@fluentui/react-charting 5.23.32 → 5.23.33
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.json +34 -1
- package/CHANGELOG.md +14 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/AreaChart/AreaChart.base.d.ts +4 -1
- package/lib/components/AreaChart/AreaChart.base.js +56 -35
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +7 -6
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +56 -51
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.d.ts +4 -1
- package/lib-amd/components/AreaChart/AreaChart.base.js +55 -34
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +7 -6
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +55 -50
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +4 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +55 -34
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +7 -6
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.d.ts +3 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +55 -50
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/package.json +3 -3
|
@@ -65,9 +65,10 @@ export var DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
65
65
|
React.useImperativeHandle(props.componentRef, function () { return ({
|
|
66
66
|
exportAsImage: exportAsImage,
|
|
67
67
|
}); }, [exportAsImage]);
|
|
68
|
+
var multiSelectLegendProps = __assign(__assign({}, legendProps), { canSelectMultipleLegends: true, selectedLegends: activeLegends });
|
|
68
69
|
switch (data[0].type) {
|
|
69
70
|
case 'pie':
|
|
70
|
-
return (React.createElement(DonutChart, __assign({}, transformPlotlyJsonToDonutProps(plotlySchema, colorMap, isDarkTheme), { legendProps:
|
|
71
|
+
return (React.createElement(DonutChart, __assign({}, transformPlotlyJsonToDonutProps(plotlySchema, colorMap, isDarkTheme), { legendProps: multiSelectLegendProps, componentRef: chartRef,
|
|
71
72
|
// Bubble event to prevent right click to open menu on the callout
|
|
72
73
|
calloutProps: { layerProps: { eventBubblingEnabled: true } } })));
|
|
73
74
|
case 'bar':
|
|
@@ -77,15 +78,15 @@ export var DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
77
78
|
}
|
|
78
79
|
else {
|
|
79
80
|
if (['group', 'overlay'].includes((_b = plotlySchema === null || plotlySchema === void 0 ? void 0 : plotlySchema.layout) === null || _b === void 0 ? void 0 : _b.barmode)) {
|
|
80
|
-
return (React.createElement(GroupedVerticalBarChart, __assign({}, transformPlotlyJsonToGVBCProps(plotlySchema, colorMap, isDarkTheme), { legendProps:
|
|
81
|
+
return (React.createElement(GroupedVerticalBarChart, __assign({}, transformPlotlyJsonToGVBCProps(plotlySchema, colorMap, isDarkTheme), { legendProps: multiSelectLegendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } })));
|
|
81
82
|
}
|
|
82
|
-
return (React.createElement(VerticalStackedBarChart, __assign({}, transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme), { legendProps:
|
|
83
|
+
return (React.createElement(VerticalStackedBarChart, __assign({}, transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme), { legendProps: multiSelectLegendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } })));
|
|
83
84
|
}
|
|
84
85
|
case 'scatter':
|
|
85
86
|
var isAreaChart_1 = data.some(function (series) { return series.fill === 'tonexty' || series.fill === 'tozeroy'; });
|
|
86
87
|
var renderChart = function (chartProps) {
|
|
87
88
|
if (isAreaChart_1) {
|
|
88
|
-
return React.createElement(AreaChart, __assign({}, chartProps));
|
|
89
|
+
return (React.createElement(AreaChart, __assign({}, chartProps, { legendProps: __assign(__assign({}, legendProps), { canSelectMultipleLegends: true, selectedLegends: activeLegends }) })));
|
|
89
90
|
}
|
|
90
91
|
return (React.createElement(LineChart, __assign({}, chartProps, { legendProps: {
|
|
91
92
|
onChange: onActiveLegendsChange,
|
|
@@ -102,7 +103,7 @@ export var DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
102
103
|
var chartProps = __assign(__assign({}, transformPlotlyJsonToScatterChartProps({ data: updatedData, layout: layout }, isAreaChart_1, colorMap, isDarkTheme)), { legendProps: legendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } });
|
|
103
104
|
return renderChart(chartProps);
|
|
104
105
|
}
|
|
105
|
-
return (React.createElement(VerticalStackedBarChart, __assign({}, transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme), { legendProps:
|
|
106
|
+
return (React.createElement(VerticalStackedBarChart, __assign({}, transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme), { legendProps: multiSelectLegendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } })));
|
|
106
107
|
case 'heatmap':
|
|
107
108
|
return (React.createElement(HeatMapChart, __assign({}, transformPlotlyJsonToHeatmapProps(plotlySchema), { legendProps: legendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } })));
|
|
108
109
|
case 'sankey':
|
|
@@ -113,7 +114,7 @@ export var DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
113
114
|
}
|
|
114
115
|
return React.createElement("div", null, "Unsupported Schema");
|
|
115
116
|
case 'histogram':
|
|
116
|
-
return (React.createElement(VerticalBarChart, __assign({}, transformPlotlyJsonToVBCProps(plotlySchema, colorMap, isDarkTheme), { legendProps:
|
|
117
|
+
return (React.createElement(VerticalBarChart, __assign({}, transformPlotlyJsonToVBCProps(plotlySchema, colorMap, isDarkTheme), { legendProps: multiSelectLegendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } })));
|
|
117
118
|
default:
|
|
118
119
|
throw new Error('Unsupported chart schema');
|
|
119
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,uDAAuD;AACvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EACtC,+CAA+C,EAC/C,iCAAiC,EACjC,gCAAgC,EAChC,+BAA+B,EAC/B,8BAA8B,EAC9B,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YA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I,EAAE,EAAE,IAC5D,CACH,CAAC;QACJ,KAAK,WAAW;YACd,IAAI,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvC,OAAO,CACL,oBAAC,UAAU,eACL,+BAA+B,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACxE,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,QAAQ,EACtB,YAAY,EAAE,EAAE,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,IAC5D,CACH,CAAC;YACJ,CAAC;YACD,OAAO,sDAA6B,CAAC;QACvC,KAAK,WAAW;YACd,OAAO,CACL,oBAAC,gBAAgB,eACX,6BAA6B,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACtE,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,QAAQ,EACtB,YAAY,EAAE,EAAE,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,IAC5D,CACH,CAAC;QACJ;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport { useTheme } from '@fluentui/react';\nimport { IRefObject } from '@fluentui/react/lib/Utilities';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport {\n isArrayOrTypedArray,\n isDateArray,\n isNumberArray,\n isMonthArray,\n sanitizeJson,\n updateXValues,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n} from './PlotlySchemaAdapter';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { IImageExportOptions, toImage } from './imageExporter';\nimport { IChart } from '../../types/index';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IDeclarativeChart>;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: IImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const { data, layout } = plotlySchema;\n let { selectedLegends } = plotlySchema;\n const xValues = data[0].x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const isXMonth = isMonthArray(xValues);\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { data, layout, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const legendProps = {\n canSelectMultipleLegends: false,\n onChange: onActiveLegendsChange,\n selectedLegend: activeLegends.slice(0, 1)[0],\n };\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions) => {\n return toImage(chartRef.current?.chartContainer, {\n background: theme.palette.white,\n ...opts,\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n switch (data[0].type) {\n case 'pie':\n return (\n <DonutChart\n {...transformPlotlyJsonToDonutProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={{ ...legendProps, canSelectMultipleLegends: true, selectedLegends: activeLegends }}\n componentRef={chartRef}\n // Bubble event to prevent right click to open menu on the callout\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'bar':\n const orientation = data[0].orientation;\n if (orientation === 'h') {\n return (\n <HorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n } else {\n if (['group', 'overlay'].includes(plotlySchema?.layout?.barmode)) {\n return (\n <GroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={{ ...legendProps, canSelectMultipleLegends: true, selectedLegends: activeLegends }}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={{ ...legendProps, canSelectMultipleLegends: true, selectedLegends: activeLegends }}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n case 'scatter':\n const isAreaChart = data.some((series: any) => series.fill === 'tonexty' || series.fill === 'tozeroy');\n const renderChart = (chartProps: any) => {\n if (isAreaChart) {\n return <AreaChart {...chartProps} />;\n }\n return (\n <LineChart\n {...{\n ...chartProps,\n legendProps: {\n onChange: onActiveLegendsChange,\n canSelectMultipleLegends: true,\n selectedLegends: activeLegends,\n },\n }}\n />\n );\n };\n if (isXDate || isXNumber) {\n const chartProps = {\n ...transformPlotlyJsonToScatterChartProps({ data, layout }, isAreaChart, colorMap, isDarkTheme),\n legendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n return renderChart(chartProps);\n } else if (isXMonth) {\n const updatedData = data.map((dataPoint: any) => ({\n ...dataPoint,\n x: updateXValues(dataPoint.x),\n }));\n const chartProps = {\n ...transformPlotlyJsonToScatterChartProps({ data: updatedData, layout }, isAreaChart, colorMap, isDarkTheme),\n legendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n return renderChart(chartProps);\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={{ ...legendProps, canSelectMultipleLegends: true, selectedLegends: activeLegends }}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'heatmap':\n return (\n <HeatMapChart\n {...transformPlotlyJsonToHeatmapProps(plotlySchema)}\n legendProps={legendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'sankey':\n return (\n <SankeyChart\n {...transformPlotlyJsonToSankeyProps(plotlySchema, colorMap, isDarkTheme)}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'indicator':\n if (data?.[0]?.mode?.includes('gauge')) {\n return (\n <GaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n return <div>Unsupported Schema</div>;\n case 'histogram':\n return (\n <VerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n default:\n throw new Error('Unsupported chart schema');\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\n"]}
|
|
1
|
+
{"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,uDAAuD;AACvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,+BAA+B,EAC/B,8BAA8B,EAC9B,sCAAsC,EAC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AY,EAAE,EAAE,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,IAC5D,CACH,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,CACL,oBAAC,WAAW,eACN,gCAAgC,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACzE,YAAY,EAAE,QAAQ,EACtB,YAAY,EAAE,EAAE,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,IAC5D,CACH,CAAC;QACJ,KAAK,WAAW;YACd,IAAI,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvC,OAAO,CACL,oBAAC,UAAU,eACL,+BAA+B,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACxE,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,QAAQ,EACtB,YAAY,EAAE,EAAE,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,IAC5D,CACH,CAAC;YACJ,CAAC;YACD,OAAO,sDAA6B,CAAC;QACvC,KAAK,WAAW;YACd,OAAO,CACL,oBAAC,gBAAgB,eACX,6BAA6B,CAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACtE,WAAW,EAAE,sBAAsB,EACnC,YAAY,EAAE,QAAQ,EACtB,YAAY,EAAE,EAAE,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,IAC5D,CACH,CAAC;QACJ;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport { useTheme } from '@fluentui/react';\nimport { IRefObject } from '@fluentui/react/lib/Utilities';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport {\n isArrayOrTypedArray,\n isDateArray,\n isNumberArray,\n isMonthArray,\n sanitizeJson,\n updateXValues,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n} from './PlotlySchemaAdapter';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { IImageExportOptions, toImage } from './imageExporter';\nimport { IChart } from '../../types/index';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IDeclarativeChart>;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: IImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const { data, layout } = plotlySchema;\n let { selectedLegends } = plotlySchema;\n const xValues = data[0].x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const isXMonth = isMonthArray(xValues);\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { data, layout, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const legendProps = {\n canSelectMultipleLegends: false,\n onChange: onActiveLegendsChange,\n selectedLegend: activeLegends.slice(0, 1)[0],\n };\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions) => {\n return toImage(chartRef.current?.chartContainer, {\n background: theme.palette.white,\n ...opts,\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n const multiSelectLegendProps = {\n ...legendProps,\n canSelectMultipleLegends: true,\n selectedLegends: activeLegends,\n };\n\n switch (data[0].type) {\n case 'pie':\n return (\n <DonutChart\n {...transformPlotlyJsonToDonutProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n // Bubble event to prevent right click to open menu on the callout\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'bar':\n const orientation = data[0].orientation;\n if (orientation === 'h') {\n return (\n <HorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n } else {\n if (['group', 'overlay'].includes(plotlySchema?.layout?.barmode)) {\n return (\n <GroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n case 'scatter':\n const isAreaChart = data.some((series: any) => series.fill === 'tonexty' || series.fill === 'tozeroy');\n const renderChart = (chartProps: any) => {\n if (isAreaChart) {\n return (\n <AreaChart\n {...chartProps}\n legendProps={{ ...legendProps, canSelectMultipleLegends: true, selectedLegends: activeLegends }}\n />\n );\n }\n return (\n <LineChart\n {...{\n ...chartProps,\n legendProps: {\n onChange: onActiveLegendsChange,\n canSelectMultipleLegends: true,\n selectedLegends: activeLegends,\n },\n }}\n />\n );\n };\n if (isXDate || isXNumber) {\n const chartProps = {\n ...transformPlotlyJsonToScatterChartProps({ data, layout }, isAreaChart, colorMap, isDarkTheme),\n legendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n return renderChart(chartProps);\n } else if (isXMonth) {\n const updatedData = data.map((dataPoint: any) => ({\n ...dataPoint,\n x: updateXValues(dataPoint.x),\n }));\n const chartProps = {\n ...transformPlotlyJsonToScatterChartProps({ data: updatedData, layout }, isAreaChart, colorMap, isDarkTheme),\n legendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n return renderChart(chartProps);\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'heatmap':\n return (\n <HeatMapChart\n {...transformPlotlyJsonToHeatmapProps(plotlySchema)}\n legendProps={legendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'sankey':\n return (\n <SankeyChart\n {...transformPlotlyJsonToSankeyProps(plotlySchema, colorMap, isDarkTheme)}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'indicator':\n if (data?.[0]?.mode?.includes('gauge')) {\n return (\n <GaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={legendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n return <div>Unsupported Schema</div>;\n case 'histogram':\n return (\n <VerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n default:\n throw new Error('Unsupported chart schema');\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\n"]}
|
|
@@ -11,6 +11,7 @@ export interface IVerticalBarChartState extends IBasestate {
|
|
|
11
11
|
hoverXValue?: string | number | null;
|
|
12
12
|
callOutAccessibilityData?: IAccessibilityProps;
|
|
13
13
|
calloutLegend: string;
|
|
14
|
+
selectedLegends: string[];
|
|
14
15
|
}
|
|
15
16
|
export declare class VerticalBarChartBase extends React.Component<IVerticalBarChartProps, IVerticalBarChartState> implements IChart {
|
|
16
17
|
static defaultProps: Partial<IVerticalBarChartProps>;
|
|
@@ -66,10 +67,10 @@ export declare class VerticalBarChartBase extends React.Component<IVerticalBarCh
|
|
|
66
67
|
private _createStringBars;
|
|
67
68
|
private _createDateBars;
|
|
68
69
|
private _closeCallout;
|
|
69
|
-
private _onLegendClick;
|
|
70
70
|
private _onLegendHover;
|
|
71
71
|
private _onLegendLeave;
|
|
72
72
|
private _getLegendData;
|
|
73
|
+
private _onLegendSelectionChange;
|
|
73
74
|
private _getAxisData;
|
|
74
75
|
/**
|
|
75
76
|
* This function checks if the given legend is highlighted or not.
|
|
@@ -82,6 +83,7 @@ export declare class VerticalBarChartBase extends React.Component<IVerticalBarCh
|
|
|
82
83
|
* This function checks if none of the legends is selected or hovered.
|
|
83
84
|
*/
|
|
84
85
|
private _noLegendHighlighted;
|
|
86
|
+
private _getHighlightedLegend;
|
|
85
87
|
private _getAriaLabel;
|
|
86
88
|
private _renderBarLabel;
|
|
87
89
|
private _getDomainMargins;
|
|
@@ -8,7 +8,7 @@ import { classNamesFunction, getId, getRTL, initializeComponentRef } from '@flue
|
|
|
8
8
|
import { DirectionalHint } from '@fluentui/react/lib/Callout';
|
|
9
9
|
import { CartesianChart, ChartHoverCard, Legends, } from '../../index';
|
|
10
10
|
import { FocusZoneDirection } from '@fluentui/react-focus';
|
|
11
|
-
import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfXAxislabels, formatValueWithSIPrefix, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, findVerticalNumericMinMaxOfY, createNumericYAxis, domainRageOfVerticalNumeric, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfXStringAxis, createStringYAxis, formatDate, getNextGradient, } from '../../utilities/index';
|
|
11
|
+
import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfXAxislabels, formatValueWithSIPrefix, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, findVerticalNumericMinMaxOfY, createNumericYAxis, domainRageOfVerticalNumeric, domainRangeOfDateForAreaLineVerticalBarChart, domainRangeOfXStringAxis, createStringYAxis, formatDate, getNextGradient, areArraysEqual, } from '../../utilities/index';
|
|
12
12
|
var CircleVisbility;
|
|
13
13
|
(function (CircleVisbility) {
|
|
14
14
|
CircleVisbility["show"] = "visibility";
|
|
@@ -19,7 +19,7 @@ var MIN_DOMAIN_MARGIN = 8;
|
|
|
19
19
|
var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
20
20
|
__extends(VerticalBarChartBase, _super);
|
|
21
21
|
function VerticalBarChartBase(props) {
|
|
22
|
-
var _a
|
|
22
|
+
var _a;
|
|
23
23
|
var _this = _super.call(this, props) || this;
|
|
24
24
|
_this._isRtl = getRTL();
|
|
25
25
|
_this._getDomainNRangeValues = function (points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shiftX) {
|
|
@@ -92,12 +92,12 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
92
92
|
dots));
|
|
93
93
|
};
|
|
94
94
|
_this._getCircleVisibilityAndRadius = function (xAxisPoint, legend) {
|
|
95
|
-
var
|
|
96
|
-
if (
|
|
97
|
-
if (xAxisPoint === activeXdataPoint &&
|
|
95
|
+
var activeXdataPoint = _this.state.activeXdataPoint;
|
|
96
|
+
if (!_this._noLegendHighlighted()) {
|
|
97
|
+
if (xAxisPoint === activeXdataPoint && _this._legendHighlighted(legend)) {
|
|
98
98
|
return { visibility: CircleVisbility.show, radius: 8 };
|
|
99
99
|
}
|
|
100
|
-
else if (
|
|
100
|
+
else if (_this._legendHighlighted(legend)) {
|
|
101
101
|
// Don't hide the circle to keep it focusable. For more information,
|
|
102
102
|
// see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
|
|
103
103
|
return { visibility: CircleVisbility.show, radius: 0.3 };
|
|
@@ -170,7 +170,9 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
170
170
|
: _this._createColors()(selectedPoint[0].y)
|
|
171
171
|
: _this._createColors()(1);
|
|
172
172
|
// there might be no y value of the line for the hovered bar. so we need to check this condition
|
|
173
|
-
if (_this._isHavingLine &&
|
|
173
|
+
if (_this._isHavingLine &&
|
|
174
|
+
((_a = selectedPoint[0].lineData) === null || _a === void 0 ? void 0 : _a.y) !== undefined &&
|
|
175
|
+
(_this._legendHighlighted(lineLegendText) || _this._noLegendHighlighted())) {
|
|
174
176
|
// callout data for the line
|
|
175
177
|
YValueHover.push({
|
|
176
178
|
legend: lineLegendText,
|
|
@@ -180,18 +182,20 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
180
182
|
yAxisCalloutData: (_d = selectedPoint[0].lineData) === null || _d === void 0 ? void 0 : _d.yAxisCalloutData,
|
|
181
183
|
});
|
|
182
184
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
?
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
185
|
+
if (_this._legendHighlighted(selectedPoint[0].legend) || _this._noLegendHighlighted()) {
|
|
186
|
+
// callout data for the bar
|
|
187
|
+
YValueHover.push({
|
|
188
|
+
legend: selectedPoint[0].legend,
|
|
189
|
+
y: selectedPoint[0].y,
|
|
190
|
+
color: enableGradient
|
|
191
|
+
? useSingleColor
|
|
192
|
+
? getNextGradient(0, 0)[0]
|
|
193
|
+
: ((_e = selectedPoint[0].gradient) === null || _e === void 0 ? void 0 : _e[0]) || getNextGradient(pointIndex, 0)[0]
|
|
194
|
+
: calloutColor,
|
|
195
|
+
data: selectedPoint[0].yAxisCalloutData,
|
|
196
|
+
yAxisCalloutData: selectedPoint[0].yAxisCalloutData,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
195
199
|
var hoverXValue = point.x instanceof Date ? formatDate(point.x, _this.props.useUTC) : point.x.toString();
|
|
196
200
|
return {
|
|
197
201
|
YValueHover: YValueHover,
|
|
@@ -217,7 +221,7 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
217
221
|
_this.setState({
|
|
218
222
|
refSelected: obj.refElement,
|
|
219
223
|
/** Show the callout if highlighted bar is focused and Hide it if unhighlighted bar is focused */
|
|
220
|
-
isCalloutVisible: _this.
|
|
224
|
+
isCalloutVisible: _this._noLegendHighlighted() || _this._legendHighlighted(point.legend),
|
|
221
225
|
calloutLegend: point.legend,
|
|
222
226
|
dataForHoverCard: point.y,
|
|
223
227
|
color: point.color || color,
|
|
@@ -322,9 +326,6 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
322
326
|
var legend = {
|
|
323
327
|
title: legendTitle,
|
|
324
328
|
color: color,
|
|
325
|
-
action: function () {
|
|
326
|
-
_this._onLegendClick(legendTitle);
|
|
327
|
-
},
|
|
328
329
|
hoverAction: function () {
|
|
329
330
|
_this._handleChartMouseLeave();
|
|
330
331
|
_this._onLegendHover(legendTitle);
|
|
@@ -339,9 +340,6 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
339
340
|
var lineLegend = {
|
|
340
341
|
title: lineLegendText,
|
|
341
342
|
color: lineLegendColor,
|
|
342
|
-
action: function () {
|
|
343
|
-
_this._onLegendClick(lineLegendText);
|
|
344
|
-
},
|
|
345
343
|
hoverAction: function () {
|
|
346
344
|
_this._handleChartMouseLeave();
|
|
347
345
|
_this._onLegendHover(lineLegendText);
|
|
@@ -353,7 +351,7 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
353
351
|
};
|
|
354
352
|
actions.unshift(lineLegend);
|
|
355
353
|
}
|
|
356
|
-
var legends = (React.createElement(Legends, __assign({ legends: actions, enabledWrapLines: _this.props.enabledLegendsWrapLines, overflowProps: _this.props.legendsOverflowProps, focusZonePropsInHoverCard: _this.props.focusZonePropsForLegendsInHoverCard, overflowText: _this.props.legendsOverflowText }, _this.props.legendProps)));
|
|
354
|
+
var legends = (React.createElement(Legends, __assign({ legends: actions, enabledWrapLines: _this.props.enabledLegendsWrapLines, overflowProps: _this.props.legendsOverflowProps, focusZonePropsInHoverCard: _this.props.focusZonePropsForLegendsInHoverCard, overflowText: _this.props.legendsOverflowText }, _this.props.legendProps, { onChange: _this._onLegendSelectionChange.bind(_this) })));
|
|
357
355
|
return legends;
|
|
358
356
|
};
|
|
359
357
|
_this._getAxisData = function (yAxisData) {
|
|
@@ -370,14 +368,13 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
370
368
|
* 2. hovering: if there is no selected legend and the user hovers over it
|
|
371
369
|
*/
|
|
372
370
|
_this._legendHighlighted = function (legendTitle) {
|
|
373
|
-
return
|
|
374
|
-
(_this.state.selectedLegend === '' && _this.state.activeLegend === legendTitle));
|
|
371
|
+
return _this._getHighlightedLegend().includes(legendTitle);
|
|
375
372
|
};
|
|
376
373
|
/**
|
|
377
374
|
* This function checks if none of the legends is selected or hovered.
|
|
378
375
|
*/
|
|
379
376
|
_this._noLegendHighlighted = function () {
|
|
380
|
-
return _this.
|
|
377
|
+
return _this._getHighlightedLegend().length === 0;
|
|
381
378
|
};
|
|
382
379
|
_this._getAriaLabel = function (point) {
|
|
383
380
|
var _a, _b, _c;
|
|
@@ -441,8 +438,8 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
441
438
|
dataForHoverCard: 0,
|
|
442
439
|
isCalloutVisible: false,
|
|
443
440
|
refSelected: null,
|
|
444
|
-
|
|
445
|
-
activeLegend:
|
|
441
|
+
selectedLegends: ((_a = props.legendProps) === null || _a === void 0 ? void 0 : _a.selectedLegends) || [],
|
|
442
|
+
activeLegend: undefined,
|
|
446
443
|
xCalloutValue: '',
|
|
447
444
|
yCalloutValue: '',
|
|
448
445
|
activeXdataPoint: null,
|
|
@@ -464,10 +461,10 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
464
461
|
return _this;
|
|
465
462
|
}
|
|
466
463
|
VerticalBarChartBase.prototype.componentDidUpdate = function (prevProps) {
|
|
467
|
-
var _a, _b, _c
|
|
468
|
-
if (((_a = prevProps.legendProps) === null || _a === void 0 ? void 0 : _a.
|
|
464
|
+
var _a, _b, _c;
|
|
465
|
+
if (!areArraysEqual((_a = prevProps.legendProps) === null || _a === void 0 ? void 0 : _a.selectedLegends, (_b = this.props.legendProps) === null || _b === void 0 ? void 0 : _b.selectedLegends)) {
|
|
469
466
|
this.setState({
|
|
470
|
-
|
|
467
|
+
selectedLegends: ((_c = this.props.legendProps) === null || _c === void 0 ? void 0 : _c.selectedLegends) || [],
|
|
471
468
|
});
|
|
472
469
|
}
|
|
473
470
|
};
|
|
@@ -490,7 +487,8 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
490
487
|
tickValues: this.props.tickValues,
|
|
491
488
|
tickFormat: this.props.tickFormat,
|
|
492
489
|
};
|
|
493
|
-
return !this._isChartEmpty() ? (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._points, supportNegativeData: this.props.supportNegativeData, chartType: ChartTypes.VerticalBarChart, xAxisType: this._xAxisType, createYAxis: createNumericYAxis, calloutProps: calloutProps, tickParams: tickParams }, (this._isHavingLine &&
|
|
490
|
+
return !this._isChartEmpty() ? (React.createElement(CartesianChart, __assign({}, this.props, { chartTitle: this._getChartTitle(), points: this._points, supportNegativeData: this.props.supportNegativeData, chartType: ChartTypes.VerticalBarChart, xAxisType: this._xAxisType, createYAxis: createNumericYAxis, calloutProps: calloutProps, tickParams: tickParams }, (this._isHavingLine &&
|
|
491
|
+
(this._noLegendHighlighted() || this._getHighlightedLegend().length > 1) && { isCalloutForStack: true }), { legendBars: legendBars, datasetForXAxisDomain: this._xAxisLabels, barwidth: this._barWidth, focusZoneDirection: FocusZoneDirection.horizontal, customizedCallout: this._getCustomizedCallout(), createStringYAxis: createStringYAxis, getmargins: this._getMargins, getMinMaxOfYAxis: findVerticalNumericMinMaxOfY, getGraphData: this._getGraphData, getDomainNRangeValues: this._getDomainNRangeValues, getAxisData: this._getAxisData, onChartMouseLeave: this._handleChartMouseLeave, getDomainMargins: this._getDomainMargins }, (this._xAxisType === XAxisTypes.StringAxis && {
|
|
494
492
|
xAxisInnerPadding: this._xAxisInnerPadding,
|
|
495
493
|
xAxisOuterPadding: this._xAxisOuterPadding,
|
|
496
494
|
}), { ref: this._cartesianChartRef,
|
|
@@ -543,7 +541,7 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
543
541
|
this.setState({
|
|
544
542
|
refSelected: mouseEvent,
|
|
545
543
|
/** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */
|
|
546
|
-
isCalloutVisible: this.
|
|
544
|
+
isCalloutVisible: this._noLegendHighlighted() || this._legendHighlighted(point.legend),
|
|
547
545
|
dataForHoverCard: point.y,
|
|
548
546
|
calloutLegend: point.legend,
|
|
549
547
|
color: point.color || color,
|
|
@@ -553,7 +551,7 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
553
551
|
yCalloutValue: point.yAxisCalloutData,
|
|
554
552
|
dataPointCalloutProps: point,
|
|
555
553
|
// Hovering over a bar should highlight corresponding line points only when no legend is selected
|
|
556
|
-
activeXdataPoint: this._noLegendHighlighted() ? point.x : null,
|
|
554
|
+
activeXdataPoint: this._noLegendHighlighted() || this._legendHighlighted(point.legend) ? point.x : null,
|
|
557
555
|
YValueHover: YValueHover,
|
|
558
556
|
hoverXValue: hoverXValue,
|
|
559
557
|
callOutAccessibilityData: point.callOutAccessibilityData,
|
|
@@ -805,18 +803,6 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
805
803
|
}
|
|
806
804
|
return bars;
|
|
807
805
|
};
|
|
808
|
-
VerticalBarChartBase.prototype._onLegendClick = function (legendTitle) {
|
|
809
|
-
if (this.state.selectedLegend === legendTitle) {
|
|
810
|
-
this.setState({
|
|
811
|
-
selectedLegend: '',
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
else {
|
|
815
|
-
this.setState({
|
|
816
|
-
selectedLegend: legendTitle,
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
806
|
VerticalBarChartBase.prototype._onLegendHover = function (legendTitle) {
|
|
821
807
|
this.setState({
|
|
822
808
|
activeLegend: legendTitle,
|
|
@@ -824,9 +810,28 @@ var VerticalBarChartBase = /** @class */ (function (_super) {
|
|
|
824
810
|
};
|
|
825
811
|
VerticalBarChartBase.prototype._onLegendLeave = function () {
|
|
826
812
|
this.setState({
|
|
827
|
-
activeLegend:
|
|
813
|
+
activeLegend: undefined,
|
|
828
814
|
});
|
|
829
815
|
};
|
|
816
|
+
VerticalBarChartBase.prototype._onLegendSelectionChange = function (selectedLegends, event, currentLegend) {
|
|
817
|
+
var _a, _b;
|
|
818
|
+
if ((_a = this.props.legendProps) === null || _a === void 0 ? void 0 : _a.canSelectMultipleLegends) {
|
|
819
|
+
this.setState({ selectedLegends: selectedLegends });
|
|
820
|
+
}
|
|
821
|
+
else {
|
|
822
|
+
this.setState({ selectedLegends: selectedLegends.slice(-1) });
|
|
823
|
+
}
|
|
824
|
+
if ((_b = this.props.legendProps) === null || _b === void 0 ? void 0 : _b.onChange) {
|
|
825
|
+
this.props.legendProps.onChange(selectedLegends, event, currentLegend);
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
VerticalBarChartBase.prototype._getHighlightedLegend = function () {
|
|
829
|
+
return this.state.selectedLegends.length > 0
|
|
830
|
+
? this.state.selectedLegends
|
|
831
|
+
: this.state.activeLegend
|
|
832
|
+
? [this.state.activeLegend]
|
|
833
|
+
: [];
|
|
834
|
+
};
|
|
830
835
|
VerticalBarChartBase.prototype._renderBarLabel = function (xPoint, yPoint, barValue, legend, isNegativeBar) {
|
|
831
836
|
if (this.props.hideLabels ||
|
|
832
837
|
this._barWidth < 16 ||
|