@fluentui/react-charts 0.0.0-nightly-20251209-0407.1 → 0.0.0-nightly-20251211-0406.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.
- package/CHANGELOG.md +13 -13
- package/dist/index.d.ts +26 -6
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +87 -49
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +84 -158
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js +1 -1
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +60 -40
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +6 -2
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/types/ChartAnnotation.js.map +1 -1
- package/lib/utilities/utilities.js +18 -9
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +87 -49
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +84 -158
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +60 -40
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +6 -2
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/types/ChartAnnotation.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +18 -9
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CommonComponents/CartesianChart.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { LegendsProps } from '../Legends/index';\nimport {\n AccessibilityProps,\n Chart,\n Margins,\n DataPoint,\n ChartAnnotation,\n HorizontalBarChartWithAxisDataPoint,\n GroupedVerticalBarChartData,\n HeatMapChartDataPoint,\n LineChartPoints,\n VerticalBarChartDataPoint,\n VerticalStackedBarDataPoint,\n ScatterChartPoints,\n GanttChartDataPoint,\n AxisCategoryOrder,\n AxisProps,\n AxisScaleType,\n} from '../../types/index';\nimport { TimeLocaleDefinition } from 'd3-time-format';\nimport { ChartPopoverProps } from './ChartPopover.types';\nimport { ChartTypes, IAxisData, IDomainNRange, IYAxisParams, XAxisTypes, YAxisType } from '../../utilities/utilities';\nimport { ScaleBand, ScaleLinear } from 'd3-scale';\n/**\n * Cartesian Chart style properties\n * {@docCategory CartesianChart}\n */\nexport interface CartesianChartStyleProps {\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Width of the chart.\n */\n width?: number;\n\n /**\n * Height of the chart.\n */\n height?: number;\n\n /**\n * Color of the chart.\n */\n color?: string;\n\n /**\n * Link to redirect if click action for graph\n */\n href?: string;\n\n /**\n * prop to check if the chart is selected or hovered upon to determine opacity\n */\n shouldHighlight?: boolean;\n\n /**\n * prop to check if the Page is in Rtl\n */\n useRtl?: boolean;\n\n /**\n * color of the line\n */\n lineColor?: string;\n\n /**\n * boolean flag which determines if shape is drawn in callout\n */\n toDrawShape?: boolean;\n\n /**\n * Prop to disable shrinking of the chart beyond a certain limit and enable scrolling when the chart overflows\n * @deprecated Use `reflowProps` instead.\n */\n enableReflow?: boolean;\n}\n\n/**\n * Cartesian Chart styles\n * {@docCategory CartesianChart}\n */\nexport interface CartesianChartStyles {\n /**\n * Style for the root element.\n */\n root?: string;\n\n /**\n * Style for the element containing the x-axis.\n */\n xAxis?: string;\n\n /**\n * Style for the element containing the y-axis.\n */\n yAxis?: string;\n\n /**\n * Style for legend container\n */\n legendContainer?: string;\n\n /**\n * line hover box css\n */\n hover?: string;\n\n /**\n * styles for description message\n */\n descriptionMessage?: string;\n\n /**\n * styles for tooltip\n */\n tooltip?: string;\n\n /**\n * styles for axis title\n */\n axisTitle?: string;\n\n /**\n * styles for axis annotation\n */\n axisAnnotation?: string;\n\n /**\n * Style for the chart Title.\n */\n chartTitle?: string;\n\n /**\n * Style to change the opacity of bars in dataviz when we hover on a single bar or legends\n */\n opacityChangeOnHover?: string;\n\n /**\n * styles for the shape object in the callout\n */\n shapeStyles?: string;\n\n /**\n * Styles for the chart wrapper div\n */\n chartWrapper?: string;\n\n /**\n * Styles for the element wrapping the svg and overlays for annotation\n */\n plotContainer?: string;\n\n /**\n * Styles for the svg tooltip\n */\n svgTooltip?: string;\n\n /**\n * Styles applied to the annotation layer root element\n */\n annotationLayer?: string;\n\n /**\n * Styles for the chart svg element\n */\n chart?: string;\n}\n\n/**\n * Cartesian Chart properties\n * {@docCategory CartesianChart}\n */\nexport interface CartesianChartProps {\n /**\n * Below height used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n height?: number;\n\n /**\n * Below width used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n width?: number;\n\n /**\n * this prop takes its parent as a HTML element to define the width and height of the chart\n */\n parentRef?: HTMLElement | null;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Margins for the chart\n * @default `{ top: 20, bottom: 35, left: 40, right: 20 }`\n * To avoid edge cuttings to the chart, we recommend you use default values or greater then default values\n */\n margins?: Margins;\n\n /** decides wether to show/hide legends\n * @defaultvalue false\n */\n hideLegend?: boolean;\n\n /**\n * Do not show tooltips in chart\n * @default false\n */\n hideTooltip?: boolean;\n\n /**\n * this prop takes values that you want the chart to render on x-axis\n * This is a optional parameter if not specified D3 will decide which values appear on the x-axis for you\n * Please look at https://github.com/d3/d3-scale for more information on how D3 decides what data to appear on the axis of chart\n */\n tickValues?: number[] | Date[] | string[] | undefined;\n\n /**\n * the format for the data on x-axis. For date object this can be specified to your requirement. Eg: '%m/%d', '%d'\n * Please look at https://github.com/d3/d3-time-format for all the formats supported for date axis\n * Only applicable for date axis. For y-axis format use yAxisTickFormat prop.\n */\n tickFormat?: string;\n\n /**\n * Width of line stroke\n */\n strokeWidth?: number;\n\n /**\n * x Axis labels tick padding. This defines the gap between tick labels and tick lines.\n * @default 10\n */\n xAxisTickPadding?: number;\n\n /**\n * the format in for the data on y-axis. For data object this can be specified to your requirement.\n * Eg: d3.format(\".0%\")(0.123),d3.format(\"+20\")(42);\n * Please look at https://github.com/d3/d3-format for all the formats supported\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yAxisTickFormat?: any;\n\n /**\n * Secondary y-scale options\n * By default this is not defined, meaning there will be no secondary y-scale.\n */\n secondaryYScaleOptions?: {\n /** Minimum value (0 by default) */\n yMinValue?: number;\n /** Maximum value (100 by default) */\n yMaxValue?: number;\n };\n\n /**\n * minimum data value point in y-axis\n */\n yMinValue?: number;\n\n /**\n * maximum data value point in y-axis\n */\n yMaxValue?: number;\n\n /**\n * minimum data value point in x-axis (for numeric x-axis)\n */\n xMinValue?: number;\n\n /**\n * maximum data value point in x-axis (for numeric x-axis)\n */\n xMaxValue?: number;\n\n /**\n * Number of ticks on the y-axis.\n * Tick count should be factor of difference between (yMinValue, yMaxValue)?\n * @default 4\n */\n yAxisTickCount?: number;\n\n /**\n * defines the number of ticks on the x-axis. Tries to match the nearest interval satisfying the count.\n * Does not work for string axis.\n * @default 6\n */\n xAxisTickCount?: number;\n\n /**\n * define the size of the tick lines on the x-axis\n * @default 10\n */\n xAxistickSize?: number;\n\n /**\n * Text annotations rendered on top of the chart area\n */\n annotations?: ChartAnnotation[];\n\n /**\n * defines the space between the tick line and the data label\n * @default 10\n */\n tickPadding?: number;\n\n /**\n * Url that the data-viz needs to redirect to upon clicking on it\n */\n href?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n legendsOverflowText?: any;\n\n /**\n * Enable the legends to wrap lines if there is not enough space to show all legends on a single line\n */\n enabledLegendsWrapLines?: boolean;\n\n /*\n * props for the legends in the chart\n */\n legendProps?: Partial<LegendsProps>;\n\n /**\n *@default false\n *Used for to elipse x axis labes and show tooltip on x axis labels\n */\n showXAxisLablesTooltip?: boolean;\n\n /**\n * @default 4\n * Used for X axis labels\n * While Giving showXAxisLablesTooltip prop, need to define after how many chars, we need to truncate the word.\n */\n noOfCharsToTruncate?: number;\n\n /**\n * @default false\n * Used to wrap x axis labels values (whole value)\n */\n wrapXAxisLables?: boolean;\n\n /**\n * @default false\n * Used to rotate x axis labels by 45 degrees\n */\n rotateXAxisLables?: boolean;\n\n /**\n * The prop used to define the date time localization options\n */\n dateLocalizeOptions?: Intl.DateTimeFormatOptions;\n\n /**\n * The prop used to define a custom locale for the date time format.\n */\n timeFormatLocale?: TimeLocaleDefinition;\n\n /**\n * The prop used to define a custom datetime formatter for date axis.\n */\n customDateTimeFormatter?: (dateTime: Date) => string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: CartesianChartStyles;\n\n /**\n * Callout customization props\n */\n calloutProps?: Partial<ChartPopoverProps>;\n\n /**\n * props for the svg; use this to include aria-* or other attributes on the tag\n */\n svgProps?: React.SVGProps<SVGSVGElement>;\n\n /**\n * Prop to disable shrinking of the chart beyond a certain limit and enable scrolling when the chart overflows\n * @deprecated Use `reflowProps` instead.\n */\n enableReflow?: boolean;\n\n /**\n * Props related to reflow behavior of the chart\n */\n reflowProps?: {\n /**\n * Determines the reflow behavior of the chart.\n * When set to `'min-width'`, the chart will not shrink below a certain width and will enable scrolling if it overflows.\n * @default 'none'\n */\n mode: 'none' | 'min-width';\n };\n\n /**\n * Prop to set the x axis title\n * @default undefined\n * Minimum bottom margin required for x axis title is 55px\n */\n\n xAxisTitle?: string;\n\n /**\n * Prop to set the y axis title\n * @default undefined\n * Minimum left margin required for y axis title is 60px and for RTL is 40px\n * Minimum right margin required for y axis title is 40px and for RTL is 60px\n */\n yAxisTitle?: string;\n\n /**\n * Prop to set the secondary y axis title\n * @default undefined\n * If RTL is enabled, minimum left and right margins required for secondary y axis title is 60px\n */\n secondaryYAxistitle?: string;\n\n /**\n * Whether to use UTC time for axis scale, ticks, and the time display in callouts.\n * When set to `true`, time is displayed equally, regardless of the user's timezone settings.\n * @default true\n */\n useUTC?: string | boolean;\n\n /**\n * @default false\n * The prop used to decide rounded ticks on y axis\n */\n roundedTicks?: boolean;\n\n /**\n * Determines whether overlapping x-axis tick labels should be hidden.\n * @default true\n */\n hideTickOverlap?: boolean;\n\n /**\n * Define a custom callout props override\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n calloutPropsPerDataPoint?: (dataPointCalloutProps: any) => ChartPopoverProps;\n\n /**\n * Optional callback to access the Chart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.Ref<Chart>;\n\n /**\n * Prop to set the x axis annotation. Used to display additional information on the x-axis.\n * This is shown on the top of the chart.\n * @default undefined\n */\n xAxisAnnotation?: string;\n\n /**\n * Prop to set the y axis annotation. Used to display additional information on the y-axis.\n * This is shown on the right side of the chart. Not shown if secondary y-axis is enabled.\n * @default undefined\n */\n yAxisAnnotation?: string;\n\n /**\n * Specifies the ordering logic for categories (or string tick labels) on the x-axis.\n * @default 'default'\n */\n xAxisCategoryOrder?: AxisCategoryOrder;\n\n /**\n * Specifies the ordering logic for categories (or string tick labels) on the y-axis.\n * @default 'default'\n */\n yAxisCategoryOrder?: AxisCategoryOrder;\n\n /**\n * Defines the scale type for the x-axis.\n * @default 'default'\n */\n xScaleType?: AxisScaleType;\n\n /**\n * Defines the scale type for the primary y-axis.\n * @default 'default'\n */\n yScaleType?: AxisScaleType;\n\n /**\n * Defines the scale type for the secondary y-axis.\n * @default 'default'\n */\n secondaryYScaleType?: AxisScaleType;\n\n /**\n * Explicit set of tick values for the y-axis.\n * If provided, these values override automatic tick generation.\n */\n yAxisTickValues?: number[] | Date[] | string[];\n\n /**\n * Configuration for the x-axis.\n * Use this to control `tickStep`, `tick0`, etc.\n */\n xAxis?: AxisProps;\n\n /**\n * Configuration for the y-axis.\n * Use this to control `tickStep`, `tick0`, etc.\n */\n yAxis?: AxisProps;\n\n /**\n *@default false\n *Used for showing complete y axis lables */\n showYAxisLables?: boolean;\n\n /**\n *@default false\n *Used for to elipse y axis labes and show tooltip on x axis labels\n */\n showYAxisLablesTooltip?: boolean;\n}\n\nexport interface YValueHover {\n legend?: string;\n y?: number | string;\n color?: string;\n data?: string | number;\n shouldDrawBorderBottom?: boolean;\n yAxisCalloutData?: string | { [id: string]: number };\n index?: number;\n callOutAccessibilityData?: AccessibilityProps;\n}\n\nexport interface ChildProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xScale?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScalePrimary?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScaleSecondary?: any;\n containerHeight?: number;\n containerWidth?: number;\n optimizeLargeData?: boolean;\n}\n\n// Only used for Cartesian chart base\nexport interface ModifiedCartesianChartProps extends CartesianChartProps {\n /**\n * Define the chart title\n */\n chartTitle?: string;\n\n /**\n * Only used for Area chart\n * Value used to draw y axis of that chart.\n */\n maxOfYVal?: number;\n\n /**\n * Data of the chart\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n points: any;\n\n /**\n * Define type of the chart\n */\n chartType: ChartTypes;\n\n /** X axis type */\n xAxisType: XAxisTypes;\n\n /** Y axis type */\n yAxisType?: YAxisType;\n\n /**\n * Legends of the chart.\n */\n legendBars: JSXElement | null;\n\n /**\n * Callout props\n */\n calloutProps?: ChartPopoverProps;\n\n /**\n * Callback method used for to get margins to the chart.\n */\n getmargins?: (margins: Margins) => void;\n\n /**\n * This is a call back method to the chart from cartesian chart.\n * params are xScale, yScale, containerHeight, containerWidth. These values were used to draw the graph.\n * It also contians an optional param xAxisElement - defines as x axis scale element.\n * This param used to enable feature word wrap of Xaxis.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getGraphData?: any;\n\n /**\n * Used for bar chart graphs.\n * To define width of the bar\n */\n barwidth?: number;\n\n /**\n * Used for tick styles of the x axis of the chart\n * Tick params are applicable for date axis only.\n */\n tickParams?: {\n tickValues?: number[] | Date[] | string[];\n tickFormat?: string;\n };\n\n /**\n * it's padding between bar's or lines in the graph\n */\n xAxisPadding?: number;\n\n /**\n * it's padding between bar's or lines in the graph\n */\n yAxisPadding?: number;\n\n /**\n * Children elements specific to derived chart types.\n */\n children(props: ChildProps): React.ReactNode;\n\n /**\n * To enable callout for individual bar or complete stack. Using for only Vertical stacked bar chart.\n * @default false\n * @type \\{boolean \\}\n */\n isCalloutForStack?: boolean;\n\n /** dataset values to find out domain of the String axis\n * Present using for only vertical stacked bar chart and grouped vertical bar chart\n */\n datasetForXAxisDomain?: string[];\n\n /** Own callout design */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n customizedCallout?: any;\n\n /**\n * if the data points for the y-axis is of type string, then we need to give this\n * prop to construct the y-axis\n */\n stringDatasetForYAxisDomain?: string[];\n\n /**\n * The prop used to define the culture to localize the numbers and date\n */\n culture?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getAxisData?: any;\n\n /**\n * Callback method used when mouse leaves the chart boundary.\n */\n onChartMouseLeave?: () => void;\n\n /** Callback method to get extra margins for domain */\n getDomainMargins?: (containerWidth: number) => Margins;\n\n /** Callback method to get extra margins for Y-axis domain */\n getYDomainMargins?: (containerHeight: number) => Margins;\n\n /** Padding between each bar/line-point */\n xAxisInnerPadding?: number;\n\n /** Padding before first bar/line-point and after last bar/line-point */\n xAxisOuterPadding?: number;\n\n /**\n *@default false\n *Used for to elipse y axis labes and show tooltip on x axis labels\n */\n showYAxisLablesTooltip?: boolean;\n\n /**\n *@default false\n *Used for showing complete y axis lables */\n showYAxisLables?: boolean;\n\n /**\n * @default false\n * Used to control the first render cycle Performance optimization code.\n */\n enableFirstRenderOptimization?: boolean;\n\n /**\n * Get the min and max values of the y-axis\n */\n getMinMaxOfYAxis: (\n points:\n | LineChartPoints[]\n | HorizontalBarChartWithAxisDataPoint[]\n | VerticalBarChartDataPoint[]\n | DataPoint[]\n | ScatterChartPoints[]\n | GanttChartDataPoint[],\n yAxisType: YAxisType | undefined,\n useSecondaryYScale?: boolean,\n ) => { startValue: number; endValue: number };\n\n /**\n * Create the y-axis\n */\n createYAxis: (\n yAxisParams: IYAxisParams,\n isRtl: boolean,\n axisData: IAxisData,\n isIntegralDataset: boolean,\n chartType: ChartTypes,\n useSecondaryYScale?: boolean,\n roundedTicks?: boolean,\n scaleType?: AxisScaleType,\n _useRtl?: boolean,\n ) => ScaleLinear<number, number, never>;\n\n /**\n * Get the domain and range values\n */\n getDomainNRangeValues: (\n points:\n | LineChartPoints[]\n | VerticalBarChartDataPoint[]\n | VerticalStackedBarDataPoint[]\n | HorizontalBarChartWithAxisDataPoint[]\n | GroupedVerticalBarChartData[]\n | HeatMapChartDataPoint[]\n | GanttChartDataPoint[],\n margins: Margins,\n width: number,\n chartType: ChartTypes,\n isRTL: boolean,\n xAxisType: XAxisTypes,\n barWidth: number,\n tickValues: Date[] | number[] | string[] | undefined,\n ) => IDomainNRange;\n\n /**\n * Create the string y-axis\n */\n createStringYAxis: (\n yAxisParams: IYAxisParams,\n dataPoints: string[],\n isRtl: boolean,\n axisData: IAxisData,\n barWidth: number | undefined,\n chartType?: ChartTypes,\n ) => ScaleBand<string>;\n\n /**\n * Controls whether the numeric x-axis domain should be extended to start and end at nice rounded values.\n * @default true\n */\n showRoundOffXTickValues?: boolean;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
1
|
+
{"version":3,"sources":["../src/components/CommonComponents/CartesianChart.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { LegendsProps } from '../Legends/index';\nimport {\n AccessibilityProps,\n Chart,\n Margins,\n DataPoint,\n ChartAnnotation,\n HorizontalBarChartWithAxisDataPoint,\n GroupedVerticalBarChartData,\n HeatMapChartDataPoint,\n LineChartPoints,\n VerticalBarChartDataPoint,\n VerticalStackedBarDataPoint,\n ScatterChartPoints,\n GanttChartDataPoint,\n AxisCategoryOrder,\n AxisProps,\n AxisScaleType,\n} from '../../types/index';\nimport { TimeLocaleDefinition } from 'd3-time-format';\nimport { ChartPopoverProps } from './ChartPopover.types';\nimport { ChartTypes, IAxisData, IDomainNRange, IYAxisParams, XAxisTypes, YAxisType } from '../../utilities/utilities';\nimport { ScaleBand, ScaleLinear } from 'd3-scale';\n/**\n * Cartesian Chart style properties\n * {@docCategory CartesianChart}\n */\nexport interface CartesianChartStyleProps {\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Width of the chart.\n */\n width?: number;\n\n /**\n * Height of the chart.\n */\n height?: number;\n\n /**\n * Color of the chart.\n */\n color?: string;\n\n /**\n * Link to redirect if click action for graph\n */\n href?: string;\n\n /**\n * prop to check if the chart is selected or hovered upon to determine opacity\n */\n shouldHighlight?: boolean;\n\n /**\n * prop to check if the Page is in Rtl\n */\n useRtl?: boolean;\n\n /**\n * color of the line\n */\n lineColor?: string;\n\n /**\n * boolean flag which determines if shape is drawn in callout\n */\n toDrawShape?: boolean;\n\n /**\n * Prop to disable shrinking of the chart beyond a certain limit and enable scrolling when the chart overflows\n * @deprecated Use `reflowProps` instead.\n */\n enableReflow?: boolean;\n}\n\n/**\n * Cartesian Chart styles\n * {@docCategory CartesianChart}\n */\nexport interface CartesianChartStyles {\n /**\n * Style for the root element.\n */\n root?: string;\n\n /**\n * Style for the element containing the x-axis.\n */\n xAxis?: string;\n\n /**\n * Style for the element containing the y-axis.\n */\n yAxis?: string;\n\n /**\n * Style for legend container\n */\n legendContainer?: string;\n\n /**\n * line hover box css\n */\n hover?: string;\n\n /**\n * styles for description message\n */\n descriptionMessage?: string;\n\n /**\n * styles for tooltip\n */\n tooltip?: string;\n\n /**\n * styles for axis title\n */\n axisTitle?: string;\n\n /**\n * styles for axis annotation\n */\n axisAnnotation?: string;\n\n /**\n * Style for the chart Title.\n */\n chartTitle?: string;\n\n /**\n * Style to change the opacity of bars in dataviz when we hover on a single bar or legends\n */\n opacityChangeOnHover?: string;\n\n /**\n * styles for the shape object in the callout\n */\n shapeStyles?: string;\n\n /**\n * Styles for the chart wrapper div\n */\n chartWrapper?: string;\n\n /**\n * Styles for the element wrapping the svg and overlays for annotation\n */\n plotContainer?: string;\n\n /**\n * Styles for the svg tooltip\n */\n svgTooltip?: string;\n\n /**\n * Styles applied to the annotation layer root element\n */\n annotationLayer?: string;\n\n /**\n * Styles for the chart svg element\n */\n chart?: string;\n}\n\n/**\n * Cartesian Chart properties\n * {@docCategory CartesianChart}\n */\nexport interface CartesianChartProps {\n /**\n * Below height used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n height?: number;\n\n /**\n * Below width used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n width?: number;\n\n /**\n * this prop takes its parent as a HTML element to define the width and height of the chart\n */\n parentRef?: HTMLElement | null;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Margins for the chart\n * @default `{ top: 20, bottom: 35, left: 40, right: 20 }`\n * To avoid edge cuttings to the chart, we recommend you use default values or greater then default values\n */\n margins?: Margins;\n\n /** decides wether to show/hide legends\n * @defaultvalue false\n */\n hideLegend?: boolean;\n\n /**\n * Do not show tooltips in chart\n * @default false\n */\n hideTooltip?: boolean;\n\n /**\n * this prop takes values that you want the chart to render on x-axis\n * This is a optional parameter if not specified D3 will decide which values appear on the x-axis for you\n * Please look at https://github.com/d3/d3-scale for more information on how D3 decides what data to appear on the axis of chart\n */\n tickValues?: number[] | Date[] | string[] | undefined;\n\n /**\n * the format for the data on x-axis. For date object this can be specified to your requirement. Eg: '%m/%d', '%d'\n * Please look at https://github.com/d3/d3-time-format for all the formats supported for date axis\n * Only applicable for date axis. For y-axis format use yAxisTickFormat prop.\n */\n tickFormat?: string;\n\n /**\n * Width of line stroke\n */\n strokeWidth?: number;\n\n /**\n * x Axis labels tick padding. This defines the gap between tick labels and tick lines.\n * @default 10\n */\n xAxisTickPadding?: number;\n\n /**\n * the format in for the data on y-axis. For data object this can be specified to your requirement.\n * Eg: d3.format(\".0%\")(0.123),d3.format(\"+20\")(42);\n * Please look at https://github.com/d3/d3-format for all the formats supported\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yAxisTickFormat?: any;\n\n /**\n * Secondary y-scale options\n * By default this is not defined, meaning there will be no secondary y-scale.\n */\n secondaryYScaleOptions?: {\n /** Minimum value (0 by default) */\n yMinValue?: number;\n /** Maximum value (100 by default) */\n yMaxValue?: number;\n };\n\n /**\n * minimum data value point in y-axis\n */\n yMinValue?: number;\n\n /**\n * maximum data value point in y-axis\n */\n yMaxValue?: number;\n\n /**\n * minimum data value point in x-axis (for numeric x-axis)\n */\n xMinValue?: number;\n\n /**\n * maximum data value point in x-axis\n */\n xMaxValue?: number;\n\n /**\n * Number of ticks on the y-axis.\n * Tick count should be factor of difference between (yMinValue, yMaxValue)?\n * @default 4\n */\n yAxisTickCount?: number;\n\n /**\n * defines the number of ticks on the x-axis. Tries to match the nearest interval satisfying the count.\n * Does not work for string axis.\n * @default 6\n */\n xAxisTickCount?: number;\n\n /**\n * define the size of the tick lines on the x-axis\n * @default 10\n */\n xAxistickSize?: number;\n\n /**\n * Text annotations rendered on top of the chart area\n */\n annotations?: ChartAnnotation[];\n\n /**\n * defines the space between the tick line and the data label\n * @default 10\n */\n tickPadding?: number;\n\n /**\n * Url that the data-viz needs to redirect to upon clicking on it\n */\n href?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n legendsOverflowText?: any;\n\n /**\n * Enable the legends to wrap lines if there is not enough space to show all legends on a single line\n */\n enabledLegendsWrapLines?: boolean;\n\n /*\n * props for the legends in the chart\n */\n legendProps?: Partial<LegendsProps>;\n\n /**\n *@default false\n *Used for to elipse x axis labes and show tooltip on x axis labels\n */\n showXAxisLablesTooltip?: boolean;\n\n /**\n * @default 4\n * Used for X axis labels\n * While Giving showXAxisLablesTooltip prop, need to define after how many chars, we need to truncate the word.\n */\n noOfCharsToTruncate?: number;\n\n /**\n * @default false\n * Used to wrap x axis labels values (whole value)\n */\n wrapXAxisLables?: boolean;\n\n /**\n * @default false\n * Used to rotate x axis labels by 45 degrees\n */\n rotateXAxisLables?: boolean;\n\n /**\n * The prop used to define the date time localization options\n */\n dateLocalizeOptions?: Intl.DateTimeFormatOptions;\n\n /**\n * The prop used to define a custom locale for the date time format.\n */\n timeFormatLocale?: TimeLocaleDefinition;\n\n /**\n * The prop used to define a custom datetime formatter for date axis.\n */\n customDateTimeFormatter?: (dateTime: Date) => string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: CartesianChartStyles;\n\n /**\n * Callout customization props\n */\n calloutProps?: Partial<ChartPopoverProps>;\n\n /**\n * props for the svg; use this to include aria-* or other attributes on the tag\n */\n svgProps?: React.SVGProps<SVGSVGElement>;\n\n /**\n * Prop to disable shrinking of the chart beyond a certain limit and enable scrolling when the chart overflows\n * @deprecated Use `reflowProps` instead.\n */\n enableReflow?: boolean;\n\n /**\n * Props related to reflow behavior of the chart\n */\n reflowProps?: {\n /**\n * Determines the reflow behavior of the chart.\n * When set to `'min-width'`, the chart will not shrink below a certain width and will enable scrolling if it overflows.\n * @default 'none'\n */\n mode: 'none' | 'min-width';\n };\n\n /**\n * Prop to set the x axis title\n * @default undefined\n * Minimum bottom margin required for x axis title is 55px\n */\n\n xAxisTitle?: string;\n\n /**\n * Prop to set the y axis title\n * @default undefined\n * Minimum left margin required for y axis title is 60px and for RTL is 40px\n * Minimum right margin required for y axis title is 40px and for RTL is 60px\n */\n yAxisTitle?: string;\n\n /**\n * Prop to set the secondary y axis title\n * @default undefined\n * If RTL is enabled, minimum left and right margins required for secondary y axis title is 60px\n */\n secondaryYAxistitle?: string;\n\n /**\n * Whether to use UTC time for axis scale, ticks, and the time display in callouts.\n * When set to `true`, time is displayed equally, regardless of the user's timezone settings.\n * @default true\n */\n useUTC?: string | boolean;\n\n /**\n * @default false\n * The prop used to decide rounded ticks on y axis\n */\n roundedTicks?: boolean;\n\n /**\n * Determines whether overlapping x-axis tick labels should be hidden.\n * @default true\n */\n hideTickOverlap?: boolean;\n\n /**\n * Define a custom callout props override\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n calloutPropsPerDataPoint?: (dataPointCalloutProps: any) => ChartPopoverProps;\n\n /**\n * Optional callback to access the Chart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.Ref<Chart>;\n\n /**\n * Prop to set the x axis annotation. Used to display additional information on the x-axis.\n * This is shown on the top of the chart.\n * @default undefined\n */\n xAxisAnnotation?: string;\n\n /**\n * Prop to set the y axis annotation. Used to display additional information on the y-axis.\n * This is shown on the right side of the chart. Not shown if secondary y-axis is enabled.\n * @default undefined\n */\n yAxisAnnotation?: string;\n\n /**\n * Specifies the ordering logic for categories (or string tick labels) on the x-axis.\n * @default 'default'\n */\n xAxisCategoryOrder?: AxisCategoryOrder;\n\n /**\n * Specifies the ordering logic for categories (or string tick labels) on the y-axis.\n * @default 'default'\n */\n yAxisCategoryOrder?: AxisCategoryOrder;\n\n /**\n * Defines the scale type for the x-axis.\n * @default 'default'\n */\n xScaleType?: AxisScaleType;\n\n /**\n * Defines the scale type for the primary y-axis.\n * @default 'default'\n */\n yScaleType?: AxisScaleType;\n\n /**\n * Defines the scale type for the secondary y-axis.\n * @default 'default'\n */\n secondaryYScaleType?: AxisScaleType;\n\n /**\n * Explicit set of tick values for the y-axis.\n * If provided, these values override automatic tick generation.\n */\n yAxisTickValues?: number[] | Date[] | string[];\n\n /**\n * Configuration for the x-axis.\n * Use this to control `tickStep`, `tick0`, etc.\n */\n xAxis?: AxisProps;\n\n /**\n * Configuration for the y-axis.\n * Use this to control `tickStep`, `tick0`, etc.\n */\n yAxis?: AxisProps;\n\n /**\n *@default false\n *Used for showing complete y axis lables */\n showYAxisLables?: boolean;\n\n /**\n *@default false\n *Used for to elipse y axis labes and show tooltip on x axis labels\n */\n showYAxisLablesTooltip?: boolean;\n}\n\nexport interface YValueHover {\n legend?: string;\n y?: number | string;\n color?: string;\n data?: string | number;\n shouldDrawBorderBottom?: boolean;\n yAxisCalloutData?: string | { [id: string]: number };\n index?: number;\n callOutAccessibilityData?: AccessibilityProps;\n}\n\nexport interface ChildProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xScale?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScalePrimary?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n yScaleSecondary?: any;\n containerHeight?: number;\n containerWidth?: number;\n optimizeLargeData?: boolean;\n}\n\n// Only used for Cartesian chart base\nexport interface ModifiedCartesianChartProps extends CartesianChartProps {\n /**\n * Define the chart title\n */\n chartTitle?: string;\n\n /**\n * Only used for Area chart\n * Value used to draw y axis of that chart.\n */\n maxOfYVal?: number;\n\n /**\n * Data of the chart\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n points: any;\n\n /**\n * Define type of the chart\n */\n chartType: ChartTypes;\n\n /** X axis type */\n xAxisType: XAxisTypes;\n\n /** Y axis type */\n yAxisType?: YAxisType;\n\n /**\n * Legends of the chart.\n */\n legendBars: JSXElement | null;\n\n /**\n * Callout props\n */\n calloutProps?: ChartPopoverProps;\n\n /**\n * Callback method used for to get margins to the chart.\n */\n getmargins?: (margins: Margins) => void;\n\n /**\n * This is a call back method to the chart from cartesian chart.\n * params are xScale, yScale, containerHeight, containerWidth. These values were used to draw the graph.\n * It also contians an optional param xAxisElement - defines as x axis scale element.\n * This param used to enable feature word wrap of Xaxis.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getGraphData?: any;\n\n /**\n * Used for bar chart graphs.\n * To define width of the bar\n */\n barwidth?: number;\n\n /**\n * Used for tick styles of the x axis of the chart\n * Tick params are applicable for date axis only.\n */\n tickParams?: {\n tickValues?: number[] | Date[] | string[];\n tickFormat?: string;\n };\n\n /**\n * it's padding between bar's or lines in the graph\n */\n xAxisPadding?: number;\n\n /**\n * it's padding between bar's or lines in the graph\n */\n yAxisPadding?: number;\n\n /**\n * Children elements specific to derived chart types.\n */\n children(props: ChildProps): React.ReactNode;\n\n /**\n * To enable callout for individual bar or complete stack. Using for only Vertical stacked bar chart.\n * @default false\n * @type \\{boolean \\}\n */\n isCalloutForStack?: boolean;\n\n /** dataset values to find out domain of the String axis\n * Present using for only vertical stacked bar chart and grouped vertical bar chart\n */\n datasetForXAxisDomain?: string[];\n\n /** Own callout design */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n customizedCallout?: any;\n\n /**\n * if the data points for the y-axis is of type string, then we need to give this\n * prop to construct the y-axis\n */\n stringDatasetForYAxisDomain?: string[];\n\n /**\n * The prop used to define the culture to localize the numbers and date\n */\n culture?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getAxisData?: any;\n\n /**\n * Callback method used when mouse leaves the chart boundary.\n */\n onChartMouseLeave?: () => void;\n\n /** Callback method to get extra margins for domain */\n getDomainMargins?: (containerWidth: number) => Margins;\n\n /** Callback method to get extra margins for Y-axis domain */\n getYDomainMargins?: (containerHeight: number) => Margins;\n\n /** Padding between each bar/line-point */\n xAxisInnerPadding?: number;\n\n /** Padding before first bar/line-point and after last bar/line-point */\n xAxisOuterPadding?: number;\n\n /**\n *@default false\n *Used for to elipse y axis labes and show tooltip on x axis labels\n */\n showYAxisLablesTooltip?: boolean;\n\n /**\n *@default false\n *Used for showing complete y axis lables */\n showYAxisLables?: boolean;\n\n /**\n * @default false\n * Used to control the first render cycle Performance optimization code.\n */\n enableFirstRenderOptimization?: boolean;\n\n /**\n * Get the min and max values of the y-axis\n */\n getMinMaxOfYAxis: (\n points:\n | LineChartPoints[]\n | HorizontalBarChartWithAxisDataPoint[]\n | VerticalBarChartDataPoint[]\n | DataPoint[]\n | ScatterChartPoints[]\n | GanttChartDataPoint[],\n yAxisType: YAxisType | undefined,\n useSecondaryYScale?: boolean,\n ) => { startValue: number; endValue: number };\n\n /**\n * Create the y-axis\n */\n createYAxis: (\n yAxisParams: IYAxisParams,\n isRtl: boolean,\n axisData: IAxisData,\n isIntegralDataset: boolean,\n chartType: ChartTypes,\n useSecondaryYScale?: boolean,\n roundedTicks?: boolean,\n scaleType?: AxisScaleType,\n _useRtl?: boolean,\n ) => ScaleLinear<number, number, never>;\n\n /**\n * Get the domain and range values\n */\n getDomainNRangeValues: (\n points:\n | LineChartPoints[]\n | VerticalBarChartDataPoint[]\n | VerticalStackedBarDataPoint[]\n | HorizontalBarChartWithAxisDataPoint[]\n | GroupedVerticalBarChartData[]\n | HeatMapChartDataPoint[]\n | GanttChartDataPoint[],\n margins: Margins,\n width: number,\n chartType: ChartTypes,\n isRTL: boolean,\n xAxisType: XAxisTypes,\n barWidth: number,\n tickValues: Date[] | number[] | string[] | undefined,\n ) => IDomainNRange;\n\n /**\n * Create the string y-axis\n */\n createStringYAxis: (\n yAxisParams: IYAxisParams,\n dataPoints: string[],\n isRtl: boolean,\n axisData: IAxisData,\n barWidth: number | undefined,\n chartType?: ChartTypes,\n ) => ScaleBand<string>;\n\n /**\n * Controls whether the numeric x-axis domain should be extended to start and end at nice rounded values.\n * @default true\n */\n showRoundOffXTickValues?: boolean;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -281,62 +281,6 @@ const toFiniteNumber = (value)=>{
|
|
|
281
281
|
const numeric = typeof value === 'number' ? value : Number(value);
|
|
282
282
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
283
283
|
};
|
|
284
|
-
/**
|
|
285
|
-
* Normalizes Plotly axis reference strings so equivalent aliases (e.g. `xaxis1`, `x1`) collapse to the base axis id.
|
|
286
|
-
*/ const normalizeAxisRef = (ref, axis)=>{
|
|
287
|
-
if (!ref) {
|
|
288
|
-
return axis;
|
|
289
|
-
}
|
|
290
|
-
const normalized = ref.toLowerCase();
|
|
291
|
-
if (normalized === axis || normalized === `${axis}axis` || normalized === `${axis}axis1` || normalized === `${axis}1`) {
|
|
292
|
-
return axis;
|
|
293
|
-
}
|
|
294
|
-
const match = normalized.match(/^([xy])(axis)?(\d+)$/);
|
|
295
|
-
if (match && match[1] === axis && match[3]) {
|
|
296
|
-
return match[3] === '1' ? axis : `${axis}${match[3]}`;
|
|
297
|
-
}
|
|
298
|
-
return normalized;
|
|
299
|
-
};
|
|
300
|
-
/**
|
|
301
|
-
* Scans the data traces bound to a given axis and returns the numeric min/max values plotted on that axis.
|
|
302
|
-
*/ const getAxisNumericRangeFromData = (axis, ref, layout, data)=>{
|
|
303
|
-
if (!data || data.length === 0) {
|
|
304
|
-
return undefined;
|
|
305
|
-
}
|
|
306
|
-
const axisLayout = getAxisLayoutByRef(layout, ref, axis);
|
|
307
|
-
const targetRef = normalizeAxisRef(ref, axis);
|
|
308
|
-
const traceAxisKey = axis === 'x' ? 'xaxis' : 'yaxis';
|
|
309
|
-
let minValue;
|
|
310
|
-
let maxValue;
|
|
311
|
-
data.forEach((trace)=>{
|
|
312
|
-
const plotTrace = trace;
|
|
313
|
-
const traceAxisRef = normalizeAxisRef(plotTrace[traceAxisKey], axis);
|
|
314
|
-
if (traceAxisRef !== targetRef) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
const values = axis === 'x' ? plotTrace.x : plotTrace.y;
|
|
318
|
-
if (!isArrayOrTypedArray(values)) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const arrayLike = values;
|
|
322
|
-
for(let index = 0; index < arrayLike.length; index++){
|
|
323
|
-
const value = arrayLike[index];
|
|
324
|
-
const numeric = toNumericValue(convertDataValue(value, axisLayout));
|
|
325
|
-
if (numeric === undefined || Number.isNaN(numeric)) {
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
minValue = minValue === undefined ? numeric : Math.min(minValue, numeric);
|
|
329
|
-
maxValue = maxValue === undefined ? numeric : Math.max(maxValue, numeric);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
if (minValue === undefined || maxValue === undefined || minValue === maxValue) {
|
|
333
|
-
return undefined;
|
|
334
|
-
}
|
|
335
|
-
return [
|
|
336
|
-
minValue,
|
|
337
|
-
maxValue
|
|
338
|
-
];
|
|
339
|
-
};
|
|
340
284
|
/**
|
|
341
285
|
* Converts Plotly's bottom-origin relative Y coordinate into the SVG top-origin space used by our overlay.
|
|
342
286
|
*/ const transformRelativeYForChart = (value)=>{
|
|
@@ -437,49 +381,32 @@ const appendPx = (value)=>{
|
|
|
437
381
|
if (value === undefined || value === null) {
|
|
438
382
|
return undefined;
|
|
439
383
|
}
|
|
440
|
-
|
|
384
|
+
const axisType = axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type;
|
|
385
|
+
if (axisType === 'date') {
|
|
441
386
|
const dateValue = value instanceof Date ? value : new Date(value);
|
|
442
387
|
return Number.isNaN(dateValue.getTime()) ? undefined : dateValue;
|
|
443
388
|
}
|
|
444
|
-
if (typeof value === 'number') {
|
|
445
|
-
return value;
|
|
446
|
-
}
|
|
447
|
-
if ((axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'linear' || (axisLayout === null || axisLayout === void 0 ? void 0 : axisLayout.type) === 'log') {
|
|
448
|
-
const numeric = Number(value);
|
|
449
|
-
return Number.isFinite(numeric) ? numeric : undefined;
|
|
450
|
-
}
|
|
451
389
|
if (value instanceof Date) {
|
|
452
|
-
return value;
|
|
453
|
-
}
|
|
454
|
-
return value;
|
|
455
|
-
};
|
|
456
|
-
const toNumericValue = (value)=>{
|
|
457
|
-
if (value instanceof Date) {
|
|
458
|
-
const timestamp = value.getTime();
|
|
459
|
-
return Number.isFinite(timestamp) ? timestamp : undefined;
|
|
390
|
+
return Number.isNaN(value.getTime()) ? undefined : value;
|
|
460
391
|
}
|
|
461
392
|
if (typeof value === 'number') {
|
|
462
393
|
return Number.isFinite(value) ? value : undefined;
|
|
463
394
|
}
|
|
464
|
-
if (
|
|
395
|
+
if (axisType === 'linear' || axisType === 'log') {
|
|
465
396
|
const numeric = Number(value);
|
|
466
397
|
return Number.isFinite(numeric) ? numeric : undefined;
|
|
467
398
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
const current = toNumericValue(convertDataValue(value, axisLayout));
|
|
478
|
-
if (start === undefined || end === undefined || current === undefined || start === end) {
|
|
479
|
-
return undefined;
|
|
399
|
+
if (typeof value === 'string') {
|
|
400
|
+
const shouldTryParseDate = axisType === undefined || axisType === '-' || axisType === null;
|
|
401
|
+
if (shouldTryParseDate && isDate(value)) {
|
|
402
|
+
const parsedDate = new Date(value);
|
|
403
|
+
if (!Number.isNaN(parsedDate.getTime()) && parsedDate.getFullYear() >= 1900) {
|
|
404
|
+
return parsedDate;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return value;
|
|
480
408
|
}
|
|
481
|
-
|
|
482
|
-
return Number.isFinite(relative) ? relative : undefined;
|
|
409
|
+
return value;
|
|
483
410
|
};
|
|
484
411
|
const createAnnotationId = (text, index)=>{
|
|
485
412
|
const normalized = text.replace(/\s+/g, ' ').trim();
|
|
@@ -544,10 +471,35 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
544
471
|
return value;
|
|
545
472
|
}
|
|
546
473
|
};
|
|
474
|
+
const mapRefTypeToCoordinateType = (refType)=>{
|
|
475
|
+
return refType === 'axis' ? 'data' : refType;
|
|
476
|
+
};
|
|
477
|
+
const normalizeCoordinateValueForType = (coordinateType, value)=>{
|
|
478
|
+
if (coordinateType === 'data') {
|
|
479
|
+
return value;
|
|
480
|
+
}
|
|
481
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
482
|
+
};
|
|
483
|
+
const getAnnotationCoordinateValue = (axis, refType, annotation, layout)=>{
|
|
484
|
+
if (refType === 'axis') {
|
|
485
|
+
const axisRef = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.xref : annotation === null || annotation === void 0 ? void 0 : annotation.yref;
|
|
486
|
+
const axisLayout = getAxisLayoutByRef(layout, axisRef, axis);
|
|
487
|
+
const rawValue = axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y;
|
|
488
|
+
return convertDataValue(rawValue, axisLayout);
|
|
489
|
+
}
|
|
490
|
+
const numericValue = toFiniteNumber(axis === 'x' ? annotation === null || annotation === void 0 ? void 0 : annotation.x : annotation === null || annotation === void 0 ? void 0 : annotation.y);
|
|
491
|
+
if (numericValue === undefined) {
|
|
492
|
+
return undefined;
|
|
493
|
+
}
|
|
494
|
+
if (refType === 'relative') {
|
|
495
|
+
return axis === 'y' ? transformRelativeYForChart(numericValue) : numericValue;
|
|
496
|
+
}
|
|
497
|
+
return numericValue;
|
|
498
|
+
};
|
|
547
499
|
/**
|
|
548
500
|
* Converts a Plotly annotation definition into the internal `ChartAnnotation` format, translating coordinates,
|
|
549
501
|
* layout alignment, styling, and connector metadata while skipping unsupported configurations.
|
|
550
|
-
*/ const convertPlotlyAnnotation = (annotation, layout,
|
|
502
|
+
*/ const convertPlotlyAnnotation = (annotation, layout, index)=>{
|
|
551
503
|
if (!annotation || annotation.visible === false) {
|
|
552
504
|
return undefined;
|
|
553
505
|
}
|
|
@@ -556,77 +508,51 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
556
508
|
if (!xRefType || !yRefType) {
|
|
557
509
|
return undefined;
|
|
558
510
|
}
|
|
511
|
+
const xValue = getAnnotationCoordinateValue('x', xRefType, annotation, layout);
|
|
512
|
+
const yValue = getAnnotationCoordinateValue('y', yRefType, annotation, layout);
|
|
513
|
+
if (xValue === undefined || yValue === undefined) {
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
const xCoordinateType = mapRefTypeToCoordinateType(xRefType);
|
|
517
|
+
const yCoordinateType = mapRefTypeToCoordinateType(yRefType);
|
|
518
|
+
const normalizedX = normalizeCoordinateValueForType(xCoordinateType, xValue);
|
|
519
|
+
const normalizedY = normalizeCoordinateValueForType(yCoordinateType, yValue);
|
|
520
|
+
if (normalizedX === undefined || normalizedY === undefined) {
|
|
521
|
+
return undefined;
|
|
522
|
+
}
|
|
523
|
+
const yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
524
|
+
const yAxisProps = yCoordinateType === 'data' && yRefNormalized === 'y2' ? {
|
|
525
|
+
yAxis: 'secondary'
|
|
526
|
+
} : undefined;
|
|
559
527
|
let coordinates;
|
|
560
|
-
if (
|
|
561
|
-
const xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
562
|
-
const yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
563
|
-
const xValue = convertDataValue(annotation.x, xAxisLayout);
|
|
564
|
-
const yValue = convertDataValue(annotation.y, yAxisLayout);
|
|
565
|
-
if (xValue === undefined || yValue === undefined) {
|
|
566
|
-
return undefined;
|
|
567
|
-
}
|
|
568
|
-
const yRefNormalized = typeof annotation.yref === 'string' ? annotation.yref.toLowerCase() : undefined;
|
|
528
|
+
if (xCoordinateType === 'data' && yCoordinateType === 'data') {
|
|
569
529
|
coordinates = {
|
|
570
530
|
type: 'data',
|
|
571
|
-
x:
|
|
572
|
-
y:
|
|
573
|
-
...
|
|
574
|
-
yAxis: 'secondary'
|
|
575
|
-
} : {}
|
|
531
|
+
x: normalizedX,
|
|
532
|
+
y: normalizedY,
|
|
533
|
+
...yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {}
|
|
576
534
|
};
|
|
577
|
-
} else if (
|
|
578
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
579
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
580
|
-
const chartRelativeY = transformRelativeYForChart(yValue);
|
|
581
|
-
if (xValue === undefined || chartRelativeY === undefined) {
|
|
582
|
-
return undefined;
|
|
583
|
-
}
|
|
535
|
+
} else if (xCoordinateType === 'relative' && yCoordinateType === 'relative') {
|
|
584
536
|
coordinates = {
|
|
585
537
|
type: 'relative',
|
|
586
|
-
x:
|
|
587
|
-
y:
|
|
538
|
+
x: normalizedX,
|
|
539
|
+
y: normalizedY
|
|
588
540
|
};
|
|
589
|
-
} else if (
|
|
590
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
591
|
-
const yAxisLayout = getAxisLayoutByRef(layout, annotation.yref, 'y');
|
|
592
|
-
const yFallbackRange = getAxisNumericRangeFromData('y', annotation.yref, layout, data);
|
|
593
|
-
const yRelative = toRelativeCoordinate(annotation.y, yAxisLayout, yFallbackRange);
|
|
594
|
-
const chartRelativeY = transformRelativeYForChart(yRelative);
|
|
595
|
-
if (xValue === undefined || chartRelativeY === undefined) {
|
|
596
|
-
return undefined;
|
|
597
|
-
}
|
|
598
|
-
coordinates = {
|
|
599
|
-
type: 'relative',
|
|
600
|
-
x: xValue,
|
|
601
|
-
y: chartRelativeY
|
|
602
|
-
};
|
|
603
|
-
} else if (xRefType === 'axis' && yRefType === 'relative') {
|
|
604
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
605
|
-
const xAxisLayout = getAxisLayoutByRef(layout, annotation.xref, 'x');
|
|
606
|
-
const xFallbackRange = getAxisNumericRangeFromData('x', annotation.xref, layout, data);
|
|
607
|
-
const xRelative = toRelativeCoordinate(annotation.x, xAxisLayout, xFallbackRange);
|
|
608
|
-
const chartRelativeY = transformRelativeYForChart(yValue);
|
|
609
|
-
if (xRelative === undefined || chartRelativeY === undefined) {
|
|
610
|
-
return undefined;
|
|
611
|
-
}
|
|
612
|
-
coordinates = {
|
|
613
|
-
type: 'relative',
|
|
614
|
-
x: xRelative,
|
|
615
|
-
y: chartRelativeY
|
|
616
|
-
};
|
|
617
|
-
} else if (xRefType === 'pixel' && yRefType === 'pixel') {
|
|
618
|
-
const xValue = toFiniteNumber(annotation.x);
|
|
619
|
-
const yValue = toFiniteNumber(annotation.y);
|
|
620
|
-
if (xValue === undefined || yValue === undefined) {
|
|
621
|
-
return undefined;
|
|
622
|
-
}
|
|
541
|
+
} else if (xCoordinateType === 'pixel' && yCoordinateType === 'pixel') {
|
|
623
542
|
coordinates = {
|
|
624
543
|
type: 'pixel',
|
|
625
|
-
x:
|
|
626
|
-
y:
|
|
544
|
+
x: normalizedX,
|
|
545
|
+
y: normalizedY
|
|
627
546
|
};
|
|
628
547
|
} else {
|
|
629
|
-
|
|
548
|
+
coordinates = {
|
|
549
|
+
type: 'mixed',
|
|
550
|
+
xCoordinateType,
|
|
551
|
+
yCoordinateType,
|
|
552
|
+
x: normalizedX,
|
|
553
|
+
y: normalizedY,
|
|
554
|
+
...yAxisProps !== null && yAxisProps !== void 0 ? yAxisProps : {}
|
|
555
|
+
};
|
|
630
556
|
}
|
|
631
557
|
const textValue = annotation.text;
|
|
632
558
|
const rawText = textValue === undefined || textValue === null ? '' : String(textValue);
|
|
@@ -783,14 +709,14 @@ const mapArrowDashToPattern = (value)=>{
|
|
|
783
709
|
}
|
|
784
710
|
return chartAnnotation;
|
|
785
711
|
};
|
|
786
|
-
const getChartAnnotationsFromLayout = (layout,
|
|
712
|
+
const getChartAnnotationsFromLayout = (layout, isMultiPlot)=>{
|
|
787
713
|
if (isMultiPlot || !(layout === null || layout === void 0 ? void 0 : layout.annotations)) {
|
|
788
714
|
return undefined;
|
|
789
715
|
}
|
|
790
716
|
const annotationsArray = Array.isArray(layout.annotations) ? layout.annotations : [
|
|
791
717
|
layout.annotations
|
|
792
718
|
];
|
|
793
|
-
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, layout,
|
|
719
|
+
const converted = annotationsArray.map((annotation, index)=>convertPlotlyAnnotation(annotation, layout, index)).filter((annotation)=>annotation !== undefined);
|
|
794
720
|
return converted.length > 0 ? converted : undefined;
|
|
795
721
|
};
|
|
796
722
|
/**
|
|
@@ -872,7 +798,7 @@ const getChartAnnotationsFromLayout = (layout, data, isMultiPlot)=>{
|
|
|
872
798
|
export const transformPlotlyJsonToAnnotationChartProps = (input, isMultiPlot, _colorMap, _colorwayType, _isDarkTheme)=>{
|
|
873
799
|
var _layoutWithMeta_meta, _input_layout, _input_layout1, _input_layout2, _input_layout3, _input_layout_font, _input_layout4, _input_layout_font1, _input_layout5, _input_layout6;
|
|
874
800
|
var _getChartAnnotationsFromLayout;
|
|
875
|
-
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.layout,
|
|
801
|
+
const annotations = (_getChartAnnotationsFromLayout = getChartAnnotationsFromLayout(input.layout, isMultiPlot)) !== null && _getChartAnnotationsFromLayout !== void 0 ? _getChartAnnotationsFromLayout : [];
|
|
876
802
|
const titles = getTitles(input.layout);
|
|
877
803
|
const layoutTitle = titles.chartTitle || undefined;
|
|
878
804
|
const layoutWithMeta = input.layout;
|
|
@@ -1128,7 +1054,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
1128
1054
|
}
|
|
1129
1055
|
});
|
|
1130
1056
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
1131
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1057
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1132
1058
|
var _input_layout_height;
|
|
1133
1059
|
return {
|
|
1134
1060
|
data: vsbcData,
|
|
@@ -1265,7 +1191,7 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
1265
1191
|
});
|
|
1266
1192
|
}
|
|
1267
1193
|
});
|
|
1268
|
-
const annotations = getChartAnnotationsFromLayout(processedInput.layout,
|
|
1194
|
+
const annotations = getChartAnnotationsFromLayout(processedInput.layout, isMultiPlot);
|
|
1269
1195
|
var _processedInput_layout_height;
|
|
1270
1196
|
return {
|
|
1271
1197
|
dataV2: gvbcDataV2,
|
|
@@ -1355,7 +1281,7 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
1355
1281
|
});
|
|
1356
1282
|
});
|
|
1357
1283
|
});
|
|
1358
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1284
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1359
1285
|
var _input_layout_height;
|
|
1360
1286
|
return {
|
|
1361
1287
|
data: vbcData,
|
|
@@ -1577,7 +1503,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
1577
1503
|
...lineShape
|
|
1578
1504
|
]
|
|
1579
1505
|
};
|
|
1580
|
-
const annotations = getChartAnnotationsFromLayout(input.layout,
|
|
1506
|
+
const annotations = getChartAnnotationsFromLayout(input.layout, isMultiPlot);
|
|
1581
1507
|
var _input_layout_height;
|
|
1582
1508
|
const commonProps = {
|
|
1583
1509
|
supportNegativeData: true,
|
|
@@ -1706,14 +1632,14 @@ export const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMa
|
|
|
1706
1632
|
// extract colors for each series only once
|
|
1707
1633
|
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
1708
1634
|
series.y.forEach((yVal, i)=>{
|
|
1709
|
-
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout,
|
|
1635
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_x;
|
|
1710
1636
|
if (isInvalidValue(yVal)) {
|
|
1711
1637
|
return;
|
|
1712
1638
|
}
|
|
1713
1639
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
1714
1640
|
const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, i, legend, colorMap, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, isDarkTheme);
|
|
1715
1641
|
const opacity = getOpacity(series, i);
|
|
1716
|
-
const base = +resolveGanttXValue((
|
|
1642
|
+
const base = +resolveGanttXValue(isArrayOrTypedArray(series.base) ? series.base[i] : series.base);
|
|
1717
1643
|
const xVal = +resolveGanttXValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
|
|
1718
1644
|
var _rgb_copy_formatHex8;
|
|
1719
1645
|
ganttData.push({
|
|
@@ -2930,7 +2856,7 @@ export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
|
2930
2856
|
}
|
|
2931
2857
|
const isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
2932
2858
|
if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
|
|
2933
|
-
result[propName] = ax.categoryarray;
|
|
2859
|
+
result[propName] = (ax === null || ax === void 0 ? void 0 : ax.autorange) === 'reversed' ? ax.categoryarray.slice().reverse() : ax.categoryarray;
|
|
2934
2860
|
return;
|
|
2935
2861
|
}
|
|
2936
2862
|
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|