@gitlab/ui
Version:
GitLab UI Components
79 lines (71 loc) • 1.66 kB
JavaScript
import { GlHeatmap } from '../../../charts';
import { toolbox } from '../../../utils/charts/story_config';
import { disableControls } from '../../../utils/stories_utils';
function generateData() {
let data = [
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ],
];
data = data.map((item) => [item[1], item[0], item[2] || '-']);
return data;
}
const template = `
<gl-heatmap
:data-series="data"
:x-axis-labels="xAxisLabels"
:y-axis-labels="yAxisLabels"
:x-axis-name="xAxisName"
:y-axis-name="yAxisName"
:options="options"
:height="height"
:show-tooltip="showTooltip"
/>
`;
const generateProps = ({
data = generateData(),
xAxisLabels = ['12', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'],
yAxisLabels = ['Sat', 'Fri', 'Thu', 'Wed', 'Tue', 'Mon', 'Sun'],
xAxisName = 'Hour',
yAxisName = 'Day',
options = {},
height = null,
showTooltip = true,
} = {}) => ({
data,
xAxisLabels,
yAxisLabels,
xAxisName,
yAxisName,
options,
height,
showTooltip,
});
const Template = (args, { argTypes }) => ({
components: {
GlHeatmap,
},
props: Object.keys(argTypes),
template,
});
export const Default = Template.bind({});
Default.args = generateProps();
export const WithToolbox = Template.bind({});
WithToolbox.args = generateProps({ options: { toolbox } });
export default {
title: 'charts/heatmap',
component: GlHeatmap,
argTypes: {
...disableControls([
'dataSeries',
'formatTooltipText',
'legendAverageText',
'legendMaxText',
'responsive',
]),
},
};