@fluentui/react-charting 5.24.23 → 5.24.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +37 -1
- package/CHANGELOG.md +21 -2
- package/dist/react-charting.d.ts +59 -1
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +10 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +11 -5
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +167 -30
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.base.d.ts +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +66 -13
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.d.ts +4 -0
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +37 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/utilities.d.ts +17 -13
- package/lib/utilities/utilities.js +131 -17
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +11 -5
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +171 -35
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/FunnelChart/funnelGeometry.js +5 -6
- package/lib-amd/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.base.d.ts +1 -1
- package/lib-amd/components/ResponsiveContainer/withResponsiveContainer.js +1 -2
- package/lib-amd/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.base.js +4 -4
- package/lib-amd/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +64 -11
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +4 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-amd/index.d.ts +1 -1
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +37 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/image-export-utils.js +2 -3
- package/lib-amd/utilities/image-export-utils.js.map +1 -1
- package/lib-amd/utilities/scatterpolar-utils.js +2 -3
- package/lib-amd/utilities/scatterpolar-utils.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +17 -13
- package/lib-amd/utilities/utilities.js +170 -54
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +11 -5
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +171 -34
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js +5 -6
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.base.d.ts +1 -1
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js +1 -2
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js +4 -4
- package/lib-commonjs/components/SankeyChart/SankeyChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +64 -11
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +4 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +37 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +2 -3
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/scatterpolar-utils.js +2 -3
- package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +17 -13
- package/lib-commonjs/utilities/utilities.js +170 -55
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CommonComponents/CartesianChart.types.ts +19 -0
- package/src/components/ScatterChart/ScatterChart.types.ts +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartesianChart.types.js","sourceRoot":"../src/","sources":["components/CommonComponents/CartesianChart.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IOverflowSetProps } from '@fluentui/react/lib/OverflowSet';\nimport { IFocusZoneProps, FocusZoneDirection } from '@fluentui/react-focus';\nimport { ICalloutProps } from '@fluentui/react/lib/Callout';\nimport { ILegendsProps } from '../Legends/index';\nimport {\n AxisCategoryOrder,\n AxisScaleType,\n IAccessibilityProps,\n IChart,\n IDataPoint,\n IGanttChartDataPoint,\n IGroupedVerticalBarChartData,\n IHeatMapChartDataPoint,\n IHorizontalBarChartWithAxisDataPoint,\n ILineChartPoints,\n IMargins,\n IScatterChartPoints,\n IVerticalBarChartDataPoint,\n IVerticalStackedBarDataPoint,\n} from '../../types/index';\nimport { IChartHoverCardProps } from '../../utilities/index';\nimport { TimeLocaleDefinition } from 'd3-time-format';\nimport { ChartTypes, IAxisData, IDomainNRange, IYAxisParams, XAxisTypes, YAxisType } from '../../utilities/utilities';\nimport { ScaleBand, ScaleLinear } from 'd3-scale';\n\n/**\n * Cartesian Chart style properties\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartStyleProps {\n /**\n * Theme (provided through customization.)\n */\n theme: ITheme;\n\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 isRtl?: 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 */\n enableReflow?: boolean;\n}\n\n/**\n * Cartesian Chart styles\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartStyles {\n /**\n * Style for the root element.\n */\n root?: IStyle;\n\n /**\n * Style for the element containing the x-axis.\n */\n xAxis?: IStyle;\n\n /**\n * Style for the element containing the y-axis.\n */\n yAxis?: IStyle;\n\n /**\n * Style for legend container\n */\n legendContainer?: IStyle;\n\n /**\n * line hover box css\n */\n hover?: IStyle;\n\n /**\n * styles for callout root-content\n */\n calloutContentRoot?: IStyle;\n\n /**\n * styles for callout x-content\n */\n calloutContentX?: IStyle;\n\n /**\n * styles for callout y-content\n */\n calloutContentY?: IStyle;\n\n /**\n * styles for description message\n */\n descriptionMessage?: IStyle;\n\n /**\n * styles for callout Date time container\n */\n calloutDateTimeContainer?: IStyle;\n\n /**\n * styles for callout info container\n */\n calloutInfoContainer?: IStyle;\n\n /**\n * styles for callout block container\n */\n calloutBlockContainer?: IStyle;\n\n /**\n * styles for callout legend text\n */\n calloutlegendText?: IStyle;\n\n /**\n * styles for tooltip\n */\n tooltip?: IStyle;\n\n /**\n * styles for axis title\n */\n axisTitle?: IStyle;\n\n /**\n * styles for axis annotation\n */\n axisAnnotation?: IStyle;\n\n /**\n * Style for the chart Title.\n */\n chartTitle?: IStyle;\n\n /**\n * Style to change the opacity of bars in dataviz when we hover on a single bar or legends\n */\n opacityChangeOnHover?: IStyle;\n\n /**\n * styles for the shape object in the callout\n */\n shapeStyles?: IStyle;\n\n /**\n * Styles for the chart wrapper div\n */\n chartWrapper?: IStyle;\n\n /**\n * Styles for the svg tooltip\n */\n svgTooltip?: IStyle;\n\n /**\n * Styles for the chart svg element\n */\n chart?: IStyle;\n}\n\n/**\n * Cartesian Chart properties\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartProps {\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 * Theme (provided through customization.)\n */\n theme?: ITheme;\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?: IMargins;\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[];\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 * 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 * 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 /**\n * Label to apply to the whole chart.\n * @deprecated - Use your chart label for the chart.\n */\n chartLabel?: string;\n\n /**\n * overflow props for the legends\n */\n legendsOverflowProps?: Partial<IOverflowSetProps>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n legendsOverflowText?: any;\n\n /**\n * focus zone props in hover card for legends\n */\n focusZonePropsForLegendsInHoverCard?: IFocusZoneProps;\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<ILegendsProps>;\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?: IStyleFunctionOrObject<ICartesianChartStyleProps, ICartesianChartStyles>;\n\n /**\n * Callout customization props\n */\n calloutProps?: Partial<ICalloutProps>;\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 * @default True for LineChart but False for other charts\n */\n enableReflow?: boolean;\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?: boolean;\n\n /**\n * @default false\n * Used for enabling negative values in Y axis.\n */\n supportNegativeData?: boolean;\n\n /**\n * @default false\n * The prop used to decide rounded ticks on y axis\n */\n roundedTicks?: boolean;\n\n /**\n * Optional callback to access the IChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IChart>;\n\n /**\n * Determines whether overlapping x-axis tick labels should be hidden.\n * @default false\n */\n hideTickOverlap?: boolean;\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\nexport interface IYValueHover {\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?: IAccessibilityProps;\n}\n\nexport interface IChildProps {\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}\n\n// Only used for Cartesian chart base\nexport interface IModifiedCartesianChartProps extends ICartesianChartProps {\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n legendBars: JSX.Element | null;\n\n /**\n * Callout props\n */\n calloutProps: Partial<ICalloutProps> & {\n isCalloutVisible: boolean;\n id: string;\n YValueHover?: IYValueHover[];\n hoverXValue?: string | number | null;\n legend?: string;\n color?: string;\n YValue?: string | number;\n XValue?: string;\n descriptionMessage?: string;\n };\n\n /**\n * Callback method used for to get margins to the chart.\n */\n getmargins?: (margins: IMargins) => 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: IChildProps): React.ReactNode;\n\n /**\n * To enable callout for individualbar 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 * Focus zone direction to the chart\n * @default FocusZoneDirection.horizontal\n */\n focusZoneDirection?: FocusZoneDirection;\n\n /**\n * props to send into the chart hover card\n */\n chartHoverProps?: IChartHoverCardProps;\n\n /**\n * props to send to the focuszone\n */\n svgFocusZoneProps?: IFocusZoneProps;\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) => IMargins;\n\n /** Callback method to get extra margins for Y-axis domain */\n getYDomainMargins?: (containerHeight: number) => IMargins;\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 | ILineChartPoints[]\n | IHorizontalBarChartWithAxisDataPoint[]\n | IVerticalBarChartDataPoint[]\n | IDataPoint[]\n | IScatterChartPoints[]\n | IGanttChartDataPoint[],\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 useSecondaryYScale?: boolean,\n supportNegativeData?: boolean,\n roundedTicks?: boolean,\n scaleType?: AxisScaleType,\n ) => ScaleLinear<number, number, never>;\n\n /**\n * Get the domain and range values\n */\n getDomainNRangeValues: (\n points:\n | ILineChartPoints[]\n | IVerticalBarChartDataPoint[]\n | IVerticalStackedBarDataPoint[]\n | IHorizontalBarChartWithAxisDataPoint[]\n | IGroupedVerticalBarChartData[]\n | IHeatMapChartDataPoint[]\n | IGanttChartDataPoint[],\n margins: IMargins,\n width: number,\n chartType: ChartTypes,\n isRTL: boolean,\n xAxisType: XAxisTypes,\n barWidth: number,\n tickValues: Date[] | number[] | string[] | undefined,\n shiftX: number,\n ) => IDomainNRange;\n\n /**\n * Create the string y-axis\n */\n createStringYAxis: (\n yAxisParams: IYAxisParams,\n dataPoints: string[],\n isRtl: boolean,\n barWidth: number | undefined,\n chartType?: ChartTypes,\n ) => ScaleBand<string>;\n\n /**\n * Callback to access the public methods and properties of the component.\n */\n ref?: IRefObject<IChart>;\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"]}
|
|
1
|
+
{"version":3,"file":"CartesianChart.types.js","sourceRoot":"../src/","sources":["components/CommonComponents/CartesianChart.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { IRefObject, IStyleFunctionOrObject } from '@fluentui/react/lib/Utilities';\nimport { ITheme, IStyle } from '@fluentui/react/lib/Styling';\nimport { IOverflowSetProps } from '@fluentui/react/lib/OverflowSet';\nimport { IFocusZoneProps, FocusZoneDirection } from '@fluentui/react-focus';\nimport { ICalloutProps } from '@fluentui/react/lib/Callout';\nimport { ILegendsProps } from '../Legends/index';\nimport {\n AxisCategoryOrder,\n AxisProps,\n AxisScaleType,\n IAccessibilityProps,\n IChart,\n IDataPoint,\n IGanttChartDataPoint,\n IGroupedVerticalBarChartData,\n IHeatMapChartDataPoint,\n IHorizontalBarChartWithAxisDataPoint,\n ILineChartPoints,\n IMargins,\n IScatterChartPoints,\n IVerticalBarChartDataPoint,\n IVerticalStackedBarDataPoint,\n} from '../../types/index';\nimport { IChartHoverCardProps } from '../../utilities/index';\nimport { TimeLocaleDefinition } from 'd3-time-format';\nimport { ChartTypes, IAxisData, IDomainNRange, IYAxisParams, XAxisTypes, YAxisType } from '../../utilities/utilities';\nimport { ScaleBand, ScaleLinear } from 'd3-scale';\n\n/**\n * Cartesian Chart style properties\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartStyleProps {\n /**\n * Theme (provided through customization.)\n */\n theme: ITheme;\n\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 isRtl?: 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 */\n enableReflow?: boolean;\n}\n\n/**\n * Cartesian Chart styles\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartStyles {\n /**\n * Style for the root element.\n */\n root?: IStyle;\n\n /**\n * Style for the element containing the x-axis.\n */\n xAxis?: IStyle;\n\n /**\n * Style for the element containing the y-axis.\n */\n yAxis?: IStyle;\n\n /**\n * Style for legend container\n */\n legendContainer?: IStyle;\n\n /**\n * line hover box css\n */\n hover?: IStyle;\n\n /**\n * styles for callout root-content\n */\n calloutContentRoot?: IStyle;\n\n /**\n * styles for callout x-content\n */\n calloutContentX?: IStyle;\n\n /**\n * styles for callout y-content\n */\n calloutContentY?: IStyle;\n\n /**\n * styles for description message\n */\n descriptionMessage?: IStyle;\n\n /**\n * styles for callout Date time container\n */\n calloutDateTimeContainer?: IStyle;\n\n /**\n * styles for callout info container\n */\n calloutInfoContainer?: IStyle;\n\n /**\n * styles for callout block container\n */\n calloutBlockContainer?: IStyle;\n\n /**\n * styles for callout legend text\n */\n calloutlegendText?: IStyle;\n\n /**\n * styles for tooltip\n */\n tooltip?: IStyle;\n\n /**\n * styles for axis title\n */\n axisTitle?: IStyle;\n\n /**\n * styles for axis annotation\n */\n axisAnnotation?: IStyle;\n\n /**\n * Style for the chart Title.\n */\n chartTitle?: IStyle;\n\n /**\n * Style to change the opacity of bars in dataviz when we hover on a single bar or legends\n */\n opacityChangeOnHover?: IStyle;\n\n /**\n * styles for the shape object in the callout\n */\n shapeStyles?: IStyle;\n\n /**\n * Styles for the chart wrapper div\n */\n chartWrapper?: IStyle;\n\n /**\n * Styles for the svg tooltip\n */\n svgTooltip?: IStyle;\n\n /**\n * Styles for the chart svg element\n */\n chart?: IStyle;\n}\n\n/**\n * Cartesian Chart properties\n * {@docCategory CartesianChart}\n */\nexport interface ICartesianChartProps {\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 * Theme (provided through customization.)\n */\n theme?: ITheme;\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?: IMargins;\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[];\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 * 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 * 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 /**\n * Label to apply to the whole chart.\n * @deprecated - Use your chart label for the chart.\n */\n chartLabel?: string;\n\n /**\n * overflow props for the legends\n */\n legendsOverflowProps?: Partial<IOverflowSetProps>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n legendsOverflowText?: any;\n\n /**\n * focus zone props in hover card for legends\n */\n focusZonePropsForLegendsInHoverCard?: IFocusZoneProps;\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<ILegendsProps>;\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?: IStyleFunctionOrObject<ICartesianChartStyleProps, ICartesianChartStyles>;\n\n /**\n * Callout customization props\n */\n calloutProps?: Partial<ICalloutProps>;\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 * @default True for LineChart but False for other charts\n */\n enableReflow?: boolean;\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?: boolean;\n\n /**\n * @default false\n * Used for enabling negative values in Y axis.\n */\n supportNegativeData?: boolean;\n\n /**\n * @default false\n * The prop used to decide rounded ticks on y axis\n */\n roundedTicks?: boolean;\n\n /**\n * Optional callback to access the IChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IChart>;\n\n /**\n * Determines whether overlapping x-axis tick labels should be hidden.\n * @default false\n */\n hideTickOverlap?: boolean;\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\nexport interface IYValueHover {\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?: IAccessibilityProps;\n}\n\nexport interface IChildProps {\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}\n\n// Only used for Cartesian chart base\nexport interface IModifiedCartesianChartProps extends ICartesianChartProps {\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n legendBars: JSX.Element | null;\n\n /**\n * Callout props\n */\n calloutProps: Partial<ICalloutProps> & {\n isCalloutVisible: boolean;\n id: string;\n YValueHover?: IYValueHover[];\n hoverXValue?: string | number | null;\n legend?: string;\n color?: string;\n YValue?: string | number;\n XValue?: string;\n descriptionMessage?: string;\n };\n\n /**\n * Callback method used for to get margins to the chart.\n */\n getmargins?: (margins: IMargins) => 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: IChildProps): React.ReactNode;\n\n /**\n * To enable callout for individualbar 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 * Focus zone direction to the chart\n * @default FocusZoneDirection.horizontal\n */\n focusZoneDirection?: FocusZoneDirection;\n\n /**\n * props to send into the chart hover card\n */\n chartHoverProps?: IChartHoverCardProps;\n\n /**\n * props to send to the focuszone\n */\n svgFocusZoneProps?: IFocusZoneProps;\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) => IMargins;\n\n /** Callback method to get extra margins for Y-axis domain */\n getYDomainMargins?: (containerHeight: number) => IMargins;\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 | ILineChartPoints[]\n | IHorizontalBarChartWithAxisDataPoint[]\n | IVerticalBarChartDataPoint[]\n | IDataPoint[]\n | IScatterChartPoints[]\n | IGanttChartDataPoint[],\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 useSecondaryYScale?: boolean,\n supportNegativeData?: boolean,\n roundedTicks?: boolean,\n scaleType?: AxisScaleType,\n ) => ScaleLinear<number, number, never>;\n\n /**\n * Get the domain and range values\n */\n getDomainNRangeValues: (\n points:\n | ILineChartPoints[]\n | IVerticalBarChartDataPoint[]\n | IVerticalStackedBarDataPoint[]\n | IHorizontalBarChartWithAxisDataPoint[]\n | IGroupedVerticalBarChartData[]\n | IHeatMapChartDataPoint[]\n | IGanttChartDataPoint[],\n margins: IMargins,\n width: number,\n chartType: ChartTypes,\n isRTL: boolean,\n xAxisType: XAxisTypes,\n barWidth: number,\n tickValues: Date[] | number[] | string[] | undefined,\n shiftX: number,\n ) => IDomainNRange;\n\n /**\n * Create the string y-axis\n */\n createStringYAxis: (\n yAxisParams: IYAxisParams,\n dataPoints: string[],\n isRtl: boolean,\n barWidth: number | undefined,\n chartType?: ChartTypes,\n ) => ScaleBand<string>;\n\n /**\n * Callback to access the public methods and properties of the component.\n */\n ref?: IRefObject<IChart>;\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"]}
|
|
@@ -70,7 +70,7 @@ export declare const projectPolarToCartesian: (input: PlotlySchema) => PlotlySch
|
|
|
70
70
|
*/
|
|
71
71
|
export declare function findArrayAttributes(trace: any): void;
|
|
72
72
|
export declare const getAllupLegendsProps: (input: PlotlySchema, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, traceInfo: TraceInfo[], isDarkTheme?: boolean) => ILegendsProps;
|
|
73
|
-
export declare const getNumberAtIndexOrDefault: (data: PlotData[
|
|
73
|
+
export declare const getNumberAtIndexOrDefault: (data: PlotData["z"] | undefined, index: number) => number | undefined;
|
|
74
74
|
export declare const getValidXYRanges: (series: Partial<PlotData>) => [number, number][];
|
|
75
75
|
export declare const isNonPlotType: (chartType: string) => boolean;
|
|
76
76
|
export declare const getGridProperties: (schema: PlotlySchema | undefined, isMultiPlot: boolean, validTracesInfo: TraceInfo[]) => GridProperties;
|
|
@@ -4,11 +4,12 @@ import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
|
4
4
|
import { format as d3Format } from 'd3-format';
|
|
5
5
|
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
6
6
|
import { GaugeChartVariant } from '../GaugeChart/index';
|
|
7
|
-
import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
|
|
7
|
+
import { DEFAULT_DATE_STRING, findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS, } from '../../utilities/utilities';
|
|
8
8
|
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, isNumber, isObjectArray, getAxisIds, getAxisKey, } from '@fluentui/chart-utilities';
|
|
9
9
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
10
10
|
import { getOpacity, extractColor, resolveColor, createColorScale } from './PlotlyColorAdapter';
|
|
11
11
|
import { rgb } from 'd3-color';
|
|
12
|
+
import { calculatePrecision, precisionRound } from '@fluentui/react';
|
|
12
13
|
export var NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
13
14
|
export var SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
14
15
|
var dashOptions = {
|
|
@@ -451,7 +452,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
451
452
|
});
|
|
452
453
|
});
|
|
453
454
|
var vsbcData = Object.values(mapXToDataPoints);
|
|
454
|
-
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout));
|
|
455
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
|
|
455
456
|
};
|
|
456
457
|
export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
457
458
|
var _a, _b, _c, _d;
|
|
@@ -517,7 +518,7 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
|
|
|
517
518
|
});
|
|
518
519
|
});
|
|
519
520
|
var gvbcData = Object.values(mapXToDataPoints);
|
|
520
|
-
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ data: gvbcData, width: (_a = processedInput.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = processedInput.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = gvbcData[0]) === null || _d === void 0 ? void 0 : _d.name) === 'string' }), getTitles(processedInput.layout)), getAxisCategoryOrderProps(processedInput.data, processedInput.layout)), getYMinMaxValues(processedInput.data[0], processedInput.layout)), getXAxisTickFormat(processedInput.data[0], processedInput.layout)), yAxisTickFormat), getBarProps(processedInput.data, processedInput.layout));
|
|
521
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({ data: gvbcData, width: (_a = processedInput.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = processedInput.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = gvbcData[0]) === null || _d === void 0 ? void 0 : _d.name) === 'string' }), getTitles(processedInput.layout)), getAxisCategoryOrderProps(processedInput.data, processedInput.layout)), getYMinMaxValues(processedInput.data[0], processedInput.layout)), getXAxisTickFormat(processedInput.data[0], processedInput.layout)), yAxisTickFormat), getBarProps(processedInput.data, processedInput.layout)), getAxisTickProps(processedInput.data, processedInput.layout));
|
|
521
522
|
};
|
|
522
523
|
export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
523
524
|
var _a, _b, _c, _d;
|
|
@@ -677,12 +678,13 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
677
678
|
var scatterChartProps = {
|
|
678
679
|
scatterChartData: chartData,
|
|
679
680
|
};
|
|
680
|
-
var commonProps = __assign(__assign(__assign(__assign(__assign(__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout));
|
|
681
|
+
var commonProps = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
|
|
681
682
|
if (isAreaChart) {
|
|
682
683
|
return __assign({ data: chartProps, mode: mode }, commonProps);
|
|
683
684
|
}
|
|
684
685
|
else {
|
|
685
|
-
return __assign(__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax)
|
|
686
|
+
return __assign(__assign(__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax), (isScatterChart
|
|
687
|
+
? __assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {}));
|
|
686
688
|
}
|
|
687
689
|
};
|
|
688
690
|
export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -727,9 +729,9 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
|
|
|
727
729
|
var scalingFactor = 0.01;
|
|
728
730
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
729
731
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
730
|
-
return __assign(__assign(__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
732
|
+
return __assign(__assign(__assign(__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
731
733
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
732
|
-
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true));
|
|
734
|
+
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true)), getAxisTickProps(input.data, input.layout));
|
|
733
735
|
};
|
|
734
736
|
export var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
735
737
|
var _a, _b, _c;
|
|
@@ -775,7 +777,7 @@ export var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot,
|
|
|
775
777
|
.filter(function (point) { return point !== null; });
|
|
776
778
|
})
|
|
777
779
|
.flat();
|
|
778
|
-
return __assign(__assign(__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true));
|
|
780
|
+
return __assign(__assign(__assign(__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true)), getAxisTickProps(input.data, input.layout));
|
|
779
781
|
};
|
|
780
782
|
export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
781
783
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
@@ -889,7 +891,7 @@ export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, col
|
|
|
889
891
|
var rangeValuesForColorScale = Array.isArray(colorscale)
|
|
890
892
|
? colorscale.map(function (arr) { return arr[1]; })
|
|
891
893
|
: defaultRange;
|
|
892
|
-
return __assign(__assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: true }, getTitles(input.layout)), getAxisCategoryOrderProps([firstData], input.layout));
|
|
894
|
+
return __assign(__assign(__assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: true }, getTitles(input.layout)), getAxisCategoryOrderProps([firstData], input.layout)), getAxisTickProps(input.data, input.layout));
|
|
893
895
|
};
|
|
894
896
|
export var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
895
897
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -1518,7 +1520,7 @@ var createBins = function (data, binStart, binEnd, binSize) {
|
|
|
1518
1520
|
var binGenerator = d3Bin().domain([minVal, maxVal]);
|
|
1519
1521
|
if (typeof binSize === 'number' && binSize > 0) {
|
|
1520
1522
|
var thresholds = [];
|
|
1521
|
-
var precision = Math.max(
|
|
1523
|
+
var precision = Math.max(calculatePrecision(minVal), calculatePrecision(binSize));
|
|
1522
1524
|
var th = precisionRound(minVal, precision);
|
|
1523
1525
|
while (th < precisionRound(maxVal + binSize, precision)) {
|
|
1524
1526
|
thresholds.push(th);
|
|
@@ -1565,14 +1567,6 @@ var calculateHistNorm = function (histnorm, value, total, dx, dy) {
|
|
|
1565
1567
|
return value;
|
|
1566
1568
|
}
|
|
1567
1569
|
};
|
|
1568
|
-
var getPrecision = function (value) {
|
|
1569
|
-
var _a, _b;
|
|
1570
|
-
return (_b = (_a = value.toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
1571
|
-
};
|
|
1572
|
-
var precisionRound = function (value, precision) {
|
|
1573
|
-
var factor = Math.pow(10, precision);
|
|
1574
|
-
return Math.round(value * factor) / factor;
|
|
1575
|
-
};
|
|
1576
1570
|
var getLegendShape = function (series) {
|
|
1577
1571
|
var _a, _b;
|
|
1578
1572
|
var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
|
|
@@ -1950,7 +1944,128 @@ var getBarProps = function (data, layout, isHorizontal) {
|
|
|
1950
1944
|
};
|
|
1951
1945
|
};
|
|
1952
1946
|
var getAxisScaleTypeProps = function (data, layout) {
|
|
1947
|
+
var _a, _b, _c;
|
|
1953
1948
|
var result = {};
|
|
1949
|
+
var axisObjects = getAxisObjects(data, layout);
|
|
1950
|
+
if (((_a = axisObjects.x) === null || _a === void 0 ? void 0 : _a.type) === 'log') {
|
|
1951
|
+
result.xScaleType = 'log';
|
|
1952
|
+
}
|
|
1953
|
+
if (((_b = axisObjects.y) === null || _b === void 0 ? void 0 : _b.type) === 'log') {
|
|
1954
|
+
result.yScaleType = 'log';
|
|
1955
|
+
}
|
|
1956
|
+
if (((_c = axisObjects.y2) === null || _c === void 0 ? void 0 : _c.type) === 'log') {
|
|
1957
|
+
result.secondaryYScaleType = 'log';
|
|
1958
|
+
}
|
|
1959
|
+
return result;
|
|
1960
|
+
};
|
|
1961
|
+
/**
|
|
1962
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
|
|
1963
|
+
*/
|
|
1964
|
+
var getAxisTickProps = function (data, layout) {
|
|
1965
|
+
var props = {};
|
|
1966
|
+
var axisObjects = getAxisObjects(data, layout);
|
|
1967
|
+
Object.keys(axisObjects).forEach(function (axId) {
|
|
1968
|
+
var ax = axisObjects[axId];
|
|
1969
|
+
if (!ax) {
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
var axType = getAxisType(data, axId[0], ax);
|
|
1973
|
+
if ((!ax.tickmode || ax.tickmode === 'array') && isArrayOrTypedArray(ax.tickvals)) {
|
|
1974
|
+
var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
|
|
1975
|
+
if (axId === 'x') {
|
|
1976
|
+
props.tickValues = tickValues;
|
|
1977
|
+
}
|
|
1978
|
+
else if (axId === 'y') {
|
|
1979
|
+
props.yAxisTickValues = tickValues;
|
|
1980
|
+
}
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
|
|
1984
|
+
var dtick = plotlyDtick(ax.dtick, axType);
|
|
1985
|
+
var tick0 = plotlyTick0(ax.tick0, axType, dtick);
|
|
1986
|
+
if (axId === 'x') {
|
|
1987
|
+
props.xAxis = {
|
|
1988
|
+
tickStep: dtick,
|
|
1989
|
+
tick0: tick0,
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
else if (axId === 'y') {
|
|
1993
|
+
props.yAxis = {
|
|
1994
|
+
tickStep: dtick,
|
|
1995
|
+
tick0: tick0,
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
|
|
2001
|
+
if (axId === 'x') {
|
|
2002
|
+
props.xAxisTickCount = ax.nticks;
|
|
2003
|
+
}
|
|
2004
|
+
else if (axId === 'y') {
|
|
2005
|
+
props.yAxisTickCount = ax.nticks;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
});
|
|
2009
|
+
return props;
|
|
2010
|
+
};
|
|
2011
|
+
/**
|
|
2012
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
|
|
2013
|
+
*/
|
|
2014
|
+
var plotlyDtick = function (dtick, axType) {
|
|
2015
|
+
var isLogAx = axType === 'log';
|
|
2016
|
+
var isDateAx = axType === 'date';
|
|
2017
|
+
var isCatAx = axType === 'category';
|
|
2018
|
+
var dtickDflt = isDateAx ? 86400000 : 1;
|
|
2019
|
+
if (!dtick) {
|
|
2020
|
+
return dtickDflt;
|
|
2021
|
+
}
|
|
2022
|
+
if (isNumber(dtick)) {
|
|
2023
|
+
dtick = Number(dtick);
|
|
2024
|
+
if (dtick <= 0) {
|
|
2025
|
+
return dtickDflt;
|
|
2026
|
+
}
|
|
2027
|
+
if (isCatAx) {
|
|
2028
|
+
// category dtick must be positive integers
|
|
2029
|
+
return Math.max(1, Math.round(dtick));
|
|
2030
|
+
}
|
|
2031
|
+
if (isDateAx) {
|
|
2032
|
+
// date dtick must be at least 0.1ms (our current precision)
|
|
2033
|
+
return Math.max(0.1, dtick);
|
|
2034
|
+
}
|
|
2035
|
+
return dtick;
|
|
2036
|
+
}
|
|
2037
|
+
if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
|
|
2038
|
+
return dtickDflt;
|
|
2039
|
+
}
|
|
2040
|
+
var prefix = dtick.charAt(0);
|
|
2041
|
+
var dtickNum = isNumber(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
|
|
2042
|
+
if (dtickNum <= 0 ||
|
|
2043
|
+
!(
|
|
2044
|
+
// "M<n>" gives ticks every (integer) n months
|
|
2045
|
+
((isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum)) ||
|
|
2046
|
+
// "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
|
|
2047
|
+
(isLogAx && prefix === 'L') ||
|
|
2048
|
+
// "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
|
|
2049
|
+
(isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))))) {
|
|
2050
|
+
return dtickDflt;
|
|
2051
|
+
}
|
|
2052
|
+
return dtick;
|
|
2053
|
+
};
|
|
2054
|
+
/**
|
|
2055
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
|
|
2056
|
+
*/
|
|
2057
|
+
var plotlyTick0 = function (tick0, axType, dtick) {
|
|
2058
|
+
if (axType === 'date') {
|
|
2059
|
+
return isDate(tick0) ? new Date(tick0) : new Date(DEFAULT_DATE_STRING);
|
|
2060
|
+
}
|
|
2061
|
+
if (dtick === 'D1' || dtick === 'D2') {
|
|
2062
|
+
// D1 and D2 modes ignore tick0 entirely
|
|
2063
|
+
return undefined;
|
|
2064
|
+
}
|
|
2065
|
+
// Aside from date axes, tick0 must be numeric
|
|
2066
|
+
return isNumber(tick0) ? Number(tick0) : 0;
|
|
2067
|
+
};
|
|
2068
|
+
var getAxisObjects = function (data, layout) {
|
|
1954
2069
|
// Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
|
|
1955
2070
|
// are called with the corresponding filtered data. As a result, all traces passed to an adapter
|
|
1956
2071
|
// function share the same xaxis.
|
|
@@ -1961,21 +2076,43 @@ var getAxisScaleTypeProps = function (data, layout) {
|
|
|
1961
2076
|
xAxisId = axisIds.x;
|
|
1962
2077
|
yAxisIds.add(axisIds.y);
|
|
1963
2078
|
});
|
|
1964
|
-
var
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
return ((_a = layout === null || layout === void 0 ? void 0 : layout[axisKey]) === null || _a === void 0 ? void 0 : _a.type) === 'log';
|
|
1968
|
-
};
|
|
1969
|
-
if (typeof xAxisId === 'number' && isLogAxis('x', xAxisId)) {
|
|
1970
|
-
result.xScaleType = 'log';
|
|
2079
|
+
var axisObjects = {};
|
|
2080
|
+
if (typeof xAxisId === 'number') {
|
|
2081
|
+
axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('x', xAxisId)];
|
|
1971
2082
|
}
|
|
1972
2083
|
var sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
1973
|
-
if (sortedYAxisIds.length > 0
|
|
1974
|
-
|
|
2084
|
+
if (sortedYAxisIds.length > 0) {
|
|
2085
|
+
axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('y', sortedYAxisIds[0])];
|
|
1975
2086
|
}
|
|
1976
|
-
if (sortedYAxisIds.length > 1
|
|
1977
|
-
|
|
2087
|
+
if (sortedYAxisIds.length > 1) {
|
|
2088
|
+
axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('y', sortedYAxisIds[1])];
|
|
2089
|
+
}
|
|
2090
|
+
return axisObjects;
|
|
2091
|
+
};
|
|
2092
|
+
var getAxisType = function (data, axLetter, ax) {
|
|
2093
|
+
var values = [];
|
|
2094
|
+
data.forEach(function (series) {
|
|
2095
|
+
var _a;
|
|
2096
|
+
(_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
|
|
2097
|
+
if (!isInvalidValue(val)) {
|
|
2098
|
+
values.push(val);
|
|
2099
|
+
}
|
|
2100
|
+
});
|
|
2101
|
+
});
|
|
2102
|
+
// Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
|
|
2103
|
+
// Therefore, simply checking the type of the values may not be sufficient. At the moment,
|
|
2104
|
+
// we don’t always perform this casting ourselves and instead use the values as provided.
|
|
2105
|
+
if (isNumberArray(values)) {
|
|
2106
|
+
if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
|
|
2107
|
+
return 'log';
|
|
2108
|
+
}
|
|
2109
|
+
return 'linear';
|
|
2110
|
+
}
|
|
2111
|
+
if (isDateArray(values)) {
|
|
2112
|
+
return 'date';
|
|
2113
|
+
}
|
|
2114
|
+
if (isStringArray(values)) {
|
|
2115
|
+
return 'category';
|
|
1978
2116
|
}
|
|
1979
|
-
return result;
|
|
1980
2117
|
};
|
|
1981
2118
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|