@fluentui/react-charts 9.0.1 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -2
- package/dist/index.d.ts +1432 -238
- package/lib/AreaChart.js +1 -0
- package/lib/AreaChart.js.map +1 -0
- package/lib/GaugeChart.js +1 -0
- package/lib/GaugeChart.js.map +1 -0
- package/lib/GroupedVerticalBarChart.js +1 -0
- package/lib/GroupedVerticalBarChart.js.map +1 -0
- package/lib/HeatMapChart.js +1 -0
- package/lib/HeatMapChart.js.map +1 -0
- package/lib/HorizontalBarChartWithAxis.js +1 -0
- package/lib/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib/SankeyChart.js +1 -0
- package/lib/SankeyChart.js.map +1 -0
- package/lib/ScatterChart.js +1 -0
- package/lib/ScatterChart.js.map +1 -0
- package/lib/VerticalStackedBarChart.js +1 -0
- package/lib/VerticalStackedBarChart.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js +775 -0
- package/lib/components/AreaChart/AreaChart.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.types.js +4 -0
- package/lib/components/AreaChart/AreaChart.types.js.map +1 -0
- package/lib/components/AreaChart/index.js +3 -0
- package/lib/components/AreaChart/index.js.map +1 -0
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +64 -0
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +30 -14
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +112 -65
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +570 -159
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +1 -1
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +1 -1
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +592 -0
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -0
- package/lib/components/GaugeChart/GaugeChart.types.js +4 -0
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -0
- package/lib/components/GaugeChart/index.js +3 -0
- package/lib/components/GaugeChart/index.js.map +1 -0
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +174 -0
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +501 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js +4 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -0
- package/lib/components/GroupedVerticalBarChart/index.js +3 -0
- package/lib/components/GroupedVerticalBarChart/index.js.map +1 -0
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +90 -0
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -0
- package/lib/components/HeatMapChart/HeatMapChart.js +588 -0
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -0
- package/lib/components/HeatMapChart/HeatMapChart.types.js +4 -0
- package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
- package/lib/components/HeatMapChart/index.js +3 -0
- package/lib/components/HeatMapChart/index.js.map +1 -0
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +46 -0
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +571 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +4 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/index.js +3 -0
- package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +76 -0
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
- package/lib/components/Legends/Legends.js +38 -37
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/Legends.types.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +43 -35
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js +1022 -0
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -0
- package/lib/components/SankeyChart/SankeyChart.types.js +3 -0
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -0
- package/lib/components/SankeyChart/index.js +3 -0
- package/lib/components/SankeyChart/index.js.map +1 -0
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +109 -0
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.js +465 -0
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.types.js +4 -0
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -0
- package/lib/components/ScatterChart/index.js +3 -0
- package/lib/components/ScatterChart/index.js.map +1 -0
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +65 -0
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -0
- package/lib/components/Sparkline/Sparkline.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +165 -88
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +904 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +1 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/index.js +3 -0
- package/lib/components/VerticalStackedBarChart/index.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +73 -0
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/types/DataPoint.js +1 -3
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js +49 -4
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/colors.js +20 -0
- package/lib/utilities/colors.js.map +1 -1
- package/lib/utilities/string.js +32 -0
- package/lib/utilities/string.js.map +1 -0
- package/lib/utilities/test-data.js +53 -0
- package/lib/utilities/test-data.js.map +1 -1
- package/lib/utilities/utilities.js +210 -20
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/AreaChart.js +6 -0
- package/lib-commonjs/AreaChart.js.map +1 -0
- package/lib-commonjs/GaugeChart.js +6 -0
- package/lib-commonjs/GaugeChart.js.map +1 -0
- package/lib-commonjs/GroupedVerticalBarChart.js +6 -0
- package/lib-commonjs/GroupedVerticalBarChart.js.map +1 -0
- package/lib-commonjs/HeatMapChart.js +6 -0
- package/lib-commonjs/HeatMapChart.js.map +1 -0
- package/lib-commonjs/HorizontalBarChartWithAxis.js +6 -0
- package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib-commonjs/SankeyChart.js +6 -0
- package/lib-commonjs/SankeyChart.js.map +1 -0
- package/lib-commonjs/ScatterChart.js +6 -0
- package/lib-commonjs/ScatterChart.js.map +1 -0
- package/lib-commonjs/VerticalStackedBarChart.js +6 -0
- package/lib-commonjs/VerticalStackedBarChart.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js +781 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.types.js +7 -0
- package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -0
- package/lib-commonjs/components/AreaChart/index.js +8 -0
- package/lib-commonjs/components/AreaChart/index.js.map +1 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +104 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +29 -14
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +120 -73
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +592 -178
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +621 -0
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -0
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js +7 -0
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -0
- package/lib-commonjs/components/GaugeChart/index.js +8 -0
- package/lib-commonjs/components/GaugeChart/index.js.map +1 -0
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +252 -0
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +507 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js +7 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/index.js +8 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/index.js.map +1 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +139 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +599 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js +7 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/index.js +8 -0
- package/lib-commonjs/components/HeatMapChart/index.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +68 -0
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +580 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +7 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js +8 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +116 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Legends/Legends.js +37 -37
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +41 -33
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +1038 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js +6 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/index.js +8 -0
- package/lib-commonjs/components/SankeyChart/index.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +179 -0
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +471 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js +7 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/index.js +8 -0
- package/lib-commonjs/components/ScatterChart/index.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +96 -0
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +164 -87
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +915 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +6 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/index.js +8 -0
- package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +120 -0
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
- package/lib-commonjs/index.js +8 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +1 -3
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js +49 -4
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/colors.js +23 -0
- package/lib-commonjs/utilities/colors.js.map +1 -1
- package/lib-commonjs/utilities/string.js +29 -0
- package/lib-commonjs/utilities/string.js.map +1 -0
- package/lib-commonjs/utilities/test-data.js +59 -0
- package/lib-commonjs/utilities/test-data.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +206 -19
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +11 -8
- package/lib/components/DeclarativeChart/PlotlySchema.js +0 -7
- package/lib/components/DeclarativeChart/PlotlySchema.js.map +0 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +0 -10
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["colors.ts"],"sourcesContent":["export const DataVizPalette = {\n color1: 'qualitative.1',\n color2: 'qualitative.2',\n color3: 'qualitative.3',\n color4: 'qualitative.4',\n color5: 'qualitative.5',\n color6: 'qualitative.6',\n color7: 'qualitative.7',\n color8: 'qualitative.8',\n color9: 'qualitative.9',\n color10: 'qualitative.10',\n color11: 'qualitative.11',\n color12: 'qualitative.12',\n color13: 'qualitative.13',\n color14: 'qualitative.14',\n color15: 'qualitative.15',\n color16: 'qualitative.16',\n color17: 'qualitative.17',\n color18: 'qualitative.18',\n color19: 'qualitative.19',\n color20: 'qualitative.20',\n color21: 'qualitative.21',\n color22: 'qualitative.22',\n color23: 'qualitative.23',\n color24: 'qualitative.24',\n color25: 'qualitative.25',\n color26: 'qualitative.26',\n color27: 'qualitative.27',\n color28: 'qualitative.28',\n color29: 'qualitative.29',\n color30: 'qualitative.30',\n color31: 'qualitative.31',\n color32: 'qualitative.32',\n color33: 'qualitative.33',\n color34: 'qualitative.34',\n color35: 'qualitative.35',\n color36: 'qualitative.36',\n color37: 'qualitative.37',\n color38: 'qualitative.38',\n color39: 'qualitative.39',\n color40: 'qualitative.40',\n info: 'semantic.info',\n disabled: 'semantic.disabled',\n highError: 'semantic.highError',\n error: 'semantic.error',\n warning: 'semantic.warning',\n success: 'semantic.success',\n highSuccess: 'semantic.highSuccess',\n};\n\n/**\n * Key: Color code.\n * Value:\n * Index 0 - Default color / Color for light theme,\n * Index 1 - Color for dark theme\n */\ntype Palette = { [key: string]: string[] };\n\nconst QualitativePalette: Palette = {\n '1': ['#637cef'], // [cornflower.tint10],\n '2': ['#e3008c'], // [hotPink.primary],\n '3': ['#2aa0a4'], // [teal.tint20],\n '4': ['#9373c0'], // [orchid.tint10],\n '5': ['#13a10e'], // [lightGreen.primary],\n '6': ['#3a96dd'], // [lightBlue.primary],\n '7': ['#ca5010'], // [pumpkin.primary],\n '8': ['#57811b'], // [lime.shade20],\n '9': ['#b146c2'], // [lilac.primary],\n '10': ['#ae8c00'], // [gold.shade10],\n '11': ['#3c51b4', '#93a4f4'], // [cornflower.shade20, cornflower.tint30],\n '12': ['#ad006a', '#ee5fb7'], // [hotPink.shade20, hotPink.tint30],\n '13': ['#026467', '#4cb4b7'], // [teal.shade20, teal.tint30],\n '14': ['#674c8c', '#a083c9'], // [orchid.shade20, orchid.tint20],\n '15': ['#0e7a0b', '#27ac22'], // [lightGreen.shade20, lightGreen.tint10],\n '16': ['#2c72a8', '#4fa1e1'], // [lightBlue.shade20, lightBlue.tint10],\n '17': ['#9a3d0c', '#d77440'], // [pumpkin.shade20, pumpkin.tint20],\n '18': ['#405f14', '#73aa24'], // [lime.shade30, lime.primary],\n '19': ['#863593', '#c36bd1'], // [lilac.shade20, lilac.tint20],\n '20': ['#6d5700', '#d0b232'], // [gold.shade30, gold.tint20],\n '21': ['#4f6bed'], // [cornflower.primary],\n '22': ['#ea38a6'], // [hotPink.tint20],\n '23': ['#038387'], // [teal.primary],\n '24': ['#8764b8'], // [orchid.primary],\n '25': ['#11910d'], // [lightGreen.shade10],\n '26': ['#3487c7'], // [lightBlue.shade10],\n '27': ['#d06228'], // [pumpkin.tint10],\n '28': ['#689920'], // [lime.shade10],\n '29': ['#ba58c9'], // [lilac.tint10],\n '30': ['#937700', '#c19c00'], // [gold.shade20, gold.primary],\n '31': ['#2c3c85', '#c8d1fa'], // [cornflower.shade30, cornflower.tint40],\n '32': ['#7f004e', '#f7adda'], // [hotPink.shade30, hotPink.tint40],\n '33': ['#02494c', '#9bd9db'], // [teal.shade30, teal.tint40],\n '34': ['#4c3867', '#b29ad4'], // [orchid.shade30, orchid.tint30],\n '35': ['#0b5a08', '#a7e3a5'], // [lightGreen.shade30, lightGreen.tint40],\n '36': ['#20547c', '#83bdeb'], // [lightBlue.shade30, lightBlue.tint30],\n '37': ['#712d09', '#df8e64'], // [pumpkin.shade30, pumpkin.tint30],\n '38': ['#23330b', '#a4cc6c'], // [lime.shade40, lime.tint30],\n '39': ['#63276d', '#cf87da'], // [lilac.shade30, lilac.tint30],\n '40': ['#3a2f00', '#dac157'], // [gold.shade40, gold.tint30],\n};\n\nconst SemanticPalette: Palette = {\n info: ['#015cda'],\n disabled: ['#dbdbdb', '#4d4d4d'], // [grey[86], grey[30]]\n highError: ['#6e0811', '#cc2635'], // [cranberry.shade30, cranberry.tint10],\n error: ['#c50f1f', '#dc626d'], // [cranberry.primary, cranberry.tint30],\n warning: ['#f7630c', '#f87528'], // [orange.primary, orange.tint10],\n success: ['#107c10', '#54b054'], // [green.primary, green.tint30],\n highSuccess: ['#094509', '#218c21'], // [green.shade30, green.tint10],\n};\n\nconst Colors: { [key: string]: Palette } = {\n qualitative: QualitativePalette,\n semantic: SemanticPalette,\n};\n\nconst QUALITATIVE_COLORS = Object.values(QualitativePalette);\nconst TOKENS = Object.values(DataVizPalette);\n\nconst getThemeSpecificColor = (colors: string[], isDarkTheme: boolean): string => {\n if (colors.length === 0) {\n return '';\n }\n const colorIdx = Number(isDarkTheme);\n if (colorIdx < colors.length) {\n return colors[colorIdx];\n }\n return colors[0];\n};\n\nexport const getNextColor = (index: number, offset: number = 0, isDarkTheme: boolean = false): string => {\n const colors = QUALITATIVE_COLORS[(index + offset) % QUALITATIVE_COLORS.length];\n return getThemeSpecificColor(colors, isDarkTheme);\n};\n\nexport const getColorFromToken = (token: string, isDarkTheme: boolean = false): string => {\n if (TOKENS.indexOf(token) >= 0) {\n const [paletteName, colorCode] = token.split('.');\n const colors = Colors[paletteName][colorCode];\n return getThemeSpecificColor(colors, isDarkTheme);\n }\n return token;\n};\n"],"names":["DataVizPalette","color1","color2","color3","color4","color5","color6","color7","color8","color9","color10","color11","color12","color13","color14","color15","color16","color17","color18","color19","color20","color21","color22","color23","color24","color25","color26","color27","color28","color29","color30","color31","color32","color33","color34","color35","color36","color37","color38","color39","color40","info","disabled","highError","error","warning","success","highSuccess","QualitativePalette","SemanticPalette","Colors","qualitative","semantic","QUALITATIVE_COLORS","Object","values","TOKENS","getThemeSpecificColor","colors","isDarkTheme","length","colorIdx","Number","getNextColor","index","offset","getColorFromToken","token","indexOf","paletteName","colorCode","split"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EAAE;AAClB;AAEA,OAAO,MAAMK,eAAe,CAACC,OAAeC,SAAiB,CAAC,EAAEN,cAAuB,KAAK;IAC1F,MAAMD,SAASL,kBAAkB,CAAC,AAACW,CAAAA,QAAQC,MAAK,IAAKZ,mBAAmBO,MAAM,CAAC;IAC/E,OAAOH,sBAAsBC,QAAQC;AACvC,EAAE;AAEF,OAAO,MAAMO,oBAAoB,CAACC,OAAeR,cAAuB,KAAK;IAC3E,IAAIH,OAAOY,OAAO,CAACD,UAAU,GAAG;QAC9B,MAAM,CAACE,aAAaC,UAAU,GAAGH,MAAMI,KAAK,CAAC;QAC7C,MAAMb,SAASR,MAAM,CAACmB,YAAY,CAACC,UAAU;QAC7C,OAAOb,sBAAsBC,QAAQC;IACvC;IACA,OAAOQ;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["colors.ts"],"sourcesContent":["import { rgb as d3Rgb } from 'd3-color';\n\nexport const DataVizPalette = {\n color1: 'qualitative.1',\n color2: 'qualitative.2',\n color3: 'qualitative.3',\n color4: 'qualitative.4',\n color5: 'qualitative.5',\n color6: 'qualitative.6',\n color7: 'qualitative.7',\n color8: 'qualitative.8',\n color9: 'qualitative.9',\n color10: 'qualitative.10',\n color11: 'qualitative.11',\n color12: 'qualitative.12',\n color13: 'qualitative.13',\n color14: 'qualitative.14',\n color15: 'qualitative.15',\n color16: 'qualitative.16',\n color17: 'qualitative.17',\n color18: 'qualitative.18',\n color19: 'qualitative.19',\n color20: 'qualitative.20',\n color21: 'qualitative.21',\n color22: 'qualitative.22',\n color23: 'qualitative.23',\n color24: 'qualitative.24',\n color25: 'qualitative.25',\n color26: 'qualitative.26',\n color27: 'qualitative.27',\n color28: 'qualitative.28',\n color29: 'qualitative.29',\n color30: 'qualitative.30',\n color31: 'qualitative.31',\n color32: 'qualitative.32',\n color33: 'qualitative.33',\n color34: 'qualitative.34',\n color35: 'qualitative.35',\n color36: 'qualitative.36',\n color37: 'qualitative.37',\n color38: 'qualitative.38',\n color39: 'qualitative.39',\n color40: 'qualitative.40',\n info: 'semantic.info',\n disabled: 'semantic.disabled',\n highError: 'semantic.highError',\n error: 'semantic.error',\n warning: 'semantic.warning',\n success: 'semantic.success',\n highSuccess: 'semantic.highSuccess',\n};\n\n/**\n * Key: Color code.\n * Value:\n * Index 0 - Default color / Color for light theme,\n * Index 1 - Color for dark theme\n */\ntype Palette = { [key: string]: string[] };\n\nconst QualitativePalette: Palette = {\n '1': ['#637cef'], // [cornflower.tint10],\n '2': ['#e3008c'], // [hotPink.primary],\n '3': ['#2aa0a4'], // [teal.tint20],\n '4': ['#9373c0'], // [orchid.tint10],\n '5': ['#13a10e'], // [lightGreen.primary],\n '6': ['#3a96dd'], // [lightBlue.primary],\n '7': ['#ca5010'], // [pumpkin.primary],\n '8': ['#57811b'], // [lime.shade20],\n '9': ['#b146c2'], // [lilac.primary],\n '10': ['#ae8c00'], // [gold.shade10],\n '11': ['#3c51b4', '#93a4f4'], // [cornflower.shade20, cornflower.tint30],\n '12': ['#ad006a', '#ee5fb7'], // [hotPink.shade20, hotPink.tint30],\n '13': ['#026467', '#4cb4b7'], // [teal.shade20, teal.tint30],\n '14': ['#674c8c', '#a083c9'], // [orchid.shade20, orchid.tint20],\n '15': ['#0e7a0b', '#27ac22'], // [lightGreen.shade20, lightGreen.tint10],\n '16': ['#2c72a8', '#4fa1e1'], // [lightBlue.shade20, lightBlue.tint10],\n '17': ['#9a3d0c', '#d77440'], // [pumpkin.shade20, pumpkin.tint20],\n '18': ['#405f14', '#73aa24'], // [lime.shade30, lime.primary],\n '19': ['#863593', '#c36bd1'], // [lilac.shade20, lilac.tint20],\n '20': ['#6d5700', '#d0b232'], // [gold.shade30, gold.tint20],\n '21': ['#4f6bed'], // [cornflower.primary],\n '22': ['#ea38a6'], // [hotPink.tint20],\n '23': ['#038387'], // [teal.primary],\n '24': ['#8764b8'], // [orchid.primary],\n '25': ['#11910d'], // [lightGreen.shade10],\n '26': ['#3487c7'], // [lightBlue.shade10],\n '27': ['#d06228'], // [pumpkin.tint10],\n '28': ['#689920'], // [lime.shade10],\n '29': ['#ba58c9'], // [lilac.tint10],\n '30': ['#937700', '#c19c00'], // [gold.shade20, gold.primary],\n '31': ['#2c3c85', '#c8d1fa'], // [cornflower.shade30, cornflower.tint40],\n '32': ['#7f004e', '#f7adda'], // [hotPink.shade30, hotPink.tint40],\n '33': ['#02494c', '#9bd9db'], // [teal.shade30, teal.tint40],\n '34': ['#4c3867', '#b29ad4'], // [orchid.shade30, orchid.tint30],\n '35': ['#0b5a08', '#a7e3a5'], // [lightGreen.shade30, lightGreen.tint40],\n '36': ['#20547c', '#83bdeb'], // [lightBlue.shade30, lightBlue.tint30],\n '37': ['#712d09', '#df8e64'], // [pumpkin.shade30, pumpkin.tint30],\n '38': ['#23330b', '#a4cc6c'], // [lime.shade40, lime.tint30],\n '39': ['#63276d', '#cf87da'], // [lilac.shade30, lilac.tint30],\n '40': ['#3a2f00', '#dac157'], // [gold.shade40, gold.tint30],\n};\n\nconst SemanticPalette: Palette = {\n info: ['#015cda'],\n disabled: ['#dbdbdb', '#4d4d4d'], // [grey[86], grey[30]]\n highError: ['#6e0811', '#cc2635'], // [cranberry.shade30, cranberry.tint10],\n error: ['#c50f1f', '#dc626d'], // [cranberry.primary, cranberry.tint30],\n warning: ['#f7630c', '#f87528'], // [orange.primary, orange.tint10],\n success: ['#107c10', '#54b054'], // [green.primary, green.tint30],\n highSuccess: ['#094509', '#218c21'], // [green.shade30, green.tint10],\n};\n\nconst Colors: { [key: string]: Palette } = {\n qualitative: QualitativePalette,\n semantic: SemanticPalette,\n};\n\nconst QUALITATIVE_COLORS = Object.values(QualitativePalette);\nconst TOKENS = Object.values(DataVizPalette);\n\nconst getThemeSpecificColor = (colors: string[], isDarkTheme: boolean): string => {\n if (colors.length === 0) {\n return '';\n }\n const colorIdx = Number(isDarkTheme);\n if (colorIdx < colors.length) {\n return colors[colorIdx];\n }\n return colors[0];\n};\n\nexport const getNextColor = (index: number, offset: number = 0, isDarkTheme: boolean = false): string => {\n const colors = QUALITATIVE_COLORS[(index + offset) % QUALITATIVE_COLORS.length];\n return getThemeSpecificColor(colors, isDarkTheme);\n};\n\nexport const getColorFromToken = (token: string, isDarkTheme: boolean = false): string => {\n if (TOKENS.indexOf(token) >= 0) {\n const [paletteName, colorCode] = token.split('.');\n const colors = Colors[paletteName][colorCode];\n return getThemeSpecificColor(colors, isDarkTheme);\n }\n return token;\n};\n\n//For reference to how these numbers are calculated, refer https://www.w3.org/TR/WCAG/#dfn-contrast-ratio\nconst rgbLrgb1 = (v: number): number => {\n return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;\n};\n\nconst rgbLrgb = ({ r, g, b }: { r: number; g: number; b: number }): { r: number; g: number; b: number } => {\n return {\n r: rgbLrgb1(r / 255),\n g: rgbLrgb1(g / 255),\n b: rgbLrgb1(b / 255),\n };\n};\n\nconst lrgbLuminance = ({ r, g, b }: { r: number; g: number; b: number }): number => {\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n};\n\nexport const getColorContrast = (c1: string, c2: string): number => {\n const l1 = lrgbLuminance(rgbLrgb(d3Rgb(c1)));\n const l2 = lrgbLuminance(rgbLrgb(d3Rgb(c2)));\n return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);\n};\n"],"names":["rgb","d3Rgb","DataVizPalette","color1","color2","color3","color4","color5","color6","color7","color8","color9","color10","color11","color12","color13","color14","color15","color16","color17","color18","color19","color20","color21","color22","color23","color24","color25","color26","color27","color28","color29","color30","color31","color32","color33","color34","color35","color36","color37","color38","color39","color40","info","disabled","highError","error","warning","success","highSuccess","QualitativePalette","SemanticPalette","Colors","qualitative","semantic","QUALITATIVE_COLORS","Object","values","TOKENS","getThemeSpecificColor","colors","isDarkTheme","length","colorIdx","Number","getNextColor","index","offset","getColorFromToken","token","indexOf","paletteName","colorCode","split","rgbLrgb1","v","rgbLrgb","r","g","b","lrgbLuminance","getColorContrast","c1","c2","l1","l2","Math","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ME,mBAAmB,CAACC,IAAYC;IAC3C,MAAMC,KAAKJ,cAAcJ,QAAQ3E,MAAMiF;IACvC,MAAMG,KAAKL,cAAcJ,QAAQ3E,MAAMkF;IACvC,OAAO,AAACG,CAAAA,KAAKC,GAAG,CAACH,IAAIC,MAAM,IAAG,IAAMC,CAAAA,KAAKE,GAAG,CAACJ,IAAIC,MAAM,IAAG;AAC5D,EAAE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Regex that finds { and } so they can be removed on a lookup for string format
|
|
2
|
+
const FORMAT_ARGS_REGEX = /[\{\}]/g;
|
|
3
|
+
// Regex that finds {#} so it can be replaced by the arguments in string format
|
|
4
|
+
const FORMAT_REGEX = /\{\d+\}/g;
|
|
5
|
+
/**
|
|
6
|
+
* String format method, used for scenarios where at runtime you
|
|
7
|
+
* need to evaluate a formatted string given a tokenized string. This
|
|
8
|
+
* usually only is needed in localization scenarios.
|
|
9
|
+
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* "I love {0} every {1}".format("CXP")
|
|
13
|
+
* ```
|
|
14
|
+
* will result in a Debug Exception.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
export function format(s, ...values) {
|
|
19
|
+
const args = values;
|
|
20
|
+
// Callback match function
|
|
21
|
+
function replaceFunc(match) {
|
|
22
|
+
// looks up in the args
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
let replacement = args[match.replace(FORMAT_ARGS_REGEX, '')];
|
|
25
|
+
// catches undefined in nondebug and null in debug and nondebug
|
|
26
|
+
if (replacement === null || replacement === undefined) {
|
|
27
|
+
replacement = '';
|
|
28
|
+
}
|
|
29
|
+
return replacement;
|
|
30
|
+
}
|
|
31
|
+
return s.replace(FORMAT_REGEX, replaceFunc);
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["string.ts"],"sourcesContent":["// Regex that finds { and } so they can be removed on a lookup for string format\nconst FORMAT_ARGS_REGEX = /[\\{\\}]/g;\n\n// Regex that finds {#} so it can be replaced by the arguments in string format\nconst FORMAT_REGEX = /\\{\\d+\\}/g;\n\n/**\n * String format method, used for scenarios where at runtime you\n * need to evaluate a formatted string given a tokenized string. This\n * usually only is needed in localization scenarios.\n\n * @example\n * ```tsx\n * \"I love {0} every {1}\".format(\"CXP\")\n * ```\n * will result in a Debug Exception.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function format(s: string, ...values: any[]): string {\n const args = values;\n // Callback match function\n function replaceFunc(match: string): string {\n // looks up in the args\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let replacement = args[match.replace(FORMAT_ARGS_REGEX, '') as any];\n\n // catches undefined in nondebug and null in debug and nondebug\n if (replacement === null || replacement === undefined) {\n replacement = '';\n }\n\n return replacement;\n }\n return s.replace(FORMAT_REGEX, replaceFunc);\n}\n"],"names":["FORMAT_ARGS_REGEX","FORMAT_REGEX","format","s","values","args","replaceFunc","match","replacement","replace","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,gFAAgF;AAChF,MAAMA,oBAAoB;AAE1B,+EAA+E;AAC/E,MAAMC,eAAe;AAErB;;;;;;;;;;;;CAYC,GACD,8DAA8D;AAC9D,OAAO,SAASC,OAAOC,CAAS,EAAE,GAAGC,MAAa;IAChD,MAAMC,OAAOD;IACb,0BAA0B;IAC1B,SAASE,YAAYC,KAAa;QAChC,uBAAuB;QACvB,8DAA8D;QAC9D,IAAIC,cAAcH,IAAI,CAACE,MAAME,OAAO,CAACT,mBAAmB,IAAW;QAEnE,+DAA+D;QAC/D,IAAIQ,gBAAgB,QAAQA,gBAAgBE,WAAW;YACrDF,cAAc;QAChB;QAEA,OAAOA;IACT;IACA,OAAOL,EAAEM,OAAO,CAACR,cAAcK;AACjC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataVizPalette } from '../index';
|
|
1
2
|
export const chartPointsVBC = [
|
|
2
3
|
{
|
|
3
4
|
x: 0,
|
|
@@ -274,3 +275,55 @@ export const chartPointsWithAxisToolTipHBCWA = [
|
|
|
274
275
|
color: 'blue'
|
|
275
276
|
}
|
|
276
277
|
];
|
|
278
|
+
export const allNegativeChartPointsVBC = [
|
|
279
|
+
{
|
|
280
|
+
x: 0,
|
|
281
|
+
y: -10000,
|
|
282
|
+
legend: 'First',
|
|
283
|
+
color: DataVizPalette.color1,
|
|
284
|
+
xAxisCalloutData: '2020/04/30',
|
|
285
|
+
yAxisCalloutData: '10%'
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
x: 10000,
|
|
289
|
+
y: -50000,
|
|
290
|
+
legend: 'Second',
|
|
291
|
+
color: DataVizPalette.color2,
|
|
292
|
+
xAxisCalloutData: '2020/04/30',
|
|
293
|
+
yAxisCalloutData: '20%'
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
x: 25000,
|
|
297
|
+
y: -30000,
|
|
298
|
+
legend: 'Third',
|
|
299
|
+
color: DataVizPalette.color3,
|
|
300
|
+
xAxisCalloutData: '2020/04/30',
|
|
301
|
+
yAxisCalloutData: '37%'
|
|
302
|
+
}
|
|
303
|
+
];
|
|
304
|
+
export const negativeChartPointsVBC = [
|
|
305
|
+
{
|
|
306
|
+
x: 0,
|
|
307
|
+
y: 10000,
|
|
308
|
+
legend: 'First',
|
|
309
|
+
color: DataVizPalette.color1,
|
|
310
|
+
xAxisCalloutData: '2020/04/30',
|
|
311
|
+
yAxisCalloutData: '10%'
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
x: 10000,
|
|
315
|
+
y: -50000,
|
|
316
|
+
legend: 'Second',
|
|
317
|
+
color: DataVizPalette.color2,
|
|
318
|
+
xAxisCalloutData: '2020/04/30',
|
|
319
|
+
yAxisCalloutData: '20%'
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
x: 25000,
|
|
323
|
+
y: 30000,
|
|
324
|
+
legend: 'Third',
|
|
325
|
+
color: DataVizPalette.color3,
|
|
326
|
+
xAxisCalloutData: '2020/04/30',
|
|
327
|
+
yAxisCalloutData: '37%'
|
|
328
|
+
}
|
|
329
|
+
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["test-data.ts"],"sourcesContent":["import {\n ChartDataPoint,\n ChartProps,\n HorizontalBarChartWithAxisDataPoint,\n VSChartDataPoint,\n VerticalStackedChartProps,\n} from '../index';\n\nexport const chartPointsVBC = [\n {\n x: 0,\n y: 10000,\n legend: 'First',\n color: 'aqua',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '10%',\n },\n {\n x: 10000,\n y: 50000,\n legend: 'Second',\n color: 'blue',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '20%',\n },\n {\n x: 25000,\n y: 30000,\n legend: 'Third',\n color: 'navy',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '37%',\n },\n];\n\nconst firstChartPointsVSBC: VSChartDataPoint[] = [\n {\n legend: 'Metadata1',\n data: 40,\n color: 'aqua',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '40%',\n },\n {\n legend: 'Metadata2',\n data: 5,\n color: 'navy',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '5%',\n },\n];\n\nconst secondChartPointsVSBC: VSChartDataPoint[] = [\n {\n legend: 'Metadata1',\n data: 30,\n color: 'aqua',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '30%',\n },\n {\n legend: 'Metadata2',\n data: 20,\n color: 'navy',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '20%',\n },\n];\n\nexport const chartPointsVSBC: VerticalStackedChartProps[] = [\n { chartData: firstChartPointsVSBC, xAxisPoint: 0 },\n { chartData: secondChartPointsVSBC, xAxisPoint: 20 },\n];\n\nexport const chartPoints2VSBC: VerticalStackedChartProps[] = [\n {\n chartData: firstChartPointsVSBC,\n xAxisPoint: 0,\n lineData: [{ y: 15, legend: 'Line1', color: 'yellow' }],\n },\n {\n chartData: secondChartPointsVSBC,\n xAxisPoint: 20,\n lineData: [{ y: 30, legend: 'Line1', color: 'yellow' }],\n },\n];\n\nexport const emptychartPointsVSBC: VerticalStackedChartProps[] = [{ chartData: [], xAxisPoint: 0 }];\n\nexport const pointsHBCWA = [\n {\n x: 10000,\n y: 5000,\n legend: 'Oranges',\n color: 'aqua',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '10%',\n },\n {\n x: 20000,\n y: 50000,\n legend: 'Dogs',\n color: 'blue',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '20%',\n },\n {\n x: 25000,\n y: 30000,\n legend: 'Apples',\n color: 'navy',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '37%',\n },\n\n {\n x: 40000,\n y: 13000,\n legend: 'Bananas',\n color: 'teal',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '88%',\n },\n];\n\nexport const pointsDC: ChartDataPoint[] = [\n { legend: 'first', data: 20000, color: '#E5E5E5', xAxisCalloutData: '2020/04/30' },\n { legend: 'second', data: 39000, color: '#0078D4', xAxisCalloutData: '2020/04/20' },\n { legend: 'third', data: 45000, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n];\n\nexport const pointsDCElevateMinimumsExample: ChartDataPoint[] = [\n { legend: 'first', data: 39000, color: '#E5E5E5', xAxisCalloutData: '2020/04/30' },\n { legend: 'second', data: 20, color: '#0078D4', xAxisCalloutData: '2020/04/20' },\n { legend: 'third', data: 20, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n { legend: 'fourth', data: 20, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n { legend: 'fifth', data: 20, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n { legend: 'sixth', data: 20, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n];\n\nexport const chartPointsDC: ChartProps = {\n chartTitle: 'Donut chart example',\n chartData: pointsDC,\n};\n\nexport const chartPointsDCElevateMinimums: ChartProps = {\n chartTitle: 'Donut chart example',\n chartData: pointsDC,\n};\n\nexport const chartPointsHBCWA: HorizontalBarChartWithAxisDataPoint[] = [\n {\n x: 10000,\n y: 5000,\n legend: 'Oranges',\n color: 'aqua',\n yAxisCalloutData: '2020/04/30',\n xAxisCalloutData: '10%',\n },\n {\n x: 20000,\n y: 50000,\n legend: 'Grapes',\n color: 'blue',\n yAxisCalloutData: '2020/04/30',\n xAxisCalloutData: '20%',\n },\n {\n x: 25000,\n y: 30000,\n legend: 'Apples',\n color: 'navy',\n yAxisCalloutData: '2020/04/30',\n xAxisCalloutData: '37%',\n },\n\n {\n x: 40000,\n y: 13000,\n legend: 'Bananas',\n color: 'teal',\n yAxisCalloutData: '2020/04/30',\n xAxisCalloutData: '88%',\n },\n];\n\nexport const chartPointsWithStringYAxisHBCWA: HorizontalBarChartWithAxisDataPoint[] = [\n {\n y: 'String One',\n x: 1000,\n color: 'aqua',\n },\n {\n y: 'String Two',\n x: 5000,\n color: 'blue',\n },\n {\n y: 'String Three',\n x: 3000,\n color: 'navy',\n },\n {\n y: 'String Four',\n x: 2000,\n color: 'blue',\n },\n];\n\nexport const chartPointsWithAxisToolTipHBCWA: HorizontalBarChartWithAxisDataPoint[] = [\n {\n x: 1000,\n y: 1000,\n color: 'aqua',\n },\n {\n x: 2000,\n y: 5000,\n color: 'blue',\n },\n {\n x: 3000,\n y: 3000,\n color: 'navy',\n },\n {\n x: 4000,\n y: 2000,\n color: 'blue',\n },\n];\n"],"names":["chartPointsVBC","x","y","legend","color","xAxisCalloutData","yAxisCalloutData","firstChartPointsVSBC","data","secondChartPointsVSBC","chartPointsVSBC","chartData","xAxisPoint","chartPoints2VSBC","lineData","emptychartPointsVSBC","pointsHBCWA","pointsDC","pointsDCElevateMinimumsExample","chartPointsDC","chartTitle","chartPointsDCElevateMinimums","chartPointsHBCWA","chartPointsWithStringYAxisH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AO;QAAWC,kBAAkB;IAAa;IAC/E;QAAEF,QAAQ;QAASK,MAAM;QAAIJ,OAAO;QAAWC,kBAAkB;IAAa;IAC9E;QAAEF,QAAQ;QAASK,MAAM;QAAIJ,OAAO;QAAWC,kBAAkB;IAAa;CAC/E,CAAC;AAEF,OAAO,MAAMc,gBAA4B;IACvCC,YAAY;IACZT,WAAWM;AACb,EAAE;AAEF,OAAO,MAAMI,+BAA2C;IACtDD,YAAY;IACZT,WAAWM;AACb,EAAE;AAEF,OAAO,MAAMK,mBAA0D;IACrE;QACErB,GAAG;QACHC,GAAG;QACHC,QAAQ;QACRC,OAAO;QACPE,kBAAkB;QAClBD,kBAAkB;IACpB;IACA;QACEJ,GAAG;QACHC,GAAG;QACHC,QAAQ;QACRC,OAAO;QACPE,kBAAkB;QAClBD,kBAAkB;IACpB;IACA;QACEJ,GAAG;QACHC,GAAG;QACHC,QAAQ;QACRC,OAAO;QACPE,kBAAkB;QAClBD,kBAAkB;IACpB;IAEA;QACEJ,GAAG;QACHC,GAAG;QACHC,QAAQ;QACRC,OAAO;QACPE,kBAAkB;QAClBD,kBAAkB;IACpB;CACD,CAAC;AAEF,OAAO,MAAMkB,kCAAyE;IACpF;QACErB,GAAG;QACHD,GAAG;QACHG,OAAO;IACT;IACA;QACEF,GAAG;QACHD,GAAG;QACHG,OAAO;IACT;IACA;QACEF,GAAG;QACHD,GAAG;QACHG,OAAO;IACT;IACA;QACEF,GAAG;QACHD,GAAG;QACHG,OAAO;IACT;CACD,CAAC;AAEF,OAAO,MAAMoB,kCAAyE;IACpF;QACEvB,GAAG;QACHC,GAAG;QACHE,OAAO;IACT;IACA;QACEH,GAAG;QACHC,GAAG;QACHE,OAAO;IACT;IACA;QACEH,GAAG;QACHC,GAAG;QACHE,OAAO;IACT;IACA;QACEH,GAAG;QACHC,GAAG;QACHE,OAAO;IACT;CACD,CAAC"}
|
|
1
|
+
{"version":3,"sources":["test-data.ts"],"sourcesContent":["import {\n ChartDataPoint,\n ChartProps,\n HorizontalBarChartWithAxisDataPoint,\n VSChartDataPoint,\n VerticalStackedChartProps,\n VerticalBarChartDataPoint,\n DataVizPalette,\n} from '../index';\n\nexport const chartPointsVBC = [\n {\n x: 0,\n y: 10000,\n legend: 'First',\n color: 'aqua',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '10%',\n },\n {\n x: 10000,\n y: 50000,\n legend: 'Second',\n color: 'blue',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '20%',\n },\n {\n x: 25000,\n y: 30000,\n legend: 'Third',\n color: 'navy',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '37%',\n },\n];\n\nconst firstChartPointsVSBC: VSChartDataPoint[] = [\n {\n legend: 'Metadata1',\n data: 40,\n color: 'aqua',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '40%',\n },\n {\n legend: 'Metadata2',\n data: 5,\n color: 'navy',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '5%',\n },\n];\n\nconst secondChartPointsVSBC: VSChartDataPoint[] = [\n {\n legend: 'Metadata1',\n data: 30,\n color: 'aqua',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '30%',\n },\n {\n legend: 'Metadata2',\n data: 20,\n color: 'navy',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '20%',\n },\n];\n\nexport const chartPointsVSBC: VerticalStackedChartProps[] = [\n { chartData: firstChartPointsVSBC, xAxisPoint: 0 },\n { chartData: secondChartPointsVSBC, xAxisPoint: 20 },\n];\n\nexport const chartPoints2VSBC: VerticalStackedChartProps[] = [\n {\n chartData: firstChartPointsVSBC,\n xAxisPoint: 0,\n lineData: [{ y: 15, legend: 'Line1', color: 'yellow' }],\n },\n {\n chartData: secondChartPointsVSBC,\n xAxisPoint: 20,\n lineData: [{ y: 30, legend: 'Line1', color: 'yellow' }],\n },\n];\n\nexport const emptychartPointsVSBC: VerticalStackedChartProps[] = [{ chartData: [], xAxisPoint: 0 }];\n\nexport const pointsHBCWA = [\n {\n x: 10000,\n y: 5000,\n legend: 'Oranges',\n color: 'aqua',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '10%',\n },\n {\n x: 20000,\n y: 50000,\n legend: 'Dogs',\n color: 'blue',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '20%',\n },\n {\n x: 25000,\n y: 30000,\n legend: 'Apples',\n color: 'navy',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '37%',\n },\n\n {\n x: 40000,\n y: 13000,\n legend: 'Bananas',\n color: 'teal',\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '88%',\n },\n];\n\nexport const pointsDC: ChartDataPoint[] = [\n { legend: 'first', data: 20000, color: '#E5E5E5', xAxisCalloutData: '2020/04/30' },\n { legend: 'second', data: 39000, color: '#0078D4', xAxisCalloutData: '2020/04/20' },\n { legend: 'third', data: 45000, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n];\n\nexport const pointsDCElevateMinimumsExample: ChartDataPoint[] = [\n { legend: 'first', data: 39000, color: '#E5E5E5', xAxisCalloutData: '2020/04/30' },\n { legend: 'second', data: 20, color: '#0078D4', xAxisCalloutData: '2020/04/20' },\n { legend: 'third', data: 20, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n { legend: 'fourth', data: 20, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n { legend: 'fifth', data: 20, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n { legend: 'sixth', data: 20, color: '#DADADA', xAxisCalloutData: '2020/04/25' },\n];\n\nexport const chartPointsDC: ChartProps = {\n chartTitle: 'Donut chart example',\n chartData: pointsDC,\n};\n\nexport const chartPointsDCElevateMinimums: ChartProps = {\n chartTitle: 'Donut chart example',\n chartData: pointsDC,\n};\n\nexport const chartPointsHBCWA: HorizontalBarChartWithAxisDataPoint[] = [\n {\n x: 10000,\n y: 5000,\n legend: 'Oranges',\n color: 'aqua',\n yAxisCalloutData: '2020/04/30',\n xAxisCalloutData: '10%',\n },\n {\n x: 20000,\n y: 50000,\n legend: 'Grapes',\n color: 'blue',\n yAxisCalloutData: '2020/04/30',\n xAxisCalloutData: '20%',\n },\n {\n x: 25000,\n y: 30000,\n legend: 'Apples',\n color: 'navy',\n yAxisCalloutData: '2020/04/30',\n xAxisCalloutData: '37%',\n },\n\n {\n x: 40000,\n y: 13000,\n legend: 'Bananas',\n color: 'teal',\n yAxisCalloutData: '2020/04/30',\n xAxisCalloutData: '88%',\n },\n];\n\nexport const chartPointsWithStringYAxisHBCWA: HorizontalBarChartWithAxisDataPoint[] = [\n {\n y: 'String One',\n x: 1000,\n color: 'aqua',\n },\n {\n y: 'String Two',\n x: 5000,\n color: 'blue',\n },\n {\n y: 'String Three',\n x: 3000,\n color: 'navy',\n },\n {\n y: 'String Four',\n x: 2000,\n color: 'blue',\n },\n];\n\nexport const chartPointsWithAxisToolTipHBCWA: HorizontalBarChartWithAxisDataPoint[] = [\n {\n x: 1000,\n y: 1000,\n color: 'aqua',\n },\n {\n x: 2000,\n y: 5000,\n color: 'blue',\n },\n {\n x: 3000,\n y: 3000,\n color: 'navy',\n },\n {\n x: 4000,\n y: 2000,\n color: 'blue',\n },\n];\n\nexport const allNegativeChartPointsVBC: VerticalBarChartDataPoint[] = [\n {\n x: 0,\n y: -10000,\n legend: 'First',\n color: DataVizPalette.color1,\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '10%',\n },\n {\n x: 10000,\n y: -50000,\n legend: 'Second',\n color: DataVizPalette.color2,\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '20%',\n },\n {\n x: 25000,\n y: -30000,\n legend: 'Third',\n color: DataVizPalette.color3,\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '37%',\n },\n];\n\nexport const negativeChartPointsVBC: VerticalBarChartDataPoint[] = [\n {\n x: 0,\n y: 10000,\n legend: 'First',\n color: DataVizPalette.color1,\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '10%',\n },\n {\n x: 10000,\n y: -50000,\n legend: 'Second',\n color: DataVizPalette.color2,\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '20%',\n },\n {\n x: 25000,\n y: 30000,\n legend: 'Third',\n color: DataVizPalette.color3,\n xAxisCalloutData: '2020/04/30',\n yAxisCalloutData: '37%',\n },\n];\n"],"names":["DataVizPalette","chartPointsVBC","x","y","legend","color","xAxisCalloutData","yAxisCalloutData","firstChartPointsVSBC","data","secondChartPointsVSBC","chartPointsVSBC","chartData","xAxisPoint","chartPoints2VSBC","lineData","emptychartPointsVSBC","pointsHBCWA","pointsDC","pointsDCElevateMinimumsExample","chartPointsDC","chartTitle","chartPointsDCElevateMinimums","chartPointsHBCWA","chartPointsWithStringYAxisHBCWA","chartPointsWithAxisToolTipHBCWA","allNegativeChartPointsVBC","color1","color2","color3","negativeChartPointsVBC"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAOEA,cAAc,QACT,WAAW;AAElB,OAAO,MAAMC,iBAAiB;IAC5B;QACEC,GAAG;QACHC,GAAG;QACHC,QAAQ;QACRC,OAAO;QACPC,kBAAkB;QAClBC,kBAAkB;IACpB;IACA;QACEL,GAAG;QACHC,GAAG;QACHC,QAAQ;QACRC,OAAO;QACPC,kBAAkB;QAClBC,kBAAkB;IACpB;IACA;QACEL,GAAG;QACHC,GAAG;QACHC,QAAQ;QACRC,OAAO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;QAC5BvB,kBAAkB;QAClBC,kBAAkB;IACpB;CACD,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { axisRight as d3AxisRight, axisBottom as d3AxisBottom, axisLeft as d3AxisLeft } from 'd3-axis';
|
|
2
|
-
import { max as d3Max, min as d3Min } from 'd3-array';
|
|
2
|
+
import { max as d3Max, min as d3Min, ticks as d3Ticks, nice as d3nice } from 'd3-array';
|
|
3
3
|
import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3ScaleUtc, scaleTime as d3ScaleTime } from 'd3-scale';
|
|
4
4
|
import { select as d3Select, selectAll as d3SelectAll } from 'd3-selection';
|
|
5
5
|
import { format as d3Format } from 'd3-format';
|
|
6
6
|
import { timeFormat as d3TimeFormat, timeFormatLocale as d3TimeFormatLocale, utcFormat as d3UtcFormat } from 'd3-time-format';
|
|
7
7
|
import { timeSecond as d3TimeSecond, timeMinute as d3TimeMinute, timeHour as d3TimeHour, timeDay as d3TimeDay, timeMonth as d3TimeMonth, timeWeek as d3TimeWeek, timeYear as d3TimeYear, utcSecond as d3UtcSecond, utcMinute as d3UtcMinute, utcHour as d3UtcHour, utcDay as d3UtcDay, utcMonth as d3UtcMonth, utcWeek as d3UtcWeek, utcYear as d3UtcYear } from 'd3-time';
|
|
8
|
+
import { curveLinear as d3CurveLinear, curveNatural as d3CurveNatural, curveStep as d3CurveStep, curveStepAfter as d3CurveStepAfter, curveStepBefore as d3CurveStepBefore } from 'd3-shape';
|
|
8
9
|
import { formatPrefix as d3FormatPrefix } from 'd3-format';
|
|
9
10
|
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
|
10
11
|
export var ChartTypes;
|
|
@@ -16,6 +17,7 @@ export var ChartTypes;
|
|
|
16
17
|
ChartTypes[ChartTypes["GroupedVerticalBarChart"] = 4] = "GroupedVerticalBarChart";
|
|
17
18
|
ChartTypes[ChartTypes["HeatMapChart"] = 5] = "HeatMapChart";
|
|
18
19
|
ChartTypes[ChartTypes["HorizontalBarChartWithAxis"] = 6] = "HorizontalBarChartWithAxis";
|
|
20
|
+
ChartTypes[ChartTypes["ScatterChart"] = 7] = "ScatterChart";
|
|
19
21
|
})(ChartTypes || (ChartTypes = {}));
|
|
20
22
|
export var XAxisTypes;
|
|
21
23
|
(function(XAxisTypes) {
|
|
@@ -203,6 +205,31 @@ export function useRtl() {
|
|
|
203
205
|
const { dir } = useFluent(); // "dir" returns "ltr" or "rtl"
|
|
204
206
|
return dir === 'rtl';
|
|
205
207
|
}
|
|
208
|
+
function isPowerOf10(num) {
|
|
209
|
+
const roundedfinalYMax = handleFloatingPointPrecisionError(num);
|
|
210
|
+
return Math.log10(roundedfinalYMax) % 1 === 0;
|
|
211
|
+
}
|
|
212
|
+
//for reference, go through this 'https://docs.python.org/release/2.5.1/tut/node16.html'
|
|
213
|
+
function handleFloatingPointPrecisionError(num) {
|
|
214
|
+
const rounded = Math.round(num);
|
|
215
|
+
return Math.abs(num - rounded) < 1e-6 ? rounded : num;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* This method is used to calculate the rounded tick values for the y-axis
|
|
219
|
+
* @param {number} minVal
|
|
220
|
+
* @param {number} maxVal
|
|
221
|
+
* @param {number} splitInto
|
|
222
|
+
* @returns {number[]}
|
|
223
|
+
*/ function calculateRoundedTicks(minVal, maxVal, splitInto) {
|
|
224
|
+
const finalYmin = minVal >= 0 && minVal === maxVal ? 0 : minVal;
|
|
225
|
+
const finalYmax = minVal < 0 && minVal === maxVal ? 0 : maxVal;
|
|
226
|
+
const ticksInterval = d3nice(finalYmin, finalYmax, splitInto);
|
|
227
|
+
const ticks = d3Ticks(ticksInterval[0], ticksInterval[ticksInterval.length - 1], splitInto);
|
|
228
|
+
if (ticks[ticks.length - 1] > finalYmax && isPowerOf10(finalYmax)) {
|
|
229
|
+
ticks.pop();
|
|
230
|
+
}
|
|
231
|
+
return ticks;
|
|
232
|
+
}
|
|
206
233
|
/**
|
|
207
234
|
* This method used for creating data points for the y axis.
|
|
208
235
|
* @export
|
|
@@ -211,12 +238,32 @@ export function useRtl() {
|
|
|
211
238
|
* @param {number} splitInto
|
|
212
239
|
* @param {boolean} isIntegralDataset
|
|
213
240
|
* @returns {number[]}
|
|
214
|
-
*/ export function prepareDatapoints(maxVal, minVal, splitInto, isIntegralDataset) {
|
|
241
|
+
*/ export function prepareDatapoints(maxVal, minVal, splitInto, isIntegralDataset, roundedTicks) {
|
|
242
|
+
if (roundedTicks) {
|
|
243
|
+
return calculateRoundedTicks(minVal, maxVal, splitInto);
|
|
244
|
+
}
|
|
215
245
|
const val = isIntegralDataset ? Math.ceil((maxVal - minVal) / splitInto) : (maxVal - minVal) / splitInto >= 1 ? Math.ceil((maxVal - minVal) / splitInto) : (maxVal - minVal) / splitInto;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
246
|
+
/*
|
|
247
|
+
For cases where we have negative and positive values
|
|
248
|
+
The dataPointsArray is filled from 0 to minVal by val difference
|
|
249
|
+
Then the array is reversed and values from 0(excluding 0) to maxVal are appended
|
|
250
|
+
This ensures presence of 0 to act as an anchor reference.
|
|
251
|
+
For simple cases where the scale may not encounter such a need for 0,
|
|
252
|
+
We simply fill from minVal to maxVal
|
|
253
|
+
*/ const dataPointsArray = [
|
|
254
|
+
minVal < 0 && maxVal >= 0 ? 0 : minVal
|
|
219
255
|
];
|
|
256
|
+
/*For the case of all positive or all negative, we need to add another value
|
|
257
|
+
in array for atleast one interval, but in case of mix of positive and negative,
|
|
258
|
+
there will always be one more entry that will be added by the logic we have*/ if (dataPointsArray[0] === minVal) {
|
|
259
|
+
dataPointsArray.push(minVal + val);
|
|
260
|
+
}
|
|
261
|
+
if (minVal < 0 && maxVal >= 0) {
|
|
262
|
+
while(dataPointsArray[dataPointsArray.length - 1] > minVal){
|
|
263
|
+
dataPointsArray.push(dataPointsArray[dataPointsArray.length - 1] - val);
|
|
264
|
+
}
|
|
265
|
+
dataPointsArray.reverse();
|
|
266
|
+
}
|
|
220
267
|
while(dataPointsArray[dataPointsArray.length - 1] < maxVal){
|
|
221
268
|
dataPointsArray.push(dataPointsArray[dataPointsArray.length - 1] + val);
|
|
222
269
|
}
|
|
@@ -227,12 +274,12 @@ export function useRtl() {
|
|
|
227
274
|
* @export
|
|
228
275
|
* @param {IYAxisParams} yAxisParams
|
|
229
276
|
* @param {boolean} isRtl
|
|
230
|
-
*/ export function createYAxis(yAxisParams, isRtl, axisData, chartType, barWidth, isIntegralDataset, useSecondaryYScale = false) {
|
|
277
|
+
*/ export function createYAxis(yAxisParams, isRtl, axisData, chartType, barWidth, isIntegralDataset, useSecondaryYScale = false, roundedTicks = false) {
|
|
231
278
|
switch(chartType){
|
|
232
279
|
case 6:
|
|
233
280
|
return createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData, barWidth);
|
|
234
281
|
default:
|
|
235
|
-
return createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, useSecondaryYScale);
|
|
282
|
+
return createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale, roundedTicks);
|
|
236
283
|
}
|
|
237
284
|
}
|
|
238
285
|
export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData, barWidth) {
|
|
@@ -254,10 +301,10 @@ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axi
|
|
|
254
301
|
const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
|
|
255
302
|
const yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
|
|
256
303
|
yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(d3Format('.2~s'));
|
|
257
|
-
yAxisElement ? d3Select(yAxisElement).call(
|
|
304
|
+
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
258
305
|
return yAxisScale;
|
|
259
306
|
}
|
|
260
|
-
export function createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, useSecondaryYScale = false) {
|
|
307
|
+
export function createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale = false, roundedTicks = false) {
|
|
261
308
|
const { yMinMaxValues = {
|
|
262
309
|
startValue: 0,
|
|
263
310
|
endValue: 0
|
|
@@ -265,11 +312,18 @@ export function createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegr
|
|
|
265
312
|
// maxOfYVal coming from only area chart and Grouped vertical bar chart(Calculation done at base file)
|
|
266
313
|
const tempVal = maxOfYVal || yMinMaxValues.endValue;
|
|
267
314
|
const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
|
|
268
|
-
const finalYmin = yMinMaxValues.startValue
|
|
269
|
-
const domainValues = prepareDatapoints(finalYmax, finalYmin, yAxisTickCount, isIntegralDataset);
|
|
315
|
+
const finalYmin = Math.min(yMinMaxValues.startValue, yMinValue || 0);
|
|
316
|
+
const domainValues = prepareDatapoints(finalYmax, finalYmin, yAxisTickCount, isIntegralDataset, roundedTicks);
|
|
317
|
+
let yMin = finalYmin;
|
|
318
|
+
let yMax = domainValues[domainValues.length - 1];
|
|
319
|
+
if (chartType === 7) {
|
|
320
|
+
const yPadding = (yMax - yMin) * 0.1;
|
|
321
|
+
yMin = yMin - yPadding;
|
|
322
|
+
yMax = yMax + yPadding;
|
|
323
|
+
}
|
|
270
324
|
const yAxisScale = d3ScaleLinear().domain([
|
|
271
|
-
|
|
272
|
-
|
|
325
|
+
domainValues[0],
|
|
326
|
+
yMax
|
|
273
327
|
]).range([
|
|
274
328
|
containerHeight - margins.bottom,
|
|
275
329
|
margins.top + (eventAnnotationProps ? eventLabelHeight : 0)
|
|
@@ -305,7 +359,7 @@ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, chartType, bar
|
|
|
305
359
|
if (yAxisTickFormat) {
|
|
306
360
|
yAxis.tickFormat(yAxisTickFormat);
|
|
307
361
|
}
|
|
308
|
-
yAxisElement ? d3Select(yAxisElement).call(
|
|
362
|
+
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
|
|
309
363
|
return yAxisScale;
|
|
310
364
|
};
|
|
311
365
|
/**
|
|
@@ -324,7 +378,7 @@ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, chartType, bar
|
|
|
324
378
|
if (yAxisTickFormat) {
|
|
325
379
|
yAxis.tickFormat(yAxisTickFormat);
|
|
326
380
|
}
|
|
327
|
-
yAxisElement ? d3Select(yAxisElement).call(
|
|
381
|
+
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
|
|
328
382
|
return yAxisScale;
|
|
329
383
|
};
|
|
330
384
|
/**
|
|
@@ -372,8 +426,9 @@ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, chartType, bar
|
|
|
372
426
|
}
|
|
373
427
|
});
|
|
374
428
|
const result = Object.keys(xValToDataPoints).map((xValue)=>{
|
|
429
|
+
const originalXValue = isNaN(Number(xValue)) ? xValue : Number(xValue);
|
|
375
430
|
return {
|
|
376
|
-
x:
|
|
431
|
+
x: originalXValue,
|
|
377
432
|
values: xValToDataPoints[xValue]
|
|
378
433
|
};
|
|
379
434
|
});
|
|
@@ -421,7 +476,7 @@ export function getUnique(arr, comp) {
|
|
|
421
476
|
if (node === null) {
|
|
422
477
|
return;
|
|
423
478
|
}
|
|
424
|
-
const axisNode = d3Select(node).call(
|
|
479
|
+
const axisNode = d3Select(node).call(xAxis);
|
|
425
480
|
let removeVal = 0;
|
|
426
481
|
const width = 10;
|
|
427
482
|
const arr = [];
|
|
@@ -490,6 +545,7 @@ yAxis, noOfCharsToTruncate, truncateLabel, xValue, isRtl) {
|
|
|
490
545
|
if (node === null) {
|
|
491
546
|
return;
|
|
492
547
|
}
|
|
548
|
+
let tickIndex = 0;
|
|
493
549
|
const axisNode = d3Select(node).call(yAxis);
|
|
494
550
|
axisNode.selectAll('.tick text').each(function() {
|
|
495
551
|
const text = d3Select(this);
|
|
@@ -501,11 +557,12 @@ yAxis, noOfCharsToTruncate, truncateLabel, xValue, isRtl) {
|
|
|
501
557
|
const x = text.attr('x');
|
|
502
558
|
const dy = parseFloat(text.attr('dy'));
|
|
503
559
|
const dx = 0;
|
|
504
|
-
|
|
560
|
+
const uid = tickIndex++;
|
|
561
|
+
text.text(null).append('tspan').attr('x', x).attr('y', y).attr('id', `BaseSpan-${uid}`).attr('dy', dy + 'em').attr('data-', totalWord);
|
|
505
562
|
if (truncateLabel && totalWordLength > noOfCharsToTruncate) {
|
|
506
|
-
text.append('tspan').attr('id',
|
|
563
|
+
text.append('tspan').attr('id', `showDots-${uid}`).attr('x', isRtl ? 0 : x).attr('y', y).attr('dy', dy).attr('dx', padding + dx + 'em').text(truncatedWord);
|
|
507
564
|
} else {
|
|
508
|
-
text.attr('text-align', 'start').append('tspan').attr('id',
|
|
565
|
+
text.attr('text-align', 'start').append('tspan').attr('id', `LessLength-${uid}`).attr('x', isRtl ? 0 : x).attr('y', y).attr('dx', padding + dx + 'em').text(totalWord);
|
|
509
566
|
}
|
|
510
567
|
});
|
|
511
568
|
}
|
|
@@ -626,6 +683,40 @@ export function tooltipOfXAxislabels(xAxistooltipProps) {
|
|
|
626
683
|
rEndValue
|
|
627
684
|
};
|
|
628
685
|
}
|
|
686
|
+
/**
|
|
687
|
+
* Calculates Domain and range values for Numeric X axis for scatter chart.
|
|
688
|
+
* @export
|
|
689
|
+
* @param {LineChartPoints[]} points
|
|
690
|
+
* @param {IMargins} margins
|
|
691
|
+
* @param {number} width
|
|
692
|
+
* @param {boolean} isRTL
|
|
693
|
+
* @returns {IDomainNRange}
|
|
694
|
+
*/ export function domainRangeOfNumericForScatterChart(points, margins, width, isRTL) {
|
|
695
|
+
let xMin = d3Min(points, (point)=>{
|
|
696
|
+
return d3Min(point.data, (item)=>item.x);
|
|
697
|
+
});
|
|
698
|
+
let xMax = d3Max(points, (point)=>{
|
|
699
|
+
return d3Max(point.data, (item)=>{
|
|
700
|
+
return item.x;
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
const xPadding = (xMax - xMin) * 0.1;
|
|
704
|
+
xMin = xMin - xPadding;
|
|
705
|
+
xMax = xMax + xPadding;
|
|
706
|
+
const rStartValue = margins.left;
|
|
707
|
+
const rEndValue = width - margins.right;
|
|
708
|
+
return isRTL ? {
|
|
709
|
+
dStartValue: xMax,
|
|
710
|
+
dEndValue: xMin,
|
|
711
|
+
rStartValue,
|
|
712
|
+
rEndValue
|
|
713
|
+
} : {
|
|
714
|
+
dStartValue: xMin,
|
|
715
|
+
dEndValue: xMax,
|
|
716
|
+
rStartValue,
|
|
717
|
+
rEndValue
|
|
718
|
+
};
|
|
719
|
+
}
|
|
629
720
|
/**
|
|
630
721
|
* Calculates Domain and range values for Numeric X axis.
|
|
631
722
|
* This method calculates Horizontal Chart with Axis
|
|
@@ -760,6 +851,59 @@ export function tooltipOfXAxislabels(xAxistooltipProps) {
|
|
|
760
851
|
rEndValue
|
|
761
852
|
};
|
|
762
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* Calculates Domain and range values for Date X axis for scatter chart.
|
|
856
|
+
* @export
|
|
857
|
+
* @param {LineChartPoints[]} points
|
|
858
|
+
* @param {IMargins} margins
|
|
859
|
+
* @param {number} width
|
|
860
|
+
* @param {boolean} isRTL
|
|
861
|
+
* @param {Date[] | number[]} tickValues
|
|
862
|
+
* @returns {IDomainNRange}
|
|
863
|
+
*/ export function domainRangeOfDateForScatterChart(points, margins, width, isRTL, tickValues = []) {
|
|
864
|
+
let sDate;
|
|
865
|
+
let lDate;
|
|
866
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
867
|
+
sDate = d3Min(points, (point)=>{
|
|
868
|
+
return d3Min(point.data, (item)=>{
|
|
869
|
+
return item.x;
|
|
870
|
+
});
|
|
871
|
+
});
|
|
872
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
873
|
+
lDate = d3Max(points, (point)=>{
|
|
874
|
+
return d3Max(point.data, (item)=>{
|
|
875
|
+
return item.x;
|
|
876
|
+
});
|
|
877
|
+
});
|
|
878
|
+
const xPadding = (lDate.getTime() - sDate.getTime()) * 0.1;
|
|
879
|
+
sDate = new Date(sDate.getTime() - xPadding);
|
|
880
|
+
lDate = new Date(lDate.getTime() + xPadding);
|
|
881
|
+
// Need to draw graph with given small and large date
|
|
882
|
+
// (Which Involves customization of date axis tick values)
|
|
883
|
+
// That may be Either from given graph data or from prop 'tickValues' date values.
|
|
884
|
+
// So, Finding smallest and largest dates
|
|
885
|
+
sDate = d3Min([
|
|
886
|
+
...tickValues,
|
|
887
|
+
sDate
|
|
888
|
+
]);
|
|
889
|
+
lDate = d3Max([
|
|
890
|
+
...tickValues,
|
|
891
|
+
lDate
|
|
892
|
+
]);
|
|
893
|
+
const rStartValue = margins.left;
|
|
894
|
+
const rEndValue = width - margins.right;
|
|
895
|
+
return isRTL ? {
|
|
896
|
+
dStartValue: lDate,
|
|
897
|
+
dEndValue: sDate,
|
|
898
|
+
rStartValue,
|
|
899
|
+
rEndValue
|
|
900
|
+
} : {
|
|
901
|
+
dStartValue: sDate,
|
|
902
|
+
dEndValue: lDate,
|
|
903
|
+
rStartValue,
|
|
904
|
+
rEndValue
|
|
905
|
+
};
|
|
906
|
+
}
|
|
763
907
|
/**
|
|
764
908
|
* Calculate domain and range values to the Vertical bar chart - For Numeric axis
|
|
765
909
|
* @export
|
|
@@ -817,6 +961,9 @@ points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shift
|
|
|
817
961
|
case 6:
|
|
818
962
|
domainNRangeValue = domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, width, isRTL, shiftX);
|
|
819
963
|
break;
|
|
964
|
+
case 7:
|
|
965
|
+
domainNRangeValue = domainRangeOfNumericForScatterChart(points, margins, width, isRTL);
|
|
966
|
+
break;
|
|
820
967
|
default:
|
|
821
968
|
domainNRangeValue = {
|
|
822
969
|
dStartValue: 0,
|
|
@@ -833,6 +980,9 @@ points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shift
|
|
|
833
980
|
case 3:
|
|
834
981
|
domainNRangeValue = domainRangeOfDateForAreaLineVerticalBarChart(points, margins, width, isRTL, tickValues, chartType, barWidth);
|
|
835
982
|
break;
|
|
983
|
+
case 7:
|
|
984
|
+
domainNRangeValue = domainRangeOfDateForScatterChart(points, margins, width, isRTL, tickValues);
|
|
985
|
+
break;
|
|
836
986
|
default:
|
|
837
987
|
domainNRangeValue = {
|
|
838
988
|
dStartValue: 0,
|
|
@@ -848,6 +998,7 @@ points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shift
|
|
|
848
998
|
case 4:
|
|
849
999
|
case 2:
|
|
850
1000
|
case 5:
|
|
1001
|
+
case 7:
|
|
851
1002
|
domainNRangeValue = domainRangeOfXStringAxis(margins, width, isRTL);
|
|
852
1003
|
break;
|
|
853
1004
|
default:
|
|
@@ -958,6 +1109,7 @@ points, chartType, yAxisType = 0) {
|
|
|
958
1109
|
switch(chartType){
|
|
959
1110
|
case 0:
|
|
960
1111
|
case 1:
|
|
1112
|
+
case 7:
|
|
961
1113
|
minMaxValues = findNumericMinMaxOfY(points);
|
|
962
1114
|
break;
|
|
963
1115
|
case 3:
|
|
@@ -1206,6 +1358,20 @@ export const formatDate = (date, useUTC)=>{
|
|
|
1206
1358
|
const timeFormat = useUTC ? d3UtcFormat : d3TimeFormat;
|
|
1207
1359
|
return timeFormat('%-e %b %Y, %H:%M')(date) + (useUTC ? ' GMT' : '');
|
|
1208
1360
|
};
|
|
1361
|
+
export function areArraysEqual(arr1, arr2) {
|
|
1362
|
+
if (arr1 === arr2 || !arr1 && !arr2) {
|
|
1363
|
+
return true;
|
|
1364
|
+
}
|
|
1365
|
+
if (!arr1 || !arr2 || arr1.length !== arr2.length) {
|
|
1366
|
+
return false;
|
|
1367
|
+
}
|
|
1368
|
+
for(let i = 0; i < arr1.length; i++){
|
|
1369
|
+
if (arr1[i] !== arr2[i]) {
|
|
1370
|
+
return false;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return true;
|
|
1374
|
+
}
|
|
1209
1375
|
const cssVarRegExp = /var\((--[a-zA-Z0-9\-]+)\)/g;
|
|
1210
1376
|
export function resolveCSSVariables(chartContainer, styleRules) {
|
|
1211
1377
|
const containerStyles = getComputedStyle(chartContainer);
|
|
@@ -1213,3 +1379,27 @@ export function resolveCSSVariables(chartContainer, styleRules) {
|
|
|
1213
1379
|
return containerStyles.getPropertyValue(group1);
|
|
1214
1380
|
});
|
|
1215
1381
|
}
|
|
1382
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1383
|
+
export function getSecureProps(props = {}) {
|
|
1384
|
+
const { dangerouslySetInnerHTML, ...result } = props;
|
|
1385
|
+
return result;
|
|
1386
|
+
}
|
|
1387
|
+
export function getCurveFactory(curve, defaultFactory = d3CurveLinear) {
|
|
1388
|
+
if (typeof curve === 'function') {
|
|
1389
|
+
return curve;
|
|
1390
|
+
}
|
|
1391
|
+
switch(curve){
|
|
1392
|
+
case 'linear':
|
|
1393
|
+
return d3CurveLinear;
|
|
1394
|
+
case 'natural':
|
|
1395
|
+
return d3CurveNatural;
|
|
1396
|
+
case 'step':
|
|
1397
|
+
return d3CurveStep;
|
|
1398
|
+
case 'stepAfter':
|
|
1399
|
+
return d3CurveStepAfter;
|
|
1400
|
+
case 'stepBefore':
|
|
1401
|
+
return d3CurveStepBefore;
|
|
1402
|
+
default:
|
|
1403
|
+
return defaultFactory;
|
|
1404
|
+
}
|
|
1405
|
+
}
|