@fluentui/react-charts 0.0.0-nightly-20250624-0406.1 → 0.0.0-nightly-20250625-0407.1

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["PlotlySchemaAdapter.ts"],"sourcesContent":["/* eslint-disable one-var */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport {\n bin as d3Bin,\n extent as d3Extent,\n sum as d3Sum,\n min as d3Min,\n max as d3Max,\n range as d3Range,\n Bin,\n} from 'd3-array';\nimport { scaleLinear as d3ScaleLinear } from 'd3-scale';\nimport { DonutChartProps } from '../DonutChart/index';\nimport {\n ChartDataPoint,\n ChartProps,\n HorizontalBarChartWithAxisDataPoint,\n LineChartPoints,\n VerticalStackedChartProps,\n HeatMapChartData,\n HeatMapChartDataPoint,\n GroupedVerticalBarChartData,\n VerticalBarChartDataPoint,\n SankeyChartData,\n LineChartLineOptions,\n} from '../../types/DataPoint';\nimport { SankeyChartProps } from '../SankeyChart/index';\nimport { VerticalStackedBarChartProps } from '../VerticalStackedBarChart/index';\nimport { HorizontalBarChartWithAxisProps } from '../HorizontalBarChartWithAxis/index';\nimport { LineChartProps } from '../LineChart/index';\nimport { AreaChartProps } from '../AreaChart/index';\nimport { HeatMapChartProps } from '../HeatMapChart/index';\nimport { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';\nimport { GaugeChartProps, GaugeChartSegment } from '../GaugeChart/index';\nimport { GroupedVerticalBarChartProps } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChartProps } from '../VerticalBarChart/index';\nimport { findNumericMinMaxOfY } from '../../utilities/utilities';\nimport type {\n Datum,\n Layout,\n PlotlySchema,\n PieData,\n PlotData,\n SankeyData,\n ScatterLine,\n TypedArray,\n Data,\n} from '@fluentui/chart-utilities';\nimport {\n isArrayOfType,\n isArrayOrTypedArray,\n isDate,\n isDateArray,\n isNumberArray,\n isYearArray,\n} from '@fluentui/chart-utilities';\nimport { curveCardinal as d3CurveCardinal } from 'd3-shape';\n\ninterface SecondaryYAxisValues {\n secondaryYAxistitle?: string;\n secondaryYScaleOptions?: { yMinValue?: number; yMaxValue?: number };\n}\n\nconst dashOptions = {\n dot: {\n strokeDasharray: '1, 5',\n strokeLinecap: 'round',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n dash: {\n strokeDasharray: '5, 5',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n longdash: {\n strokeDasharray: '10, 5',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n dashdot: {\n strokeDasharray: '5, 5, 1, 5',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n longdashdot: {\n strokeDasharray: '10, 5, 1, 5',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n solid: {\n strokeDasharray: '0',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n} as const;\n\nconst getLegend = (series: Partial<PlotData>, index: number): string => {\n return series.name || `Series ${index + 1}`;\n};\n\nfunction getTitles(layout: Partial<Layout> | undefined) {\n const titles = {\n chartTitle: typeof layout?.title === 'string' ? layout.title : layout?.title?.text ?? '',\n xAxisTitle: typeof layout?.xaxis?.title === 'string' ? layout?.xaxis?.title : layout?.xaxis?.title?.text ?? '',\n yAxisTitle: typeof layout?.yaxis?.title === 'string' ? layout?.yaxis?.title : layout?.yaxis?.title?.text ?? '',\n };\n return titles;\n}\n\nexport const correctYearMonth = (xValues: Datum[] | Datum[][] | TypedArray): any[] => {\n const presentYear = new Date().getFullYear();\n if (xValues.length > 0 && Array.isArray(xValues[0])) {\n throw new Error('updateXValues:: 2D array not supported');\n }\n const dates = (xValues as Datum[]).map(possiblyMonthValue => {\n const parsedDate = `${possiblyMonthValue} 01, ${presentYear}`;\n return isDate(parsedDate) ? new Date(parsedDate) : null;\n });\n for (let i = dates.length - 1; i > 0; i--) {\n const currentMonth = dates[i]!.getMonth();\n const previousMonth = dates[i - 1]!.getMonth();\n const currentYear = dates[i]!.getFullYear();\n const previousYear = dates[i - 1]!.getFullYear();\n if (previousMonth >= currentMonth) {\n dates[i - 1]!.setFullYear(dates[i]!.getFullYear() - 1);\n } else if (previousYear > currentYear) {\n dates[i - 1]!.setFullYear(currentYear);\n }\n }\n xValues = (xValues as Datum[]).map((month, index) => {\n return `${month} 01, ${dates[index]!.getFullYear()}`;\n });\n return xValues;\n};\n\nexport const getColor = (\n legendLabel: string,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string => {\n if (!colorMap.current.has(legendLabel)) {\n const nextColor = getNextColor(colorMap.current.size + 1, 0, isDarkTheme);\n colorMap.current.set(legendLabel, nextColor);\n return nextColor;\n }\n\n return colorMap.current.get(legendLabel) as string;\n};\n\nconst usesSecondaryYScale = (series: Partial<PlotData>): boolean => {\n return series.yaxis === 'y2';\n};\n\nconst getSecondaryYAxisValues = (\n data: Data[],\n layout: Partial<Layout> | undefined,\n maxAllowedMinY?: number,\n minAllowedMaxY?: number,\n): SecondaryYAxisValues => {\n let containsSecondaryYAxis = false;\n let yMinValue: number | undefined;\n let yMaxValue: number | undefined;\n\n data.forEach((series: Partial<PlotData>) => {\n if (usesSecondaryYScale(series)) {\n containsSecondaryYAxis = true;\n const yValues = series.y as number[];\n if (yValues) {\n yMinValue = Math.min(...yValues);\n yMaxValue = Math.max(...yValues);\n }\n }\n });\n\n if (!containsSecondaryYAxis) {\n return {};\n }\n\n if (typeof yMinValue === 'number' && typeof maxAllowedMinY === 'number') {\n yMinValue = Math.min(yMinValue, maxAllowedMinY);\n }\n if (typeof yMaxValue === 'number' && typeof minAllowedMaxY === 'number') {\n yMaxValue = Math.max(yMaxValue, minAllowedMaxY);\n }\n if (layout?.yaxis2?.range) {\n yMinValue = layout.yaxis2.range[0];\n yMaxValue = layout.yaxis2.range[1];\n }\n\n return {\n secondaryYAxistitle:\n typeof layout?.yaxis2?.title === 'string'\n ? layout.yaxis2.title\n : typeof layout?.yaxis2?.title?.text === 'string'\n ? layout.yaxis2.title.text\n : undefined,\n secondaryYScaleOptions: {\n yMinValue,\n yMaxValue,\n },\n };\n};\n\nexport const transformPlotlyJsonToDonutProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): DonutChartProps => {\n const firstData = input.data[0] as PieData;\n\n const mapLegendToDataPoint: Record<string, ChartDataPoint> = {};\n firstData.labels?.forEach((label: string, index: number) => {\n const color = getColor(label, colorMap, isDarkTheme);\n //ToDo how to handle string data?\n const value = typeof firstData.values?.[index] === 'number' ? (firstData.values[index] as number) : 1;\n\n if (!mapLegendToDataPoint[label]) {\n mapLegendToDataPoint[label] = {\n legend: label,\n data: value,\n color,\n };\n } else {\n mapLegendToDataPoint[label].data! += value;\n }\n });\n\n const width: number = input.layout?.width ?? 440;\n const height: number = input.layout?.height ?? 220;\n const hideLabels: boolean = firstData.textinfo\n ? !['value', 'percent', 'label+percent'].includes(firstData.textinfo)\n : false;\n const donutMarginHorizontal: number = hideLabels ? 0 : 80;\n const donutMarginVertical: number = 40 + (hideLabels ? 0 : 40);\n const innerRadius: number = firstData.hole\n ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2)\n : 0;\n const { chartTitle } = getTitles(input.layout);\n\n return {\n data: {\n chartTitle,\n chartData: Object.values(mapLegendToDataPoint),\n },\n hideLegend: input.layout?.showlegend === false ? true : false,\n width: input.layout?.width,\n height,\n innerRadius,\n hideLabels,\n showLabelsInPercent: firstData.textinfo ? ['percent', 'label+percent'].includes(firstData.textinfo) : true,\n };\n};\n\nexport const transformPlotlyJsonToVSBCProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n fallbackVSBC?: boolean,\n): VerticalStackedBarChartProps => {\n const mapXToDataPoints: { [key: string]: VerticalStackedChartProps } = {};\n let yMaxValue = 0;\n const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);\n let yMinValue = 0;\n input.data.forEach((series: PlotData, index1: number) => {\n const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis\n (series.x as Datum[])?.forEach((x: string | number, index2: number) => {\n if (!mapXToDataPoints[x]) {\n mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };\n }\n const legend: string = getLegend(series, index1);\n const yVal: number = (series.y?.[index2] as number) ?? 0;\n if (series.type === 'bar') {\n const color = getColor(legend, colorMap, isDarkTheme);\n mapXToDataPoints[x].chartData.push({\n legend,\n data: yVal,\n color,\n });\n yMaxValue = Math.max(yMaxValue, yVal);\n } else if (series.type === 'scatter' || !!fallbackVSBC) {\n const color = getColor(legend, colorMap, isDarkTheme);\n const lineOptions = getLineOptions(series.line);\n mapXToDataPoints[x].lineData!.push({\n legend,\n y: yVal,\n color,\n ...(lineOptions ? { lineOptions } : {}),\n useSecondaryYScale: usesSecondaryYScale(series),\n });\n if (!usesSecondaryYScale(series)) {\n yMaxValue = Math.max(yMaxValue, yVal);\n }\n }\n\n yMaxValue = Math.max(yMaxValue, yVal);\n yMinValue = Math.min(yMinValue, yVal);\n });\n });\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: Object.values(mapXToDataPoints),\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n barWidth: 'auto',\n yMaxValue,\n yMinValue,\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n mode: 'plotly',\n ...secondaryYAxisValues,\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToGVBCProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): GroupedVerticalBarChartProps => {\n const mapXToDataPoints: Record<string, GroupedVerticalBarChartData> = {};\n const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);\n input.data.forEach((series: PlotData, index1: number) => {\n (series.x as Datum[])?.forEach((x: string | number, index2: number) => {\n if (!mapXToDataPoints[x]) {\n mapXToDataPoints[x] = { name: x.toString(), series: [] };\n }\n if (series.type === 'bar') {\n const legend: string = getLegend(series, index1);\n const color = getColor(legend, colorMap, isDarkTheme);\n\n mapXToDataPoints[x].series.push({\n key: legend,\n data: (series.y?.[index2] as number) ?? 0,\n xAxisCalloutData: x as string,\n color,\n legend,\n useSecondaryYScale: usesSecondaryYScale(series),\n });\n }\n });\n });\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: Object.values(mapXToDataPoints),\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n barWidth: 'auto',\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n mode: 'plotly',\n ...secondaryYAxisValues,\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToVBCProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): VerticalBarChartProps => {\n const vbcData: VerticalBarChartDataPoint[] = [];\n\n input.data.forEach((series: Partial<PlotData>, seriesIdx: number) => {\n if (!series.x) {\n return;\n }\n\n const isXString = isStringArray(series.x);\n const xBins = createBins(series.x, series.xbins?.start, series.xbins?.end, series.xbins?.size);\n const yBins: number[][] = xBins.map(() => []);\n let total = 0;\n\n series.x.forEach((xVal, index) => {\n const binIdx = findBinIndex(xBins, xVal as string | number | null, isXString);\n if (binIdx !== -1) {\n yBins[binIdx].push((series.y?.[index] as number | null | undefined) ?? 1);\n }\n });\n\n const y = yBins.map(bin => {\n const yVal = calculateHistFunc(series.histfunc, bin);\n total += yVal;\n return yVal;\n });\n\n xBins.forEach((bin, index) => {\n const legend: string = getLegend(series, seriesIdx);\n const color: string = getColor(legend, colorMap, isDarkTheme);\n const yVal = calculateHistNorm(\n series.histnorm,\n y[index],\n total,\n isXString ? bin.length : getBinSize(bin as Bin<number, number>),\n );\n\n vbcData.push({\n x: isXString ? bin.join(', ') : getBinCenter(bin as Bin<number, number>),\n y: yVal,\n legend,\n color,\n ...(isXString\n ? {}\n : { xAxisCalloutData: `[${(bin as Bin<number, number>).x0} - ${(bin as Bin<number, number>).x1})` }),\n });\n });\n });\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: vbcData,\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n mode: 'plotly',\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToScatterChartProps = (\n input: PlotlySchema,\n isAreaChart: boolean,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): LineChartProps | AreaChartProps => {\n const secondaryYAxisValues = getSecondaryYAxisValues(\n input.data,\n input.layout,\n isAreaChart ? 0 : undefined,\n isAreaChart ? 0 : undefined,\n );\n let mode: string = 'tonexty';\n const chartData: LineChartPoints[] = input.data.map((series: PlotData, index: number) => {\n const xValues = series.x as Datum[];\n const isString = typeof xValues[0] === 'string';\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const legend: string = getLegend(series, index);\n const lineColor = getColor(legend, colorMap, isDarkTheme);\n mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';\n const lineOptions = getLineOptions(series.line);\n\n return {\n legend,\n data: xValues.map((x, i: number) => ({\n x: isString ? (isXDate ? new Date(x as string) : isXNumber ? parseFloat(x as string) : x) : x,\n y: series.y[i],\n ...(Array.isArray(series.marker?.size)\n ? { markerSize: series.marker.size[i] }\n : typeof series.marker?.size === 'number'\n ? { markerSize: series.marker.size }\n : {}),\n })),\n color: lineColor,\n ...(lineOptions ? { lineOptions } : {}),\n useSecondaryYScale: usesSecondaryYScale(series),\n } as LineChartPoints;\n });\n\n const yMinMaxValues = findNumericMinMaxOfY(chartData);\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n const chartProps: ChartProps = {\n chartTitle,\n lineChartData: chartData,\n };\n\n if (isAreaChart) {\n return {\n data: chartProps,\n supportNegativeData: true,\n xAxisTitle,\n yAxisTitle,\n ...secondaryYAxisValues,\n mode,\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n hideTickOverlap: true,\n useUTC: false,\n } as AreaChartProps;\n } else {\n return {\n data: chartProps,\n supportNegativeData: true,\n xAxisTitle,\n yAxisTitle,\n ...secondaryYAxisValues,\n roundedTicks: true,\n yMinValue: yMinMaxValues.startValue,\n yMaxValue: yMinMaxValues.endValue,\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n hideTickOverlap: true,\n enableReflow: false,\n useUTC: false,\n } as LineChartProps;\n }\n};\n\nexport const transformPlotlyJsonToHorizontalBarWithAxisProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): HorizontalBarChartWithAxisProps => {\n const chartData: HorizontalBarChartWithAxisDataPoint[] = input.data\n .map((series: PlotData, index: number) => {\n return (series.y as Datum[]).map((yValue: string, i: number) => {\n const color = getColor(yValue, colorMap, isDarkTheme);\n return {\n x: series.x[i],\n y: yValue,\n legend: yValue,\n color,\n } as HorizontalBarChartWithAxisDataPoint;\n });\n })\n .flat()\n //reversing the order to invert the Y bars order as required by plotly.\n .reverse();\n\n const chartHeight: number = input.layout?.height ?? 450;\n const margin: number = input.layout?.margin?.l ?? 0;\n const padding: number = input.layout?.margin?.pad ?? 0;\n const availableHeight: number = chartHeight - margin - padding;\n const numberOfBars = input.data.reduce((total: number, item: PlotData) => {\n return total + (item.y?.length || 0);\n }, 0);\n const scalingFactor = 0.01;\n const gapFactor = 1 / (1 + scalingFactor * numberOfBars);\n const barHeight = availableHeight / (numberOfBars * (1 + gapFactor));\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: chartData,\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n secondaryYAxistitle:\n typeof input.layout?.yaxis2?.title === 'string'\n ? input.layout?.yaxis2?.title\n : input.layout?.yaxis2?.title?.text || '',\n barHeight,\n showYAxisLables: true,\n height: chartHeight,\n width: input.layout?.width,\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToHeatmapProps = (input: PlotlySchema): HeatMapChartProps => {\n const firstData = input.data[0] as Partial<PlotData>;\n const heatmapDataPoints: HeatMapChartDataPoint[] = [];\n let zMin = Number.POSITIVE_INFINITY;\n let zMax = Number.NEGATIVE_INFINITY;\n\n if (firstData.type === 'histogram2d') {\n const isXString = isStringArray(firstData.x);\n const isYString = isStringArray(firstData.y);\n const xBins = createBins(firstData.x, firstData.xbins?.start, firstData.xbins?.end, firstData.xbins?.size);\n const yBins = createBins(firstData.y, firstData.ybins?.start, firstData.ybins?.end, firstData.ybins?.size);\n const zBins: number[][][] = yBins.map(() => xBins.map(() => []));\n let total = 0;\n\n firstData.x?.forEach((xVal, index) => {\n const xBinIdx = findBinIndex(xBins, xVal as string | number | null, isXString);\n const yBinIdx = findBinIndex(yBins, firstData.y?.[index] as string | number | null | undefined, isYString);\n\n if (xBinIdx !== -1 && yBinIdx !== -1) {\n zBins[yBinIdx][xBinIdx].push((firstData.z?.[index] as number | null | undefined) ?? 1);\n }\n });\n\n const z = zBins.map(row => {\n return row.map(bin => {\n const zVal = calculateHistFunc(firstData.histfunc, bin);\n total += zVal;\n return zVal;\n });\n });\n\n xBins.forEach((xBin, xIdx) => {\n yBins.forEach((yBin, yIdx) => {\n const zVal = calculateHistNorm(\n firstData.histnorm,\n z[yIdx][xIdx],\n total,\n isXString ? xBin.length : getBinSize(xBin as Bin<number, number>),\n isYString ? yBin.length : getBinSize(yBin as Bin<number, number>),\n );\n\n heatmapDataPoints.push({\n x: isXString ? xBin.join(', ') : getBinCenter(xBin as Bin<number, number>),\n y: isYString ? yBin.join(', ') : getBinCenter(yBin as Bin<number, number>),\n value: zVal,\n rectText: zVal,\n });\n\n if (typeof zVal === 'number') {\n zMin = Math.min(zMin, zVal);\n zMax = Math.max(zMax, zVal);\n }\n });\n });\n } else {\n (firstData.x as Datum[])?.forEach((xVal, xIdx: number) => {\n firstData.y?.forEach((yVal: any, yIdx: number) => {\n const zVal = (firstData.z as number[][])?.[yIdx]?.[xIdx];\n\n heatmapDataPoints.push({\n x: input.layout?.xaxis?.type === 'date' ? (xVal as Date) : xVal ?? 0,\n y: input.layout?.yaxis?.type === 'date' ? (yVal as Date) : yVal,\n value: zVal,\n rectText: zVal,\n });\n\n if (typeof zVal === 'number') {\n zMin = Math.min(zMin, zVal);\n zMax = Math.max(zMax, zVal);\n }\n });\n });\n }\n\n const heatmapData: HeatMapChartData = {\n legend: firstData.name ?? '',\n data: heatmapDataPoints,\n value: 0,\n };\n\n // Initialize domain and range to default values\n const defaultDomain = [zMin, (zMax + zMin) / 2, zMax];\n const defaultRange = [\n getColorFromToken(DataVizPalette.color1),\n getColorFromToken(DataVizPalette.color2),\n getColorFromToken(DataVizPalette.color3),\n ];\n const domainValuesForColorScale: number[] = Array.isArray(firstData.colorscale)\n ? (firstData.colorscale as Array<[number, string]>).map(arr => arr[0] * (zMax - zMin) + zMin)\n : defaultDomain;\n\n const rangeValuesForColorScale: string[] = Array.isArray(firstData.colorscale)\n ? (firstData.colorscale as Array<[number, string]>).map(arr => arr[1])\n : defaultRange;\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: [heatmapData],\n domainValuesForColorScale,\n rangeValuesForColorScale,\n hideLegend: true,\n showYAxisLables: true,\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n sortOrder: 'none',\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToSankeyProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): SankeyChartProps => {\n const { link, node } = input.data[0] as SankeyData;\n const validLinks = (link?.value ?? [])\n .map((val: number, index: number) => ({\n value: val,\n source: link?.source![index],\n target: link?.target![index],\n }))\n // eslint-disable-next-line @typescript-eslint/no-shadow\n // Filter out negative nodes, unequal nodes and self-references (circular links)\n .filter(x => x.source >= 0 && x.target >= 0 && x.source !== x.target);\n\n const sankeyChartData = {\n nodes: node.label?.map((label: string, index: number) => {\n const color = getColor(label, colorMap, isDarkTheme);\n\n return {\n nodeId: index,\n name: label,\n color,\n };\n }),\n links: validLinks.map((validLink: any, index: number) => {\n return {\n ...validLink,\n };\n }),\n } as SankeyChartData;\n\n // const styles: SankeyChartProps['styles'] = {\n // root: {\n // ...(input.layout?.font?.size ? { fontSize: input.layout.font?.size } : {}),\n // },\n // };\n\n const { chartTitle } = getTitles(input.layout);\n\n return {\n data: {\n chartTitle,\n SankeyChartData: sankeyChartData,\n },\n width: input.layout?.width,\n height: input.layout?.height ?? 468,\n // TODO\n // styles,\n enableReflow: true,\n };\n};\n\nexport const transformPlotlyJsonToGaugeProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): GaugeChartProps => {\n const firstData = input.data[0] as PlotData;\n\n const segments = firstData.gauge?.steps?.length\n ? firstData.gauge.steps.map((step: any, index: number): GaugeChartSegment => {\n const legend = step.name || `Segment ${index + 1}`;\n const color = getColor(legend, colorMap, isDarkTheme);\n return {\n legend,\n size: step.range?.[1] - step.range?.[0],\n color,\n };\n })\n : [\n {\n legend: 'Current',\n size: firstData.value ?? 0 - (firstData.gauge?.axis?.range?.[0] ?? 0),\n color: getColor('Current', colorMap, isDarkTheme),\n },\n {\n legend: 'Target',\n size: (firstData.gauge?.axis?.range?.[1] ?? 100) - (firstData.value ?? 0),\n color: DataVizPalette.disabled,\n },\n ];\n\n let sublabel: string | undefined;\n // let sublabelColor: string | undefined;\n if (firstData.delta?.reference) {\n const diff = firstData.value - firstData.delta.reference;\n if (diff >= 0) {\n sublabel = `\\u25B2 ${diff}`;\n // const color = getColorFromToken(DataVizPalette.success, isDarkTheme);\n // sublabelColor = color;\n } else {\n sublabel = `\\u25BC ${Math.abs(diff)}`;\n // const color = getColorFromToken(DataVizPalette.error, isDarkTheme);\n // sublabelColor = color;\n }\n }\n\n // const styles: GaugeChartProps['styles'] = {\n // sublabel: {\n // fill: sublabelColor,\n // },\n // };\n\n const { chartTitle } = getTitles(input.layout);\n\n return {\n segments,\n chartValue: firstData.value ?? 0,\n chartTitle,\n sublabel,\n // range values can be null\n minValue: typeof firstData.gauge?.axis?.range?.[0] === 'number' ? firstData.gauge?.axis?.range?.[0] : undefined,\n maxValue: typeof firstData.gauge?.axis?.range?.[1] === 'number' ? firstData.gauge?.axis?.range?.[1] : undefined,\n chartValueFormat: () => firstData.value?.toString() ?? '',\n // FIXME\n // width: input.layout?.width,\n // height: input.layout?.height ?? 220,\n // TODO\n // styles,\n variant: firstData.gauge?.steps?.length ? 'multiple-segments' : 'single-segment',\n };\n};\n\nfunction isPlainObject(obj: any) {\n return (\n Object.prototype.toString.call(obj) === '[object Object]' &&\n Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty')\n );\n}\n\nvar arrayAttributes: any[] = [];\nvar stack: any[] = [];\nvar isArrayStack: any[] = [];\nvar baseContainer: any, baseAttrName: any;\n/**\n * Interate iteratively through the trace object and find all the array attributes.\n * 1 trace record = 1 series of data\n * @param trace\n */\nexport function findArrayAttributes(trace: any) {\n // Init basecontainer and baseAttrName\n crawlIntoTrace(baseContainer, 0, '');\n}\n\nfunction crawlIntoTrace(container: any, i: number, astrPartial: any) {\n var item = container[stack[i]];\n var newAstrPartial = astrPartial + stack[i];\n if (i === stack.length - 1) {\n if (isArrayOrTypedArray(item)) {\n arrayAttributes.push(baseAttrName + newAstrPartial);\n }\n } else {\n if (isArrayStack[i]) {\n if (Array.isArray(item)) {\n for (var j = 0; j < item.length; j++) {\n if (isPlainObject(item[j])) {\n crawlIntoTrace(item[j], i + 1, newAstrPartial + '[' + j + '].');\n }\n }\n }\n } else if (isPlainObject(item)) {\n crawlIntoTrace(item, i + 1, newAstrPartial + '.');\n }\n }\n}\n\nfunction getLineOptions(line: Partial<ScatterLine> | undefined): LineChartLineOptions | undefined {\n if (!line) {\n return;\n }\n\n let lineOptions: LineChartLineOptions = {};\n if (line.dash) {\n lineOptions = { ...lineOptions, ...dashOptions[line.dash] };\n }\n\n switch (line.shape) {\n case 'spline':\n const smoothing = typeof line.smoothing === 'number' ? line.smoothing : 1;\n lineOptions.curve = d3CurveCardinal.tension(1 - smoothing / 1.3);\n break;\n case 'hv':\n lineOptions.curve = 'stepAfter';\n break;\n case 'vh':\n lineOptions.curve = 'stepBefore';\n break;\n case 'hvh':\n lineOptions.curve = 'step';\n break;\n default:\n lineOptions.curve = 'linear';\n }\n\n return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;\n}\n\nconst isStringArray = (arr: any) => {\n return isArrayOfType(arr, (value: any) => typeof value === 'string');\n};\n\n// TODO: Use binary search to find the appropriate bin for numeric value.\nconst findBinIndex = (\n bins: string[][] | Bin<number, number>[],\n value: string | number | null | undefined,\n isString: boolean,\n) => {\n if (typeof value === 'undefined' || value === null) {\n return -1;\n }\n\n return isString\n ? (bins as string[][]).findIndex(bin => bin.includes(value as string))\n : (bins as Bin<number, number>[]).findIndex(bin => (value as number) >= bin.x0! && (value as number) < bin.x1!);\n};\n\nconst getBinSize = (bin: Bin<number, number>) => {\n return bin.x1! - bin.x0!;\n};\n\nconst getBinCenter = (bin: Bin<number, number>) => {\n return (bin.x1! + bin.x0!) / 2;\n};\n\n// TODO: Add support for date axes\nconst createBins = (\n data: TypedArray | Datum[] | Datum[][] | undefined,\n binStart?: number | string,\n binEnd?: number | string,\n binSize?: number | string,\n) => {\n if (!data || data.length === 0) {\n return [];\n }\n\n if (isStringArray(data)) {\n const categories = Array.from(new Set(data as string[]));\n const start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;\n const stop = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories.length;\n const step = typeof binSize === 'number' ? binSize : 1;\n\n return d3Range(start, stop, step).map(i => categories.slice(i, i + step));\n }\n\n const scale = d3ScaleLinear()\n .domain(d3Extent<number>(data as number[]) as [number, number])\n .nice();\n let [minVal, maxVal] = scale.domain();\n\n minVal = typeof binStart === 'number' ? binStart : minVal;\n maxVal = typeof binEnd === 'number' ? binEnd : maxVal;\n\n const binGenerator = d3Bin().domain([minVal, maxVal]);\n\n if (typeof binSize === 'number') {\n const thresholds: number[] = [];\n let th = minVal;\n const tolerance = 1 / Math.pow(10, binSize.toString().split('.')[1]?.length ?? 0);\n\n while (maxVal + binSize - th > tolerance) {\n thresholds.push(th);\n th += binSize;\n }\n\n minVal = thresholds[0];\n maxVal = thresholds[thresholds.length - 1];\n binGenerator.domain([minVal, maxVal]).thresholds(thresholds);\n }\n\n // NOTE: The last bin generated by d3Bin often has identical x0 and x1 values (both inclusive) and\n // can be ignored if the highest value is already included in the previous bin.\n return binGenerator(data as number[]);\n};\n\nconst calculateHistFunc = (histfunc: PlotData['histfunc'] | undefined, bin: number[]) => {\n switch (histfunc) {\n case 'sum':\n return d3Sum(bin);\n case 'avg':\n return bin.length === 0 ? 0 : d3Sum(bin) / bin.length;\n case 'min':\n return d3Min(bin) ?? 0;\n case 'max':\n return d3Max(bin) ?? 0;\n default:\n return bin.length;\n }\n};\n\nconst calculateHistNorm = (\n histnorm: PlotData['histnorm'] | undefined,\n value: number,\n total: number,\n dx: number,\n dy: number = 1,\n) => {\n switch (histnorm) {\n case 'percent':\n return total === 0 ? 0 : (value / total) * 100;\n case 'probability':\n return total === 0 ? 0 : value / total;\n case 'density':\n return dx * dy === 0 ? 0 : value / (dx * dy);\n case 'probability density':\n return total * dx * dy === 0 ? 0 : value / (total * dx * dy);\n default:\n return value;\n }\n};\n"],"names":["React","bin","d3Bin","extent","d3Extent","sum","d3Sum","min","d3Min","max","d3Max","range","d3Range","scaleLinear","d3ScaleLinear","DataVizPalette","getColorFromToken","getNextColor","findNumericMinMaxOfY","isArrayOfType","isArrayOrTypedArray","isDate","isDateArray","isNumberArray","isYearArray","curveCardinal","d3CurveCardinal","dashOptions","dot","strokeDasharray","strokeLinecap","strokeWidth","lineBorderWidth","dash","longdash","dashdot","longdashdot","solid","getLegend","series","index","name","getTitles","layout","titles","chartTitle","title","text","xAxisTitle","xaxis","yAxisTitle","yaxis","correctYearMonth","xValues","presentYear","Date","getFullYear","length","Array","isArray","Error","dates","map","possiblyMonthValue","parsedDate","i","currentMonth","getMonth","previousMonth","currentYear","previousYear","setFullYear","month","getColor","legendLabel","colorMap","isDarkTheme","current","has","nextColor","size","set","get","usesSecondaryYScale","getSecondaryYAxisValues","data","maxAllowedMinY","minAllowedMaxY","containsSecondaryYAxis","yMinValue","yMaxValue","forEach","yValues","y","Math","yaxis2","secondaryYAxistitle","undefined","secondaryYScaleOptions","transformPlotlyJsonToDonutProps","input","firstData","mapLegendToDataPoint","labels","label","color","value","values","legend","width","height","hideLabels","textinfo","includes","donutMarginHorizontal","donutMarginVertical","innerRadius","hole","chartData","Object","hideLegend","showlegend","showLabelsInPercent","transformPlotlyJsonToVSBCProps","fallbackVSBC","mapXToDataPoints","secondaryYAxisValues","index1","isXYearCategory","x","index2","xAxisPoint","toString","lineData","yVal","type","push","lineOptions","getLineOptions","line","useSecondaryYScale","barWidth","mode","hideTickOverlap","transformPlotlyJsonToGVBCProps","key","xAxisCalloutData","transformPlotlyJsonToVBCProps","vbcData","seriesIdx","isXString","isStringArray","xBins","createBins","xbins","start","end","yBins","total","xVal","binIdx","findBinIndex","calculateHistFunc","histfunc","calculateHistNorm","histnorm","getBinSize","join","getBinCenter","x0","x1","transformPlotlyJsonToScatterChartProps","isAreaChart","isString","isXDate","isXNumber","lineColor","fill","parseFloat","marker","markerSize","yMinMaxValues","chartProps","lineChartData","supportNegativeData","useUTC","roundedTicks","startValue","endValue","enableReflow","transformPlotlyJsonToHorizontalBarWithAxisProps","yValue","flat","reverse","chartHeight","margin","l","padding","pad","availableHeight","numberOfBars","reduce","item","scalingFactor","gapFactor","barHeight","showYAxisLables","transformPlotlyJsonToHeatmapProps","heatmapDataPoints","zMin","Number","POSITIVE_INFINITY","zMax","NEGATIVE_INFINITY","isYString","ybins","zBins","xBinIdx","yBinIdx","z","row","zVal","xBin","xIdx","yBin","yIdx","rectText","heatmapData","defaultDomain","defaultRange","color1","color2","color3","domainValuesForColorScale","colorscale","arr","rangeValuesForColorScale","sortOrder","transformPlotlyJsonToSankeyProps","node","link","validLinks","val","source","target","filter","sankeyChartData","nodes","nodeId","links","validLink","SankeyChartData","transformPlotlyJsonToGaugeProps","segments","gauge","steps","step","axis","disabled","sublabel","delta","reference","diff","abs","chartValue","minValue","maxValue","chartValueFormat","variant","isPlainObject","obj","prototype","call","getPrototypeOf","hasOwnProperty","arrayAttributes","stack","isArrayStack","baseContainer","baseAttrName","findArrayAttributes","trace","crawlIntoTrace","container","astrPartial","newAstrPartial","j","shape","smoothing","curve","tension","keys","bins","findIndex","binStart","binEnd","binSize","categories","from","Set","ceil","stop","floor","slice","scale","domain","nice","minVal","maxVal","binGenerator","thresholds","th","tolerance","pow","split","dx","dy"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACF;AAEA,MAAM2G,oBAAoB,CACxBC,UACA3D,OACAoD,OACA6J,IACAC,KAAa,CAAC;IAEd,OAAQvJ;QACN,KAAK;YACH,OAAOP,UAAU,IAAI,IAAI,AAACpD,QAAQoD,QAAS;QAC7C,KAAK;YACH,OAAOA,UAAU,IAAI,IAAIpD,QAAQoD;QACnC,KAAK;YACH,OAAO6J,KAAKC,OAAO,IAAI,IAAIlN,QAASiN,CAAAA,KAAKC,EAAC;QAC5C,KAAK;YACH,OAAO9J,QAAQ6J,KAAKC,OAAO,IAAI,IAAIlN,QAASoD,CAAAA,QAAQ6J,KAAKC,EAAC;QAC5D;YACE,OAAOlN;IACX;AACF"}
1
+ {"version":3,"sources":["PlotlySchemaAdapter.ts"],"sourcesContent":["/* eslint-disable one-var */\n/* eslint-disable vars-on-top */\n/* eslint-disable no-var */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport {\n bin as d3Bin,\n extent as d3Extent,\n sum as d3Sum,\n min as d3Min,\n max as d3Max,\n range as d3Range,\n Bin,\n} from 'd3-array';\nimport { scaleLinear as d3ScaleLinear } from 'd3-scale';\nimport { DonutChartProps } from '../DonutChart/index';\nimport {\n ChartDataPoint,\n ChartProps,\n HorizontalBarChartWithAxisDataPoint,\n LineChartPoints,\n VerticalStackedChartProps,\n HeatMapChartData,\n HeatMapChartDataPoint,\n GroupedVerticalBarChartData,\n VerticalBarChartDataPoint,\n SankeyChartData,\n LineChartLineOptions,\n} from '../../types/DataPoint';\nimport { SankeyChartProps } from '../SankeyChart/index';\nimport { VerticalStackedBarChartProps } from '../VerticalStackedBarChart/index';\nimport { HorizontalBarChartWithAxisProps } from '../HorizontalBarChartWithAxis/index';\nimport { LineChartProps } from '../LineChart/index';\nimport { AreaChartProps } from '../AreaChart/index';\nimport { HeatMapChartProps } from '../HeatMapChart/index';\nimport { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';\nimport { GaugeChartProps, GaugeChartSegment } from '../GaugeChart/index';\nimport { GroupedVerticalBarChartProps } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChartProps } from '../VerticalBarChart/index';\nimport { findNumericMinMaxOfY } from '../../utilities/utilities';\nimport type {\n Datum,\n Layout,\n PlotlySchema,\n PieData,\n PlotData,\n SankeyData,\n ScatterLine,\n TypedArray,\n Data,\n} from '@fluentui/chart-utilities';\nimport {\n isArrayOfType,\n isArrayOrTypedArray,\n isDate,\n isDateArray,\n isNumberArray,\n isYearArray,\n} from '@fluentui/chart-utilities';\nimport { curveCardinal as d3CurveCardinal } from 'd3-shape';\n\ninterface SecondaryYAxisValues {\n secondaryYAxistitle?: string;\n secondaryYScaleOptions?: { yMinValue?: number; yMaxValue?: number };\n}\n\nconst dashOptions = {\n dot: {\n strokeDasharray: '1, 5',\n strokeLinecap: 'round',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n dash: {\n strokeDasharray: '5, 5',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n longdash: {\n strokeDasharray: '10, 5',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n dashdot: {\n strokeDasharray: '5, 5, 1, 5',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n longdashdot: {\n strokeDasharray: '10, 5, 1, 5',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n solid: {\n strokeDasharray: '0',\n strokeLinecap: 'butt',\n strokeWidth: '2',\n lineBorderWidth: '4',\n },\n} as const;\n\nconst getLegend = (series: Partial<PlotData>, index: number): string => {\n return series.name || `Series ${index + 1}`;\n};\n\nfunction getTitles(layout: Partial<Layout> | undefined) {\n const titles = {\n chartTitle: typeof layout?.title === 'string' ? layout.title : layout?.title?.text ?? '',\n xAxisTitle: typeof layout?.xaxis?.title === 'string' ? layout?.xaxis?.title : layout?.xaxis?.title?.text ?? '',\n yAxisTitle: typeof layout?.yaxis?.title === 'string' ? layout?.yaxis?.title : layout?.yaxis?.title?.text ?? '',\n };\n return titles;\n}\n\nexport const correctYearMonth = (xValues: Datum[] | Datum[][] | TypedArray): any[] => {\n const presentYear = new Date().getFullYear();\n if (xValues.length > 0 && Array.isArray(xValues[0])) {\n throw new Error('updateXValues:: 2D array not supported');\n }\n const dates = (xValues as Datum[]).map(possiblyMonthValue => {\n const parsedDate = `${possiblyMonthValue} 01, ${presentYear}`;\n return isDate(parsedDate) ? new Date(parsedDate) : null;\n });\n for (let i = dates.length - 1; i > 0; i--) {\n const currentMonth = dates[i]!.getMonth();\n const previousMonth = dates[i - 1]!.getMonth();\n const currentYear = dates[i]!.getFullYear();\n const previousYear = dates[i - 1]!.getFullYear();\n if (previousMonth >= currentMonth) {\n dates[i - 1]!.setFullYear(dates[i]!.getFullYear() - 1);\n } else if (previousYear > currentYear) {\n dates[i - 1]!.setFullYear(currentYear);\n }\n }\n xValues = (xValues as Datum[]).map((month, index) => {\n return `${month} 01, ${dates[index]!.getFullYear()}`;\n });\n return xValues;\n};\n\nexport const getColor = (\n legendLabel: string,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string => {\n if (!colorMap.current.has(legendLabel)) {\n const nextColor = getNextColor(colorMap.current.size + 1, 0, isDarkTheme);\n colorMap.current.set(legendLabel, nextColor);\n return nextColor;\n }\n\n return colorMap.current.get(legendLabel) as string;\n};\n\nconst usesSecondaryYScale = (series: Partial<PlotData>): boolean => {\n return series.yaxis === 'y2';\n};\n\nconst getSecondaryYAxisValues = (\n data: Data[],\n layout: Partial<Layout> | undefined,\n maxAllowedMinY?: number,\n minAllowedMaxY?: number,\n): SecondaryYAxisValues => {\n let containsSecondaryYAxis = false;\n let yMinValue: number | undefined;\n let yMaxValue: number | undefined;\n\n data.forEach((series: Partial<PlotData>) => {\n if (usesSecondaryYScale(series)) {\n containsSecondaryYAxis = true;\n const yValues = series.y as number[];\n if (yValues) {\n yMinValue = Math.min(...yValues);\n yMaxValue = Math.max(...yValues);\n }\n }\n });\n\n if (!containsSecondaryYAxis) {\n return {};\n }\n\n if (typeof yMinValue === 'number' && typeof maxAllowedMinY === 'number') {\n yMinValue = Math.min(yMinValue, maxAllowedMinY);\n }\n if (typeof yMaxValue === 'number' && typeof minAllowedMaxY === 'number') {\n yMaxValue = Math.max(yMaxValue, minAllowedMaxY);\n }\n if (layout?.yaxis2?.range) {\n yMinValue = layout.yaxis2.range[0];\n yMaxValue = layout.yaxis2.range[1];\n }\n\n return {\n secondaryYAxistitle:\n typeof layout?.yaxis2?.title === 'string'\n ? layout.yaxis2.title\n : typeof layout?.yaxis2?.title?.text === 'string'\n ? layout.yaxis2.title.text\n : undefined,\n secondaryYScaleOptions: {\n yMinValue,\n yMaxValue,\n },\n };\n};\n\nexport const transformPlotlyJsonToDonutProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): DonutChartProps => {\n const firstData = input.data[0] as PieData;\n\n const mapLegendToDataPoint: Record<string, ChartDataPoint> = {};\n firstData.labels?.forEach((label: string, index: number) => {\n const color = getColor(label, colorMap, isDarkTheme);\n //ToDo how to handle string data?\n const value = typeof firstData.values?.[index] === 'number' ? (firstData.values[index] as number) : 1;\n\n if (!mapLegendToDataPoint[label]) {\n mapLegendToDataPoint[label] = {\n legend: label,\n data: value,\n color,\n };\n } else {\n mapLegendToDataPoint[label].data! += value;\n }\n });\n\n const width: number = input.layout?.width ?? 440;\n const height: number = input.layout?.height ?? 220;\n const hideLabels: boolean = firstData.textinfo\n ? !['value', 'percent', 'label+percent'].includes(firstData.textinfo)\n : false;\n const donutMarginHorizontal: number = hideLabels ? 0 : 80;\n const donutMarginVertical: number = 40 + (hideLabels ? 0 : 40);\n const innerRadius: number = firstData.hole\n ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2)\n : 0;\n const { chartTitle } = getTitles(input.layout);\n\n return {\n data: {\n chartTitle,\n chartData: Object.values(mapLegendToDataPoint),\n },\n hideLegend: input.layout?.showlegend === false ? true : false,\n width: input.layout?.width,\n height,\n innerRadius,\n hideLabels,\n showLabelsInPercent: firstData.textinfo ? ['percent', 'label+percent'].includes(firstData.textinfo) : true,\n };\n};\n\nexport const transformPlotlyJsonToVSBCProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n fallbackVSBC?: boolean,\n): VerticalStackedBarChartProps => {\n const mapXToDataPoints: { [key: string]: VerticalStackedChartProps } = {};\n let yMaxValue = 0;\n const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);\n let yMinValue = 0;\n input.data.forEach((series: PlotData, index1: number) => {\n const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis\n (series.x as Datum[])?.forEach((x: string | number, index2: number) => {\n if (!mapXToDataPoints[x]) {\n mapXToDataPoints[x] = { xAxisPoint: isXYearCategory ? x.toString() : x, chartData: [], lineData: [] };\n }\n const legend: string = getLegend(series, index1);\n const yVal: number = (series.y?.[index2] as number) ?? 0;\n if (series.type === 'bar') {\n const color = getColor(legend, colorMap, isDarkTheme);\n mapXToDataPoints[x].chartData.push({\n legend,\n data: yVal,\n color,\n });\n yMaxValue = Math.max(yMaxValue, yVal);\n } else if (series.type === 'scatter' || !!fallbackVSBC) {\n const color = getColor(legend, colorMap, isDarkTheme);\n const lineOptions = getLineOptions(series.line);\n mapXToDataPoints[x].lineData!.push({\n legend,\n y: yVal,\n color,\n ...(lineOptions ? { lineOptions } : {}),\n useSecondaryYScale: usesSecondaryYScale(series),\n });\n if (!usesSecondaryYScale(series)) {\n yMaxValue = Math.max(yMaxValue, yVal);\n }\n }\n\n yMaxValue = Math.max(yMaxValue, yVal);\n yMinValue = Math.min(yMinValue, yVal);\n });\n });\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: Object.values(mapXToDataPoints),\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n barWidth: 'auto',\n yMaxValue,\n yMinValue,\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n mode: 'plotly',\n ...secondaryYAxisValues,\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToGVBCProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): GroupedVerticalBarChartProps => {\n const mapXToDataPoints: Record<string, GroupedVerticalBarChartData> = {};\n const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);\n input.data.forEach((series: PlotData, index1: number) => {\n (series.x as Datum[])?.forEach((x: string | number, index2: number) => {\n if (!mapXToDataPoints[x]) {\n mapXToDataPoints[x] = { name: x.toString(), series: [] };\n }\n if (series.type === 'bar') {\n const legend: string = getLegend(series, index1);\n const color = getColor(legend, colorMap, isDarkTheme);\n\n mapXToDataPoints[x].series.push({\n key: legend,\n data: (series.y?.[index2] as number) ?? 0,\n xAxisCalloutData: x as string,\n color,\n legend,\n useSecondaryYScale: usesSecondaryYScale(series),\n });\n }\n });\n });\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: Object.values(mapXToDataPoints),\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n barWidth: 'auto',\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n mode: 'plotly',\n ...secondaryYAxisValues,\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToVBCProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): VerticalBarChartProps => {\n const vbcData: VerticalBarChartDataPoint[] = [];\n\n input.data.forEach((series: Partial<PlotData>, seriesIdx: number) => {\n if (!series.x) {\n return;\n }\n\n const isXString = isStringArray(series.x);\n const xBins = createBins(series.x, series.xbins?.start, series.xbins?.end, series.xbins?.size);\n const yBins: number[][] = xBins.map(() => []);\n let total = 0;\n\n series.x.forEach((xVal, index) => {\n const binIdx = findBinIndex(xBins, xVal as string | number | null, isXString);\n if (binIdx !== -1) {\n yBins[binIdx].push((series.y?.[index] as number | null | undefined) ?? 1);\n }\n });\n\n const y = yBins.map(bin => {\n const yVal = calculateHistFunc(series.histfunc, bin);\n total += yVal;\n return yVal;\n });\n\n xBins.forEach((bin, index) => {\n const legend: string = getLegend(series, seriesIdx);\n const color: string = getColor(legend, colorMap, isDarkTheme);\n const yVal = calculateHistNorm(\n series.histnorm,\n y[index],\n total,\n isXString ? bin.length : getBinSize(bin as Bin<number, number>),\n );\n\n vbcData.push({\n x: isXString ? bin.join(', ') : getBinCenter(bin as Bin<number, number>),\n y: yVal,\n legend,\n color,\n ...(isXString\n ? {}\n : { xAxisCalloutData: `[${(bin as Bin<number, number>).x0} - ${(bin as Bin<number, number>).x1})` }),\n });\n });\n });\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: vbcData,\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n mode: 'plotly',\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToScatterChartProps = (\n input: PlotlySchema,\n isAreaChart: boolean,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): LineChartProps | AreaChartProps => {\n const secondaryYAxisValues = getSecondaryYAxisValues(\n input.data,\n input.layout,\n isAreaChart ? 0 : undefined,\n isAreaChart ? 0 : undefined,\n );\n let mode: string = 'tonexty';\n const chartData: LineChartPoints[] = input.data.map((series: PlotData, index: number) => {\n const xValues = series.x as Datum[];\n const isString = typeof xValues[0] === 'string';\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const legend: string = getLegend(series, index);\n const lineColor = getColor(legend, colorMap, isDarkTheme);\n mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';\n const lineOptions = getLineOptions(series.line);\n\n return {\n legend,\n data: xValues.map((x, i: number) => ({\n x: isString ? (isXDate ? new Date(x as string) : isXNumber ? parseFloat(x as string) : x) : x,\n y: series.y[i],\n ...(Array.isArray(series.marker?.size)\n ? { markerSize: series.marker.size[i] }\n : typeof series.marker?.size === 'number'\n ? { markerSize: series.marker.size }\n : {}),\n })),\n color: lineColor,\n ...(lineOptions ? { lineOptions } : {}),\n useSecondaryYScale: usesSecondaryYScale(series),\n } as LineChartPoints;\n });\n\n const yMinMaxValues = findNumericMinMaxOfY(chartData);\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n const chartProps: ChartProps = {\n chartTitle,\n lineChartData: chartData,\n };\n\n if (isAreaChart) {\n return {\n data: chartProps,\n supportNegativeData: true,\n xAxisTitle,\n yAxisTitle,\n ...secondaryYAxisValues,\n mode,\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n hideTickOverlap: true,\n useUTC: false,\n } as AreaChartProps;\n } else {\n return {\n data: chartProps,\n supportNegativeData: true,\n xAxisTitle,\n yAxisTitle,\n ...secondaryYAxisValues,\n roundedTicks: true,\n yMinValue: yMinMaxValues.startValue,\n yMaxValue: yMinMaxValues.endValue,\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n hideTickOverlap: true,\n enableReflow: false,\n useUTC: false,\n } as LineChartProps;\n }\n};\n\nexport const transformPlotlyJsonToHorizontalBarWithAxisProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): HorizontalBarChartWithAxisProps => {\n const chartData: HorizontalBarChartWithAxisDataPoint[] = input.data\n .map((series: PlotData, index: number) => {\n return (series.y as Datum[]).map((yValue: string, i: number) => {\n const legendName = series.name ?? yValue;\n const color = getColor(legendName, colorMap, isDarkTheme);\n return {\n x: series.x[i],\n y: yValue,\n legend: legendName,\n color,\n } as HorizontalBarChartWithAxisDataPoint;\n });\n })\n .flat()\n //reversing the order to invert the Y bars order as required by plotly.\n .reverse();\n\n const chartHeight: number = input.layout?.height ?? 450;\n const margin: number = input.layout?.margin?.l ?? 0;\n const padding: number = input.layout?.margin?.pad ?? 0;\n const availableHeight: number = chartHeight - margin - padding;\n const numberOfBars = input.data.reduce((total: number, item: PlotData) => {\n return total + (item.y?.length || 0);\n }, 0);\n const scalingFactor = 0.01;\n const gapFactor = 1 / (1 + scalingFactor * numberOfBars);\n const barHeight = availableHeight / (numberOfBars * (1 + gapFactor));\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: chartData,\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n secondaryYAxistitle:\n typeof input.layout?.yaxis2?.title === 'string'\n ? input.layout?.yaxis2?.title\n : input.layout?.yaxis2?.title?.text || '',\n barHeight,\n showYAxisLables: true,\n height: chartHeight,\n width: input.layout?.width,\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToHeatmapProps = (input: PlotlySchema): HeatMapChartProps => {\n const firstData = input.data[0] as Partial<PlotData>;\n const heatmapDataPoints: HeatMapChartDataPoint[] = [];\n let zMin = Number.POSITIVE_INFINITY;\n let zMax = Number.NEGATIVE_INFINITY;\n\n if (firstData.type === 'histogram2d') {\n const isXString = isStringArray(firstData.x);\n const isYString = isStringArray(firstData.y);\n const xBins = createBins(firstData.x, firstData.xbins?.start, firstData.xbins?.end, firstData.xbins?.size);\n const yBins = createBins(firstData.y, firstData.ybins?.start, firstData.ybins?.end, firstData.ybins?.size);\n const zBins: number[][][] = yBins.map(() => xBins.map(() => []));\n let total = 0;\n\n firstData.x?.forEach((xVal, index) => {\n const xBinIdx = findBinIndex(xBins, xVal as string | number | null, isXString);\n const yBinIdx = findBinIndex(yBins, firstData.y?.[index] as string | number | null | undefined, isYString);\n\n if (xBinIdx !== -1 && yBinIdx !== -1) {\n zBins[yBinIdx][xBinIdx].push((firstData.z?.[index] as number | null | undefined) ?? 1);\n }\n });\n\n const z = zBins.map(row => {\n return row.map(bin => {\n const zVal = calculateHistFunc(firstData.histfunc, bin);\n total += zVal;\n return zVal;\n });\n });\n\n xBins.forEach((xBin, xIdx) => {\n yBins.forEach((yBin, yIdx) => {\n const zVal = calculateHistNorm(\n firstData.histnorm,\n z[yIdx][xIdx],\n total,\n isXString ? xBin.length : getBinSize(xBin as Bin<number, number>),\n isYString ? yBin.length : getBinSize(yBin as Bin<number, number>),\n );\n\n heatmapDataPoints.push({\n x: isXString ? xBin.join(', ') : getBinCenter(xBin as Bin<number, number>),\n y: isYString ? yBin.join(', ') : getBinCenter(yBin as Bin<number, number>),\n value: zVal,\n rectText: zVal,\n });\n\n if (typeof zVal === 'number') {\n zMin = Math.min(zMin, zVal);\n zMax = Math.max(zMax, zVal);\n }\n });\n });\n } else {\n (firstData.x as Datum[])?.forEach((xVal, xIdx: number) => {\n firstData.y?.forEach((yVal: any, yIdx: number) => {\n const zVal = (firstData.z as number[][])?.[yIdx]?.[xIdx];\n\n heatmapDataPoints.push({\n x: input.layout?.xaxis?.type === 'date' ? (xVal as Date) : xVal ?? 0,\n y: input.layout?.yaxis?.type === 'date' ? (yVal as Date) : yVal,\n value: zVal,\n rectText: zVal,\n });\n\n if (typeof zVal === 'number') {\n zMin = Math.min(zMin, zVal);\n zMax = Math.max(zMax, zVal);\n }\n });\n });\n }\n\n const heatmapData: HeatMapChartData = {\n legend: firstData.name ?? '',\n data: heatmapDataPoints,\n value: 0,\n };\n\n // Initialize domain and range to default values\n const defaultDomain = [zMin, (zMax + zMin) / 2, zMax];\n const defaultRange = [\n getColorFromToken(DataVizPalette.color1),\n getColorFromToken(DataVizPalette.color2),\n getColorFromToken(DataVizPalette.color3),\n ];\n const domainValuesForColorScale: number[] = Array.isArray(firstData.colorscale)\n ? (firstData.colorscale as Array<[number, string]>).map(arr => arr[0] * (zMax - zMin) + zMin)\n : defaultDomain;\n\n const rangeValuesForColorScale: string[] = Array.isArray(firstData.colorscale)\n ? (firstData.colorscale as Array<[number, string]>).map(arr => arr[1])\n : defaultRange;\n\n const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);\n\n return {\n data: [heatmapData],\n domainValuesForColorScale,\n rangeValuesForColorScale,\n hideLegend: true,\n showYAxisLables: true,\n chartTitle,\n xAxisTitle,\n yAxisTitle,\n sortOrder: 'none',\n width: input.layout?.width,\n height: input.layout?.height ?? 350,\n hideTickOverlap: true,\n };\n};\n\nexport const transformPlotlyJsonToSankeyProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): SankeyChartProps => {\n const { link, node } = input.data[0] as SankeyData;\n const validLinks = (link?.value ?? [])\n .map((val: number, index: number) => ({\n value: val,\n source: link?.source![index],\n target: link?.target![index],\n }))\n // eslint-disable-next-line @typescript-eslint/no-shadow\n // Filter out negative nodes, unequal nodes and self-references (circular links)\n .filter(x => x.source >= 0 && x.target >= 0 && x.source !== x.target);\n\n const sankeyChartData = {\n nodes: node.label?.map((label: string, index: number) => {\n const color = getColor(label, colorMap, isDarkTheme);\n\n return {\n nodeId: index,\n name: label,\n color,\n };\n }),\n links: validLinks.map((validLink: any, index: number) => {\n return {\n ...validLink,\n };\n }),\n } as SankeyChartData;\n\n // const styles: SankeyChartProps['styles'] = {\n // root: {\n // ...(input.layout?.font?.size ? { fontSize: input.layout.font?.size } : {}),\n // },\n // };\n\n const { chartTitle } = getTitles(input.layout);\n\n return {\n data: {\n chartTitle,\n SankeyChartData: sankeyChartData,\n },\n width: input.layout?.width,\n height: input.layout?.height ?? 468,\n // TODO\n // styles,\n enableReflow: true,\n };\n};\n\nexport const transformPlotlyJsonToGaugeProps = (\n input: PlotlySchema,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): GaugeChartProps => {\n const firstData = input.data[0] as PlotData;\n\n const segments = firstData.gauge?.steps?.length\n ? firstData.gauge.steps.map((step: any, index: number): GaugeChartSegment => {\n const legend = step.name || `Segment ${index + 1}`;\n const color = getColor(legend, colorMap, isDarkTheme);\n return {\n legend,\n size: step.range?.[1] - step.range?.[0],\n color,\n };\n })\n : [\n {\n legend: 'Current',\n size: firstData.value ?? 0 - (firstData.gauge?.axis?.range?.[0] ?? 0),\n color: getColor('Current', colorMap, isDarkTheme),\n },\n {\n legend: 'Target',\n size: (firstData.gauge?.axis?.range?.[1] ?? 100) - (firstData.value ?? 0),\n color: DataVizPalette.disabled,\n },\n ];\n\n let sublabel: string | undefined;\n // let sublabelColor: string | undefined;\n if (firstData.delta?.reference) {\n const diff = firstData.value - firstData.delta.reference;\n if (diff >= 0) {\n sublabel = `\\u25B2 ${diff}`;\n // const color = getColorFromToken(DataVizPalette.success, isDarkTheme);\n // sublabelColor = color;\n } else {\n sublabel = `\\u25BC ${Math.abs(diff)}`;\n // const color = getColorFromToken(DataVizPalette.error, isDarkTheme);\n // sublabelColor = color;\n }\n }\n\n // const styles: GaugeChartProps['styles'] = {\n // sublabel: {\n // fill: sublabelColor,\n // },\n // };\n\n const { chartTitle } = getTitles(input.layout);\n\n return {\n segments,\n chartValue: firstData.value ?? 0,\n chartTitle,\n sublabel,\n // range values can be null\n minValue: typeof firstData.gauge?.axis?.range?.[0] === 'number' ? firstData.gauge?.axis?.range?.[0] : undefined,\n maxValue: typeof firstData.gauge?.axis?.range?.[1] === 'number' ? firstData.gauge?.axis?.range?.[1] : undefined,\n chartValueFormat: () => firstData.value?.toString() ?? '',\n // FIXME\n // width: input.layout?.width,\n // height: input.layout?.height ?? 220,\n // TODO\n // styles,\n variant: firstData.gauge?.steps?.length ? 'multiple-segments' : 'single-segment',\n };\n};\n\nfunction isPlainObject(obj: any) {\n return (\n Object.prototype.toString.call(obj) === '[object Object]' &&\n Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty')\n );\n}\n\nvar arrayAttributes: any[] = [];\nvar stack: any[] = [];\nvar isArrayStack: any[] = [];\nvar baseContainer: any, baseAttrName: any;\n/**\n * Interate iteratively through the trace object and find all the array attributes.\n * 1 trace record = 1 series of data\n * @param trace\n */\nexport function findArrayAttributes(trace: any) {\n // Init basecontainer and baseAttrName\n crawlIntoTrace(baseContainer, 0, '');\n}\n\nfunction crawlIntoTrace(container: any, i: number, astrPartial: any) {\n var item = container[stack[i]];\n var newAstrPartial = astrPartial + stack[i];\n if (i === stack.length - 1) {\n if (isArrayOrTypedArray(item)) {\n arrayAttributes.push(baseAttrName + newAstrPartial);\n }\n } else {\n if (isArrayStack[i]) {\n if (Array.isArray(item)) {\n for (var j = 0; j < item.length; j++) {\n if (isPlainObject(item[j])) {\n crawlIntoTrace(item[j], i + 1, newAstrPartial + '[' + j + '].');\n }\n }\n }\n } else if (isPlainObject(item)) {\n crawlIntoTrace(item, i + 1, newAstrPartial + '.');\n }\n }\n}\n\nfunction getLineOptions(line: Partial<ScatterLine> | undefined): LineChartLineOptions | undefined {\n if (!line) {\n return;\n }\n\n let lineOptions: LineChartLineOptions = {};\n if (line.dash) {\n lineOptions = { ...lineOptions, ...dashOptions[line.dash] };\n }\n\n switch (line.shape) {\n case 'spline':\n const smoothing = typeof line.smoothing === 'number' ? line.smoothing : 1;\n lineOptions.curve = d3CurveCardinal.tension(1 - smoothing / 1.3);\n break;\n case 'hv':\n lineOptions.curve = 'stepAfter';\n break;\n case 'vh':\n lineOptions.curve = 'stepBefore';\n break;\n case 'hvh':\n lineOptions.curve = 'step';\n break;\n default:\n lineOptions.curve = 'linear';\n }\n\n return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;\n}\n\nconst isStringArray = (arr: any) => {\n return isArrayOfType(arr, (value: any) => typeof value === 'string');\n};\n\n// TODO: Use binary search to find the appropriate bin for numeric value.\nconst findBinIndex = (\n bins: string[][] | Bin<number, number>[],\n value: string | number | null | undefined,\n isString: boolean,\n) => {\n if (typeof value === 'undefined' || value === null) {\n return -1;\n }\n\n return isString\n ? (bins as string[][]).findIndex(bin => bin.includes(value as string))\n : (bins as Bin<number, number>[]).findIndex(bin => (value as number) >= bin.x0! && (value as number) < bin.x1!);\n};\n\nconst getBinSize = (bin: Bin<number, number>) => {\n return bin.x1! - bin.x0!;\n};\n\nconst getBinCenter = (bin: Bin<number, number>) => {\n return (bin.x1! + bin.x0!) / 2;\n};\n\n// TODO: Add support for date axes\nconst createBins = (\n data: TypedArray | Datum[] | Datum[][] | undefined,\n binStart?: number | string,\n binEnd?: number | string,\n binSize?: number | string,\n) => {\n if (!data || data.length === 0) {\n return [];\n }\n\n if (isStringArray(data)) {\n const categories = Array.from(new Set(data as string[]));\n const start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;\n const stop = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories.length;\n const step = typeof binSize === 'number' ? binSize : 1;\n\n return d3Range(start, stop, step).map(i => categories.slice(i, i + step));\n }\n\n const scale = d3ScaleLinear()\n .domain(d3Extent<number>(data as number[]) as [number, number])\n .nice();\n let [minVal, maxVal] = scale.domain();\n\n minVal = typeof binStart === 'number' ? binStart : minVal;\n maxVal = typeof binEnd === 'number' ? binEnd : maxVal;\n\n const binGenerator = d3Bin().domain([minVal, maxVal]);\n\n if (typeof binSize === 'number') {\n const thresholds: number[] = [];\n let th = minVal;\n const tolerance = 1 / Math.pow(10, binSize.toString().split('.')[1]?.length ?? 0);\n\n while (maxVal + binSize - th > tolerance) {\n thresholds.push(th);\n th += binSize;\n }\n\n minVal = thresholds[0];\n maxVal = thresholds[thresholds.length - 1];\n binGenerator.domain([minVal, maxVal]).thresholds(thresholds);\n }\n\n // NOTE: The last bin generated by d3Bin often has identical x0 and x1 values (both inclusive) and\n // can be ignored if the highest value is already included in the previous bin.\n return binGenerator(data as number[]);\n};\n\nconst calculateHistFunc = (histfunc: PlotData['histfunc'] | undefined, bin: number[]) => {\n switch (histfunc) {\n case 'sum':\n return d3Sum(bin);\n case 'avg':\n return bin.length === 0 ? 0 : d3Sum(bin) / bin.length;\n case 'min':\n return d3Min(bin) ?? 0;\n case 'max':\n return d3Max(bin) ?? 0;\n default:\n return bin.length;\n }\n};\n\nconst calculateHistNorm = (\n histnorm: PlotData['histnorm'] | undefined,\n value: number,\n total: number,\n dx: number,\n dy: number = 1,\n) => {\n switch (histnorm) {\n case 'percent':\n return total === 0 ? 0 : (value / total) * 100;\n case 'probability':\n return total === 0 ? 0 : value / total;\n case 'density':\n return dx * dy === 0 ? 0 : value / (dx * dy);\n case 'probability density':\n return total * dx * dy === 0 ? 0 : value / (total * dx * dy);\n default:\n return value;\n }\n};\n"],"names":["React","bin","d3Bin","extent","d3Extent","sum","d3Sum","min","d3Min","max","d3Max","range","d3Range","scaleLinear","d3ScaleLinear","DataVizPalette","getColorFromToken","getNextColor","findNumericMinMaxOfY","isArrayOfType","isArrayOrTypedArray","isDate","isDateArray","isNumberArray","isYearArray","curveCardinal","d3CurveCardinal","dashOptions","dot","strokeDasharray","strokeLinecap","strokeWidth","lineBorderWidth","dash","longdash","dashdot","longdashdot","solid","getLegend","series","index","name","getTitles","layout","titles","chartTitle","title","text","xAxisTitle","xaxis","yAxisTitle","yaxis","correctYearMonth","xValues","presentYear","Date","getFullYear","length","Array","isArray","Error","dates","map","possiblyMonthValue","parsedDate","i","currentMonth","getMonth","previousMonth","currentYear","previousYear","setFullYear","month","getColor","legendLabel","colorMap","isDarkTheme","current","has","nextColor","size","set","get","usesSecondaryYScale","getSecondaryYAxisValues","data","maxAllowedMinY","minAllowedMaxY","containsSecondaryYAxis","yMinValue","yMaxValue","forEach","yValues","y","Math","yaxis2","secondaryYAxistitle","undefined","secondaryYScaleOptions","transformPlotlyJsonToDonutProps","input","firstData","mapLegendToDataPoint","labels","label","color","value","values","legend","width","height","hideLabels","textinfo","includes","donutMarginHorizontal","donutMarginVertical","innerRadius","hole","chartData","Object","hideLegend","showlegend","showLabelsInPercent","transformPlotlyJsonToVSBCProps","fallbackVSBC","mapXToDataPoints","secondaryYAxisValues","index1","isXYearCategory","x","index2","xAxisPoint","toString","lineData","yVal","type","push","lineOptions","getLineOptions","line","useSecondaryYScale","barWidth","mode","hideTickOverlap","transformPlotlyJsonToGVBCProps","key","xAxisCalloutData","transformPlotlyJsonToVBCProps","vbcData","seriesIdx","isXString","isStringArray","xBins","createBins","xbins","start","end","yBins","total","xVal","binIdx","findBinIndex","calculateHistFunc","histfunc","calculateHistNorm","histnorm","getBinSize","join","getBinCenter","x0","x1","transformPlotlyJsonToScatterChartProps","isAreaChart","isString","isXDate","isXNumber","lineColor","fill","parseFloat","marker","markerSize","yMinMaxValues","chartProps","lineChartData","supportNegativeData","useUTC","roundedTicks","startValue","endValue","enableReflow","transformPlotlyJsonToHorizontalBarWithAxisProps","yValue","legendName","flat","reverse","chartHeight","margin","l","padding","pad","availableHeight","numberOfBars","reduce","item","scalingFactor","gapFactor","barHeight","showYAxisLables","transformPlotlyJsonToHeatmapProps","heatmapDataPoints","zMin","Number","POSITIVE_INFINITY","zMax","NEGATIVE_INFINITY","isYString","ybins","zBins","xBinIdx","yBinIdx","z","row","zVal","xBin","xIdx","yBin","yIdx","rectText","heatmapData","defaultDomain","defaultRange","color1","color2","color3","domainValuesForColorScale","colorscale","arr","rangeValuesForColorScale","sortOrder","transformPlotlyJsonToSankeyProps","node","link","validLinks","val","source","target","filter","sankeyChartData","nodes","nodeId","links","validLink","SankeyChartData","transformPlotlyJsonToGaugeProps","segments","gauge","steps","step","axis","disabled","sublabel","delta","reference","diff","abs","chartValue","minValue","maxValue","chartValueFormat","variant","isPlainObject","obj","prototype","call","getPrototypeOf","hasOwnProperty","arrayAttributes","stack","isArrayStack","baseContainer","baseAttrName","findArrayAttributes","trace","crawlIntoTrace","container","astrPartial","newAstrPartial","j","shape","smoothing","curve","tension","keys","bins","findIndex","binStart","binEnd","binSize","categories","from","Set","ceil","stop","floor","slice","scale","domain","nice","minVal","maxVal","binGenerator","thresholds","th","tolerance","pow","split","dx","dy"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAEA,MAAM6E,oBAAoB,CAACC,UAA4ClK;IACrE,OAAQkK;QACN,KAAK;YACH,OAAO7J,MAAML;QACf,KAAK;YACH,OAAOA,IAAIwD,MAAM,KAAK,IAAI,IAAInD,MAAML,OAAOA,IAAIwD,MAAM;QACvD,KAAK;gBACIjD;YAAP,OAAOA,CAAAA,SAAAA,MAAMP,kBAANO,oBAAAA,SAAc;QACvB,KAAK;gBACIE;YAAP,OAAOA,CAAAA,SAAAA,MAAMT,kBAANS,oBAAAA,SAAc;QACvB;YACE,OAAOT,IAAIwD,MAAM;IACrB;AACF;AAEA,MAAM2G,oBAAoB,CACxBC,UACA3D,OACAoD,OACA8J,IACAC,KAAa,CAAC;IAEd,OAAQxJ;QACN,KAAK;YACH,OAAOP,UAAU,IAAI,IAAI,AAACpD,QAAQoD,QAAS;QAC7C,KAAK;YACH,OAAOA,UAAU,IAAI,IAAIpD,QAAQoD;QACnC,KAAK;YACH,OAAO8J,KAAKC,OAAO,IAAI,IAAInN,QAASkN,CAAAA,KAAKC,EAAC;QAC5C,KAAK;YACH,OAAO/J,QAAQ8J,KAAKC,OAAO,IAAI,IAAInN,QAASoD,CAAAA,QAAQ8J,KAAKC,EAAC;QAC5D;YACE,OAAOnN;IACX;AACF"}
@@ -7,7 +7,7 @@ import { useId } from '@fluentui/react-utilities';
7
7
  import { useHorizontalBarChartWithAxisStyles } from './useHorizontalBarChartWithAxisStyles.styles';
8
8
  import { CartesianChart } from '../CommonComponents/CartesianChart';
9
9
  import { ChartPopover } from '../CommonComponents/ChartPopover';
10
- import { ChartTypes, getAccessibleDataObject, YAxisType, XAxisTypes, getTypeOfAxis, getNextColor, areArraysEqual, useRtl, DataVizPalette, getColorFromToken } from '../../utilities/index';
10
+ import { ChartTypes, getAccessibleDataObject, YAxisType, XAxisTypes, getTypeOfAxis, getNextColor, areArraysEqual, useRtl, DataVizPalette, getColorFromToken, computeLongestBars, domainRangeOfNumericForHorizontalBarChartWithAxis, groupChartDataByYValue } from '../../utilities/index';
11
11
  export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
12
12
  var _props_legendProps, _props_legendProps1, _props_legendProps2, _props_legendProps3;
13
13
  const _refArray = [];
@@ -27,7 +27,10 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
27
27
  let _calloutAnchorPoint;
28
28
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
29
  let tooltipElement;
30
+ let _longestBarPositiveTotalValue;
31
+ let _longestBarNegativeTotalValue;
30
32
  const cartesianChartRef = React.useRef(null);
33
+ const X_ORIGIN = 0;
31
34
  const [color, setColor] = React.useState('');
32
35
  const [dataForHoverCard, setDataForHoverCard] = React.useState(0);
33
36
  const [isLegendSelected, setIsLegendSelected] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) && props.legendProps.selectedLegends.length > 0 || ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegend) !== undefined);
@@ -116,7 +119,13 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
116
119
  return props.onRenderCalloutPerDataPoint ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps, _renderCallout) : null;
117
120
  }
118
121
  function _getGraphData(xScale, yScale, containerHeight, containerWidth, xElement, yElement) {
119
- return _bars = _yAxisType === YAxisType.NumericAxis ? _createNumericBars(containerHeight, containerWidth, xElement, yElement) : _createStringBars(containerHeight, containerWidth, xElement, yElement);
122
+ const stackedChartData = groupChartDataByYValue(_points);
123
+ const longestBars = computeLongestBars(stackedChartData, X_ORIGIN);
124
+ _longestBarPositiveTotalValue = longestBars.longestPositiveBar;
125
+ _longestBarNegativeTotalValue = longestBars.longestNegativeBar;
126
+ const { xBarScale, yBarScale } = _yAxisType === YAxisType.NumericAxis ? _getScales(containerHeight, containerWidth, true) : _getScales(containerHeight, containerWidth, false);
127
+ const allBars = stackedChartData.map((singleBarData)=>_yAxisType === YAxisType.NumericAxis ? _createNumericBars(containerHeight, containerWidth, xElement, yElement, singleBarData, xBarScale, yBarScale) : _createStringBars(containerHeight, containerWidth, xElement, yElement, singleBarData, xBarScale, yBarScale)).flat();
128
+ return _bars = allBars;
120
129
  }
121
130
  function _createColors() {
122
131
  const increment = _colors.length <= 1 ? 1 : 1 / (_colors.length - 1);
@@ -184,16 +193,15 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
184
193
  }
185
194
  }
186
195
  function _getScales(containerHeight, containerWidth, isNumericScale) {
196
+ const xMax = _longestBarPositiveTotalValue;
197
+ const xMin = _longestBarNegativeTotalValue;
198
+ const xDomain = [
199
+ Math.min(X_ORIGIN, xMin),
200
+ Math.max(X_ORIGIN, xMax)
201
+ ];
187
202
  if (isNumericScale) {
188
- const xMax = d3Max(_points, (point)=>point.x);
189
203
  const yMax = d3Max(_points, (point)=>point.y);
190
- const xBarScale = d3ScaleLinear().domain(_isRtl ? [
191
- xMax,
192
- 0
193
- ] : [
194
- 0,
195
- xMax
196
- ]).nice().range([
204
+ const xBarScale = d3ScaleLinear().domain(xDomain).nice().range([
197
205
  _margins.left,
198
206
  containerWidth - _margins.right
199
207
  ]);
@@ -209,7 +217,6 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
209
217
  yBarScale
210
218
  };
211
219
  } else {
212
- const xMax = d3Max(_points, (point)=>point.x);
213
220
  // please note these padding default values must be consistent in here
214
221
  // and CatrtesianChartBase w for more details refer example
215
222
  // http://using-d3js.com/04_07_ordinal_scales.html
@@ -217,13 +224,7 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
217
224
  containerHeight - _margins.bottom - _barHeight / 2,
218
225
  _margins.top + _barHeight / 2
219
226
  ]).padding(props.yAxisPadding || 0);
220
- const xBarScale = d3ScaleLinear().domain(_isRtl ? [
221
- xMax,
222
- 0
223
- ] : [
224
- 0,
225
- xMax
226
- ]).nice().range([
227
+ const xBarScale = d3ScaleLinear().domain(xDomain).nice().range([
227
228
  _margins.left,
228
229
  containerWidth - _margins.right
229
230
  ]);
@@ -233,22 +234,37 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
233
234
  };
234
235
  }
235
236
  }
236
- function _createNumericBars(containerHeight, containerWidth, xElement, yElement) {
237
+ function _createNumericBars(containerHeight, containerWidth, xElement, yElement, singleBarData, // eslint-disable-next-line @typescript-eslint/no-explicit-any
238
+ xBarScale, // eslint-disable-next-line @typescript-eslint/no-explicit-any
239
+ yBarScale) {
237
240
  const { useSingleColor = false } = props;
238
- const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth, true);
239
241
  const sortedBars = [
240
- ..._points
242
+ ...singleBarData
241
243
  ];
242
244
  sortedBars.sort((a, b)=>{
243
245
  const aValue = typeof a.y === 'number' ? a.y : parseFloat(a.y);
244
246
  const bValue = typeof b.y === 'number' ? b.y : parseFloat(b.y);
245
247
  return bValue - aValue;
246
248
  });
249
+ let prevWidthPositive = 0;
250
+ let prevWidthNegative = 0;
251
+ let prevPoint = 0;
252
+ const totalPositiveBars = singleBarData.filter((point)=>point.x >= X_ORIGIN).length;
253
+ const totalNegativeBars = singleBarData.length - totalPositiveBars;
254
+ let currPositiveCounter = 0;
255
+ let currNegativeCounter = 0;
247
256
  const bars = sortedBars.map((point, index)=>{
248
257
  let shouldHighlight = true;
249
258
  if (isLegendHovered || isLegendSelected) {
250
259
  shouldHighlight = _isLegendHighlighted(point.legend);
251
260
  }
261
+ if (point.x >= X_ORIGIN) {
262
+ ++currPositiveCounter;
263
+ }
264
+ if (point.x < X_ORIGIN) {
265
+ ++currNegativeCounter;
266
+ }
267
+ const barStartX = _isRtl ? containerWidth - (_margins.right + Math.max(xBarScale(point.x + X_ORIGIN), xBarScale(X_ORIGIN)) - _margins.left) : Math.min(xBarScale(point.x + X_ORIGIN), xBarScale(X_ORIGIN));
252
268
  const barHeight = Math.max(yBarScale(point.y), 0);
253
269
  if (barHeight < 1) {
254
270
  return /*#__PURE__*/ React.createElement(React.Fragment, {
@@ -264,14 +280,26 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
264
280
  startColor = props.colors ? _createColors()(point.x) : getNextColor(index, 0);
265
281
  }
266
282
  startColor = point.color && !useSingleColor ? point.color : startColor;
283
+ const prevBarWidth = Math.abs(xBarScale(prevPoint + X_ORIGIN) - xBarScale(X_ORIGIN));
284
+ prevPoint > X_ORIGIN ? prevWidthPositive += prevBarWidth : prevWidthNegative += prevBarWidth;
285
+ const currentWidth = Math.abs(xBarScale(point.x + X_ORIGIN) - xBarScale(X_ORIGIN));
286
+ const gapWidthLTR = currentWidth > 2 && (point.x > X_ORIGIN && currPositiveCounter !== totalPositiveBars || point.x < X_ORIGIN && (totalPositiveBars !== 0 || currNegativeCounter > 1)) ? 2 : 0;
287
+ const gapWidthRTL = currentWidth > 2 && (point.x > X_ORIGIN && (totalNegativeBars !== 0 || currPositiveCounter > 1) || point.x < X_ORIGIN && currNegativeCounter !== totalNegativeBars) ? 2 : 0;
288
+ let xStart = X_ORIGIN;
289
+ if (_isRtl) {
290
+ xStart = point.x > X_ORIGIN ? barStartX - prevWidthPositive : barStartX + prevWidthNegative;
291
+ } else {
292
+ xStart = point.x > X_ORIGIN ? barStartX + prevWidthPositive : barStartX - prevWidthNegative;
293
+ }
294
+ prevPoint = point.x;
267
295
  return /*#__PURE__*/ React.createElement(React.Fragment, {
268
296
  key: `${index}_${point.x}`
269
297
  }, /*#__PURE__*/ React.createElement("rect", {
270
298
  key: point.y,
271
- x: _isRtl ? xBarScale(point.x) : _margins.left,
299
+ x: xStart,
272
300
  y: yBarScale(point.y) - _barHeight / 2,
273
301
  "data-is-focusable": shouldHighlight,
274
- width: _isRtl ? containerWidth - _margins.right - Math.max(xBarScale(point.x), 0) : Math.max(xBarScale(point.x), 0) - _margins.left,
302
+ width: currentWidth - (_isRtl ? gapWidthRTL : gapWidthLTR),
275
303
  height: _barHeight,
276
304
  ref: (e)=>{
277
305
  _refCallback(e, point.legend);
@@ -321,14 +349,29 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
321
349
  });
322
350
  }
323
351
  }
324
- function _createStringBars(containerHeight, containerWidth, xElement, yElement) {
325
- const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth, false);
352
+ function _createStringBars(containerHeight, containerWidth, xElement, yElement, singleBarData, // eslint-disable-next-line @typescript-eslint/no-explicit-any
353
+ xBarScale, // eslint-disable-next-line @typescript-eslint/no-explicit-any
354
+ yBarScale) {
326
355
  const { useSingleColor = false } = props;
327
- const bars = _points.map((point, index)=>{
356
+ let prevWidthPositive = 0;
357
+ let prevWidthNegative = 0;
358
+ let prevPoint = 0;
359
+ const totalPositiveBars = singleBarData.filter((point)=>point.x >= X_ORIGIN).length;
360
+ const totalNegativeBars = singleBarData.length - totalPositiveBars;
361
+ let currPositiveCounter = 0;
362
+ let currNegativeCounter = 0;
363
+ const bars = singleBarData.map((point, index)=>{
328
364
  let shouldHighlight = true;
329
365
  if (isLegendHovered || isLegendSelected) {
330
366
  shouldHighlight = _isLegendHighlighted(point.legend);
331
367
  }
368
+ if (point.x >= X_ORIGIN) {
369
+ ++currPositiveCounter;
370
+ }
371
+ if (point.x < X_ORIGIN) {
372
+ ++currNegativeCounter;
373
+ }
374
+ const barStartX = _isRtl ? containerWidth - (_margins.right + Math.max(xBarScale(point.x + X_ORIGIN), xBarScale(X_ORIGIN)) - _margins.left) : Math.min(xBarScale(point.x + X_ORIGIN), xBarScale(X_ORIGIN));
332
375
  const barHeight = Math.max(yBarScale(point.y), 0);
333
376
  if (barHeight < 1) {
334
377
  return /*#__PURE__*/ React.createElement(React.Fragment, {
@@ -344,15 +387,27 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
344
387
  startColor = props.colors ? _createColors()(point.x) : getNextColor(index, 0);
345
388
  }
346
389
  startColor = point.color && !useSingleColor ? point.color : startColor;
390
+ const prevBarWidth = Math.abs(xBarScale(prevPoint + X_ORIGIN) - xBarScale(X_ORIGIN));
391
+ prevPoint > 0 ? prevWidthPositive += prevBarWidth : prevWidthNegative += prevBarWidth;
392
+ const currentWidth = Math.abs(xBarScale(point.x + X_ORIGIN) - xBarScale(X_ORIGIN));
393
+ const gapWidthLTR = currentWidth > 2 && (point.x > X_ORIGIN && currPositiveCounter !== totalPositiveBars || point.x < X_ORIGIN && (totalPositiveBars !== 0 || currNegativeCounter > 1)) ? 2 : 0;
394
+ const gapWidthRTL = currentWidth > 2 && (point.x > X_ORIGIN && (totalNegativeBars !== 0 || currPositiveCounter > 1) || point.x < X_ORIGIN && currNegativeCounter !== totalNegativeBars) ? 2 : 0;
395
+ prevPoint = point.x;
396
+ let xStart = X_ORIGIN;
397
+ if (_isRtl) {
398
+ xStart = point.x > X_ORIGIN ? barStartX - prevWidthPositive : barStartX + prevWidthNegative;
399
+ } else {
400
+ xStart = point.x > X_ORIGIN ? barStartX + prevWidthPositive : barStartX - prevWidthNegative;
401
+ }
347
402
  return /*#__PURE__*/ React.createElement(React.Fragment, {
348
403
  key: `${index}_${point.x}`
349
404
  }, /*#__PURE__*/ React.createElement("rect", {
350
405
  transform: `translate(0,${0.5 * (yBarScale.bandwidth() - _barHeight)})`,
351
406
  key: point.x,
352
- x: _isRtl ? xBarScale(point.x) : _margins.left,
407
+ x: xStart,
353
408
  y: yBarScale(point.y),
354
409
  rx: props.roundCorners ? 3 : 0,
355
- width: _isRtl ? containerWidth - _margins.right - Math.max(xBarScale(point.x), 0) : Math.max(xBarScale(point.x), 0) - _margins.left,
410
+ width: currentWidth - (_isRtl ? gapWidthRTL : gapWidthLTR),
356
411
  height: _barHeight,
357
412
  "aria-labelledby": `toolTip${_calloutId}`,
358
413
  "aria-label": _getAriaLabel(point),
@@ -416,16 +471,20 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
416
471
  function _getLegendData(data) {
417
472
  const { useSingleColor } = props;
418
473
  const actions = [];
474
+ const mapLegendToColor = {};
419
475
  data.forEach((point, _index)=>{
420
476
  // eslint-disable-next-line @typescript-eslint/no-shadow
421
477
  const color = useSingleColor ? props.colors ? _createColors()(1) : getNextColor(1, 0) : point.color;
478
+ mapLegendToColor[point.legend] = color;
479
+ });
480
+ Object.entries(mapLegendToColor).forEach(([legendTitle, color])=>{
422
481
  // mapping data to the format Legends component needs
423
482
  const legend = {
424
- title: point.legend,
483
+ title: legendTitle,
425
484
  color,
426
485
  hoverAction: ()=>{
427
486
  _handleChartMouseLeave();
428
- _onLegendHover(point.legend);
487
+ _onLegendHover(legendTitle);
429
488
  },
430
489
  // eslint-disable-next-line @typescript-eslint/no-shadow
431
490
  onMouseOutAction: (isLegendSelected)=>{
@@ -508,6 +567,20 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
508
567
  setPopoverOpen(true);
509
568
  }
510
569
  }
570
+ function _getDomainNRangeValues(points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shiftX) {
571
+ let domainNRangeValue;
572
+ if (xAxisType === XAxisTypes.NumericAxis) {
573
+ domainNRangeValue = domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, width, isRTL, shiftX, X_ORIGIN);
574
+ } else {
575
+ domainNRangeValue = {
576
+ dStartValue: 0,
577
+ dEndValue: 0,
578
+ rStartValue: 0,
579
+ rEndValue: 0
580
+ };
581
+ }
582
+ return domainNRangeValue;
583
+ }
511
584
  if (!_isChartEmpty()) {
512
585
  _adjustProps();
513
586
  const calloutProps = {
@@ -542,6 +615,7 @@ export const HorizontalBarChartWithAxis = /*#__PURE__*/ React.forwardRef((props,
542
615
  chartType: ChartTypes.HorizontalBarChartWithAxis,
543
616
  xAxisType: _xAxisType,
544
617
  yAxisType: _yAxisType,
618
+ getDomainNRangeValues: _getDomainNRangeValues,
545
619
  stringDatasetForYAxisDomain: _yAxisLabels,
546
620
  calloutProps: calloutProps,
547
621
  tickParams: tickParams,