import { RadialGauge } from 'reaviz';
import { categoryData, categoryDataStackedArcs } from 'reaviz-data-utils';
import {
RadialGaugeArc,
RadialGaugeSeries,
StackedRadialGaugeValueLabel,
StackedRadialGaugeSeries,
StackedRadialGaugeDescriptionLabel
} from 'reaviz';
import { Gradient } from 'reaviz';
import { max } from 'd3-array';
import { ChartDataShape, ColorSchemeType } from 'reaviz';
import React from 'react';
import { StoryFn } from '@storybook/react';
export default {
tags: ['snapshot'],
title: 'Charts/Gauge/Radial'
};
export const Single = () => (
}
/>
);
export const FilledArc = () => (
}
/>
}
/>
);
export const CustomArc = () => (
}
innerArc={}
arcWidth={25}
colorScheme={['#38e52c']}
/>
}
/>
);
export const Multi = () => {
const maxValue = max(categoryData, (d) => d.data as number);
const colorScheme: string[] = ['#CE003E', '#DF8D03', '#00ECB1', '#9FA9B1'];
return (
}
/>
);
};
export const MultiLine = () => (
}
/>
);
export const Stacked = () => {
const colorScheme: string[] = ['#CE003E', '#DF8D03', '#00ECB1', '#9FA9B1'];
return (
}
descriptionLabel={
}
/>
}
/>
);
};
interface GaugeStackedTemplateProps {
width: number;
height: number;
data: ChartDataShape[];
colorSchemaType: 'handlerFn' | 'array' | 'string';
}
const GaugeStackedTemplate: StoryFn = ({
width,
height,
data,
colorSchemaType
}) => {
const defaultColor = '#948d62';
const customColorScheme: Record = {
'Third Party': '#DF8D03',
Malware: '#993FFF',
DLP: '#D9C0FF',
IDS: '#00FFC7'
};
const colorSchemeHandler = (data: ChartDataShape) => {
const key = data.key;
if (typeof key === 'string' && customColorScheme[key]) {
return customColorScheme[key];
}
return defaultColor;
};
const colorSchemeArr: string[] = ['#c42656', '#03df2f', '#6747b4', '#ccd016'];
let colorSchema: ColorSchemeType;
switch (colorSchemaType) {
case 'handlerFn':
colorSchema = colorSchemeHandler;
break;
case 'array':
colorSchema = colorSchemeArr;
break;
default:
colorSchema = defaultColor;
}
const descriptionElement = (
Hours Complete
67%
↑ 4%
from last week
);
return (
}
/>
);
};
export const GaugeStacked = GaugeStackedTemplate.bind({});
GaugeStacked.args = {
width: 700,
height: 300,
data: categoryDataStackedArcs,
maxValue: undefined,
colorSchemaType: 'handlerFn'
};
GaugeStacked.argTypes = {
width: { control: { type: 'number', min: 300, max: 700, step: 10 } },
height: { control: { type: 'number', min: 300, max: 700, step: 10 } },
data: {
type: 'object'
},
maxValue: {
type: 'number'
},
colorSchemaType: {
control: 'inline-radio',
options: ['handlerFn', 'array', 'string']
}
};
export const Autosize = () => (
);
export const WithGradient = () => (
} />
}
/>
}
/>
);