stream-charts 1.0.1 → 1.1.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/README.md +757 -342
- package/changes.md +11 -0
- package/dist/src/app/charts/Chart.d.ts +116 -87
- package/dist/src/app/charts/Chart.js +96 -101
- package/dist/src/app/charts/Chart.js.map +1 -1
- package/dist/src/app/charts/axes/AxesState.d.ts +64 -0
- package/dist/src/app/charts/axes/AxesState.js +97 -0
- package/dist/src/app/charts/axes/AxesState.js.map +1 -0
- package/dist/src/app/charts/axes/AxesState.test.js +30 -0
- package/dist/src/app/charts/axes/AxesState.test.js.map +1 -0
- package/dist/src/app/charts/axes/AxisInterval.d.ts +92 -0
- package/dist/src/app/charts/axes/AxisInterval.js +126 -0
- package/dist/src/app/charts/axes/AxisInterval.js.map +1 -0
- package/dist/src/app/charts/axes/AxisInterval.test.js +120 -0
- package/dist/src/app/charts/axes/AxisInterval.test.js.map +1 -0
- package/dist/src/app/charts/axes/BaseAxisRange.d.ts +83 -0
- package/dist/src/app/charts/axes/BaseAxisRange.js +58 -0
- package/dist/src/app/charts/axes/BaseAxisRange.js.map +1 -0
- package/dist/src/app/charts/axes/ContinuousAxis.d.ts +22 -0
- package/dist/src/app/charts/axes/ContinuousAxis.js +96 -0
- package/dist/src/app/charts/axes/ContinuousAxis.js.map +1 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.d.ts +59 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.js +84 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.js.map +1 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.test.js +47 -0
- package/dist/src/app/charts/axes/ContinuousAxisRange.test.js.map +1 -0
- package/dist/src/app/charts/axes/OrdinalAxis.d.ts +23 -0
- package/dist/src/app/charts/axes/OrdinalAxis.js +124 -0
- package/dist/src/app/charts/axes/OrdinalAxis.js.map +1 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.d.ts +69 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.js +100 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.js.map +1 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.test.js +48 -0
- package/dist/src/app/charts/axes/OrdinalAxisRange.test.js.map +1 -0
- package/dist/src/app/charts/axes/axes.d.ts +391 -0
- package/dist/src/app/charts/axes/axes.js +1046 -0
- package/dist/src/app/charts/axes/axes.js.map +1 -0
- package/dist/src/app/charts/d3types.d.ts +10 -10
- package/dist/src/app/charts/filters/regexFilter.d.ts +9 -0
- package/dist/src/app/charts/filters/regexFilter.js +18 -0
- package/dist/src/app/charts/filters/regexFilter.js.map +1 -0
- package/dist/src/app/charts/filters/regexFilter.test.d.ts +1 -0
- package/dist/src/app/charts/filters/regexFilter.test.js +11 -0
- package/dist/src/app/charts/filters/regexFilter.test.js.map +1 -0
- package/dist/src/app/charts/hooks/useAxes.d.ts +144 -0
- package/dist/src/app/charts/hooks/useAxes.js +187 -0
- package/dist/src/app/charts/hooks/useAxes.js.map +1 -0
- package/dist/src/app/charts/hooks/useChart.d.ts +30 -201
- package/dist/src/app/charts/hooks/useChart.js +33 -134
- package/dist/src/app/charts/hooks/useChart.js.map +1 -1
- package/dist/src/app/charts/hooks/useDataObservable.d.ts +74 -0
- package/dist/src/app/charts/hooks/useDataObservable.js +76 -0
- package/dist/src/app/charts/hooks/useDataObservable.js.map +1 -0
- package/dist/src/app/charts/hooks/useInitialData.d.ts +38 -0
- package/dist/src/app/charts/hooks/useInitialData.js +29 -0
- package/dist/src/app/charts/hooks/useInitialData.js.map +1 -0
- package/dist/src/app/charts/hooks/useMouse.d.ts +53 -0
- package/dist/src/app/charts/hooks/useMouse.js +65 -0
- package/dist/src/app/charts/hooks/useMouse.js.map +1 -0
- package/dist/src/app/charts/hooks/usePlotDimensions.d.ts +34 -0
- package/dist/src/app/charts/hooks/usePlotDimensions.js +73 -0
- package/dist/src/app/charts/hooks/usePlotDimensions.js.map +1 -0
- package/dist/src/app/charts/hooks/useTooltip.d.ts +64 -0
- package/dist/src/app/charts/hooks/useTooltip.js +52 -0
- package/dist/src/app/charts/hooks/useTooltip.js.map +1 -0
- package/dist/src/app/charts/observables/ChartData.d.ts +23 -0
- package/dist/src/app/charts/observables/ChartData.js +20 -0
- package/dist/src/app/charts/observables/ChartData.js.map +1 -0
- package/dist/src/app/charts/observables/iterates.d.ts +52 -0
- package/dist/src/app/charts/observables/iterates.js +121 -0
- package/dist/src/app/charts/observables/iterates.js.map +1 -0
- package/dist/src/app/charts/observables/iterates.test.d.ts +1 -0
- package/dist/src/app/charts/observables/iterates.test.js +180 -0
- package/dist/src/app/charts/observables/iterates.test.js.map +1 -0
- package/dist/src/app/charts/observables/ordinals.d.ts +75 -0
- package/dist/src/app/charts/observables/ordinals.js +141 -0
- package/dist/src/app/charts/observables/ordinals.js.map +1 -0
- package/dist/src/app/charts/observables/ordinals.test.d.ts +1 -0
- package/dist/src/app/charts/observables/ordinals.test.js +102 -0
- package/dist/src/app/charts/observables/ordinals.test.js.map +1 -0
- package/dist/src/app/charts/plots/BarPlot.d.ts +81 -0
- package/dist/src/app/charts/plots/BarPlot.js +557 -0
- package/dist/src/app/charts/plots/BarPlot.js.map +1 -0
- package/dist/src/app/charts/plots/PoincarePlot.d.ts +78 -0
- package/dist/src/app/charts/plots/PoincarePlot.js +504 -0
- package/dist/src/app/charts/plots/PoincarePlot.js.map +1 -0
- package/dist/src/app/charts/{RasterPlot.d.ts → plots/RasterPlot.d.ts} +1 -1
- package/dist/src/app/charts/{RasterPlot.js → plots/RasterPlot.js} +152 -133
- package/dist/src/app/charts/plots/RasterPlot.js.map +1 -0
- package/dist/src/app/charts/{ScatterPlot.d.ts → plots/ScatterPlot.d.ts} +10 -8
- package/dist/src/app/charts/plots/ScatterPlot.js +379 -0
- package/dist/src/app/charts/plots/ScatterPlot.js.map +1 -0
- package/dist/src/app/charts/{plot.d.ts → plots/plot.d.ts} +12 -14
- package/dist/src/app/charts/{plot.js → plots/plot.js} +19 -17
- package/dist/src/app/charts/plots/plot.js.map +1 -0
- package/dist/src/app/charts/series/baseSeries.d.ts +38 -0
- package/dist/src/app/charts/series/baseSeries.js +36 -0
- package/dist/src/app/charts/series/baseSeries.js.map +1 -0
- package/dist/src/app/charts/series/datumSeries.test.d.ts +1 -0
- package/dist/src/app/charts/series/datumSeries.test.js +50 -0
- package/dist/src/app/charts/series/datumSeries.test.js.map +1 -0
- package/dist/src/app/charts/series/iterateSeries.d.ts +42 -0
- package/dist/src/app/charts/series/iterateSeries.js +34 -0
- package/dist/src/app/charts/series/iterateSeries.js.map +1 -0
- package/dist/src/app/charts/series/ordinalSeries.d.ts +54 -0
- package/dist/src/app/charts/series/ordinalSeries.js +98 -0
- package/dist/src/app/charts/series/ordinalSeries.js.map +1 -0
- package/dist/src/app/charts/series/timeSeries.d.ts +30 -0
- package/dist/src/app/charts/series/timeSeries.js +19 -0
- package/dist/src/app/charts/series/timeSeries.js.map +1 -0
- package/dist/src/app/charts/{chartData.d.ts → series/timeSeriesChartData.d.ts} +11 -6
- package/dist/src/app/charts/series/timeSeriesChartData.js +32 -0
- package/dist/src/app/charts/series/timeSeriesChartData.js.map +1 -0
- package/dist/src/app/charts/styling/barPlotStyle.d.ts +41 -0
- package/dist/src/app/charts/styling/barPlotStyle.js +84 -0
- package/dist/src/app/charts/styling/barPlotStyle.js.map +1 -0
- package/dist/src/app/charts/{margins.d.ts → styling/margins.d.ts} +7 -5
- package/dist/src/app/charts/{margins.js → styling/margins.js} +19 -9
- package/dist/src/app/charts/styling/margins.js.map +1 -0
- package/dist/src/app/charts/styling/margins.test.d.ts +1 -0
- package/dist/src/app/charts/styling/margins.test.js +19 -0
- package/dist/src/app/charts/styling/margins.test.js.map +1 -0
- package/dist/src/app/charts/styling/svgStyle.d.ts +76 -0
- package/dist/src/app/charts/styling/svgStyle.js +84 -0
- package/dist/src/app/charts/styling/svgStyle.js.map +1 -0
- package/dist/src/app/charts/subscriptions/subscription.test.d.ts +1 -0
- package/dist/src/app/charts/subscriptions/subscription.test.js +395 -0
- package/dist/src/app/charts/subscriptions/subscription.test.js.map +1 -0
- package/dist/src/app/charts/subscriptions/subscriptions.d.ts +100 -0
- package/dist/src/app/charts/subscriptions/subscriptions.js +449 -0
- package/dist/src/app/charts/subscriptions/subscriptions.js.map +1 -0
- package/dist/src/app/charts/tooltips/BarPlotTooltipContent.d.ts +90 -0
- package/dist/src/app/charts/tooltips/BarPlotTooltipContent.js +302 -0
- package/dist/src/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -0
- package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.d.ts +100 -0
- package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.js +190 -0
- package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -0
- package/dist/src/app/charts/{RasterPlotTooltipContent.js → tooltips/RasterPlotTooltipContent.js} +40 -44
- package/dist/src/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -0
- package/dist/src/app/charts/tooltips/ScatterPlotTooltipContent.js +154 -0
- package/dist/src/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -0
- package/dist/src/app/charts/{Tooltip.d.ts → tooltips/Tooltip.d.ts} +4 -2
- package/dist/src/app/charts/{Tooltip.js → tooltips/Tooltip.js} +23 -28
- package/dist/src/app/charts/tooltips/Tooltip.js.map +1 -0
- package/dist/src/app/charts/{tooltipUtils.d.ts → tooltips/tooltipUtils.d.ts} +11 -6
- package/dist/src/app/charts/{tooltipUtils.js → tooltips/tooltipUtils.js} +33 -17
- package/dist/src/app/charts/tooltips/tooltipUtils.js.map +1 -0
- package/dist/src/app/charts/{Tracker.d.ts → trackers/Tracker.d.ts} +6 -5
- package/dist/src/app/charts/trackers/Tracker.js +60 -0
- package/dist/src/app/charts/trackers/Tracker.js.map +1 -0
- package/dist/src/app/charts/{trackerUtils.d.ts → trackers/trackerUtils.d.ts} +13 -8
- package/dist/src/app/charts/trackers/trackerUtils.js +359 -0
- package/dist/src/app/charts/trackers/trackerUtils.js.map +1 -0
- package/dist/src/app/charts/utils.d.ts +22 -32
- package/dist/src/app/charts/utils.js +36 -37
- package/dist/src/app/charts/utils.js.map +1 -1
- package/dist/src/index.d.ts +48 -15
- package/dist/src/index.js +71 -15
- package/dist/src/index.js.map +1 -1
- package/package.json +30 -20
- package/src/app/charts/Chart.tsx +334 -0
- package/src/app/charts/axes/AxesState.test.ts +34 -0
- package/src/app/charts/axes/AxesState.ts +112 -0
- package/src/app/charts/axes/AxisInterval.test.ts +143 -0
- package/src/app/charts/axes/AxisInterval.ts +139 -0
- package/src/app/charts/axes/BaseAxisRange.ts +113 -0
- package/src/app/charts/axes/ContinuousAxis.tsx +192 -0
- package/src/app/charts/axes/ContinuousAxisRange.test.ts +55 -0
- package/src/app/charts/axes/ContinuousAxisRange.ts +96 -0
- package/src/app/charts/axes/OrdinalAxis.tsx +223 -0
- package/src/app/charts/axes/OrdinalAxisRange.test.ts +55 -0
- package/src/app/charts/axes/OrdinalAxisRange.ts +112 -0
- package/src/app/charts/axes/axes.ts +1569 -0
- package/src/app/charts/d3types.ts +16 -0
- package/src/app/charts/filters/regexFilter.test.ts +13 -0
- package/src/app/charts/filters/regexFilter.ts +17 -0
- package/src/app/charts/hooks/useAxes.tsx +341 -0
- package/src/app/charts/hooks/useChart.tsx +159 -0
- package/src/app/charts/hooks/useDataObservable.tsx +175 -0
- package/src/app/charts/hooks/useInitialData.tsx +65 -0
- package/src/app/charts/hooks/useMouse.tsx +125 -0
- package/src/app/charts/hooks/usePlotDimensions.tsx +120 -0
- package/src/app/charts/hooks/useTooltip.tsx +112 -0
- package/src/app/charts/observables/ChartData.ts +31 -0
- package/src/app/charts/observables/iterates.test.ts +201 -0
- package/src/app/charts/observables/iterates.ts +203 -0
- package/src/app/charts/observables/ordinals.test.ts +135 -0
- package/src/app/charts/observables/ordinals.ts +248 -0
- package/src/app/charts/plots/BarPlot.tsx +1088 -0
- package/src/app/charts/plots/PoincarePlot.tsx +832 -0
- package/src/app/charts/plots/RasterPlot.tsx +676 -0
- package/src/app/charts/plots/ScatterPlot.tsx +653 -0
- package/src/app/charts/plots/plot.ts +75 -0
- package/src/app/charts/series/baseSeries.ts +52 -0
- package/src/app/charts/series/datumSeries.test.ts +60 -0
- package/src/app/charts/series/iterateSeries.ts +56 -0
- package/src/app/charts/series/ordinalSeries.ts +164 -0
- package/src/app/charts/series/timeSeries.ts +40 -0
- package/src/app/charts/series/timeSeriesChartData.ts +68 -0
- package/src/app/charts/styling/barPlotStyle.ts +126 -0
- package/src/app/charts/styling/margins.test.ts +22 -0
- package/src/app/charts/styling/margins.ts +58 -0
- package/src/app/charts/styling/svgStyle.ts +118 -0
- package/src/app/charts/subscriptions/subscription.test.ts +499 -0
- package/src/app/charts/subscriptions/subscriptions.ts +635 -0
- package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +440 -0
- package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +352 -0
- package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +274 -0
- package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +319 -0
- package/src/app/charts/tooltips/Tooltip.tsx +148 -0
- package/src/app/charts/tooltips/tooltipUtils.ts +216 -0
- package/src/app/charts/trackers/Tracker.tsx +129 -0
- package/src/app/charts/trackers/trackerUtils.ts +494 -0
- package/src/app/charts/utils.ts +109 -0
- package/dist/src/app/charts/CategoryAxis.d.ts +0 -20
- package/dist/src/app/charts/CategoryAxis.js +0 -112
- package/dist/src/app/charts/CategoryAxis.js.map +0 -1
- package/dist/src/app/charts/ContinuousAxis.d.ts +0 -16
- package/dist/src/app/charts/ContinuousAxis.js +0 -186
- package/dist/src/app/charts/ContinuousAxis.js.map +0 -1
- package/dist/src/app/charts/RasterPlot.js.map +0 -1
- package/dist/src/app/charts/RasterPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/ScatterPlot.js +0 -351
- package/dist/src/app/charts/ScatterPlot.js.map +0 -1
- package/dist/src/app/charts/ScatterPlotTooltipContent.js +0 -163
- package/dist/src/app/charts/ScatterPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/Tooltip.js.map +0 -1
- package/dist/src/app/charts/Tracker.js +0 -65
- package/dist/src/app/charts/Tracker.js.map +0 -1
- package/dist/src/app/charts/axes.d.ts +0 -132
- package/dist/src/app/charts/axes.js +0 -265
- package/dist/src/app/charts/axes.js.map +0 -1
- package/dist/src/app/charts/chartData.js +0 -32
- package/dist/src/app/charts/chartData.js.map +0 -1
- package/dist/src/app/charts/continuousAxisRangeFor.d.ts +0 -20
- package/dist/src/app/charts/continuousAxisRangeFor.js +0 -68
- package/dist/src/app/charts/continuousAxisRangeFor.js.map +0 -1
- package/dist/src/app/charts/datumSeries.d.ts +0 -59
- package/dist/src/app/charts/datumSeries.js +0 -55
- package/dist/src/app/charts/datumSeries.js.map +0 -1
- package/dist/src/app/charts/datumSeries.test.js +0 -50
- package/dist/src/app/charts/datumSeries.test.js.map +0 -1
- package/dist/src/app/charts/hooks/AxesState.d.ts +0 -37
- package/dist/src/app/charts/hooks/AxesState.js +0 -44
- package/dist/src/app/charts/hooks/AxesState.js.map +0 -1
- package/dist/src/app/charts/margins.js.map +0 -1
- package/dist/src/app/charts/margins.test.js +0 -14
- package/dist/src/app/charts/margins.test.js.map +0 -1
- package/dist/src/app/charts/plot.js.map +0 -1
- package/dist/src/app/charts/regexFilter.d.ts +0 -9
- package/dist/src/app/charts/regexFilter.js +0 -17
- package/dist/src/app/charts/regexFilter.js.map +0 -1
- package/dist/src/app/charts/regexFilter.test.js +0 -11
- package/dist/src/app/charts/regexFilter.test.js.map +0 -1
- package/dist/src/app/charts/subscriptions.d.ts +0 -43
- package/dist/src/app/charts/subscriptions.js +0 -213
- package/dist/src/app/charts/subscriptions.js.map +0 -1
- package/dist/src/app/charts/svgStyle.d.ts +0 -27
- package/dist/src/app/charts/svgStyle.js +0 -32
- package/dist/src/app/charts/svgStyle.js.map +0 -1
- package/dist/src/app/charts/timeRange.test.js +0 -54
- package/dist/src/app/charts/timeRange.test.js.map +0 -1
- package/dist/src/app/charts/tooltipUtils.js.map +0 -1
- package/dist/src/app/charts/trackerUtils.js +0 -130
- package/dist/src/app/charts/trackerUtils.js.map +0 -1
- /package/dist/src/app/charts/{datumSeries.test.d.ts → axes/AxesState.test.d.ts} +0 -0
- /package/dist/src/app/charts/{margins.test.d.ts → axes/AxisInterval.test.d.ts} +0 -0
- /package/dist/src/app/charts/{regexFilter.test.d.ts → axes/ContinuousAxisRange.test.d.ts} +0 -0
- /package/dist/src/app/charts/{timeRange.test.d.ts → axes/OrdinalAxisRange.test.d.ts} +0 -0
- /package/dist/src/app/charts/{RasterPlotTooltipContent.d.ts → tooltips/RasterPlotTooltipContent.d.ts} +0 -0
- /package/dist/src/app/charts/{ScatterPlotTooltipContent.d.ts → tooltips/ScatterPlotTooltipContent.d.ts} +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AxesFont, AxisLocation } from "./axes";
|
|
2
|
+
import { ScaleContinuousNumeric } from "d3";
|
|
3
|
+
interface Props {
|
|
4
|
+
axisId: string;
|
|
5
|
+
location: AxisLocation;
|
|
6
|
+
scale?: ScaleContinuousNumeric<number, number>;
|
|
7
|
+
domain: [min: number, max: number];
|
|
8
|
+
font?: Partial<AxesFont>;
|
|
9
|
+
label: string;
|
|
10
|
+
updateAxisBasedOnDomainValues?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents a continuous numeric axis (x or y) that can be place on the top, bottom,
|
|
14
|
+
* left, or right of the chart. The domain (axis range) can be managed by this axis
|
|
15
|
+
* component or managed externally (i.e. deferred). This component returns null, meaning
|
|
16
|
+
* React won't render it because we are updating the SVG element and don't want React
|
|
17
|
+
* involved, except to call this function if the props change.
|
|
18
|
+
* @param props The properties for the axis
|
|
19
|
+
* @constructor
|
|
20
|
+
*/
|
|
21
|
+
export declare function ContinuousAxis(props: Props): null;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { addContinuousNumericXAxis, addContinuousNumericYAxis, AxisLocation, defaultAxesFont, labelIdFor } from "./axes";
|
|
2
|
+
import { useChart } from "../hooks/useChart";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import * as d3 from "d3";
|
|
5
|
+
import { usePlotDimensions } from "../hooks/usePlotDimensions";
|
|
6
|
+
import { AxisInterval } from "./AxisInterval";
|
|
7
|
+
import { ContinuousAxisRange } from "./ContinuousAxisRange";
|
|
8
|
+
/**
|
|
9
|
+
* Represents a continuous numeric axis (x or y) that can be place on the top, bottom,
|
|
10
|
+
* left, or right of the chart. The domain (axis range) can be managed by this axis
|
|
11
|
+
* component or managed externally (i.e. deferred). This component returns null, meaning
|
|
12
|
+
* React won't render it because we are updating the SVG element and don't want React
|
|
13
|
+
* involved, except to call this function if the props change.
|
|
14
|
+
* @param props The properties for the axis
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
export function ContinuousAxis(props) {
|
|
18
|
+
const { chartId, container, axes, color } = useChart();
|
|
19
|
+
const { xAxesState, yAxesState, addXAxis, addYAxis, axisRangeFor, setAxisIntervalFor, setAxisRangeFor, addAxesRangesUpdateHandler, } = axes;
|
|
20
|
+
const { plotDimensions, margin } = usePlotDimensions();
|
|
21
|
+
const { axisId, location, scale = d3.scaleLinear(), domain, updateAxisBasedOnDomainValues = true, label, } = props;
|
|
22
|
+
const axisRef = useRef(undefined);
|
|
23
|
+
const rangeUpdateHandlerIdRef = useRef(undefined);
|
|
24
|
+
const axisIdRef = useRef(axisId);
|
|
25
|
+
const marginRef = useRef(margin);
|
|
26
|
+
const domainRef = useRef(AxisInterval.as(domain));
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
axisIdRef.current = axisId;
|
|
29
|
+
marginRef.current = margin;
|
|
30
|
+
}, [axisId, plotDimensions, margin]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (container) {
|
|
33
|
+
const svg = d3.select(container);
|
|
34
|
+
const font = Object.assign(Object.assign(Object.assign({}, defaultAxesFont()), { color }), props.font);
|
|
35
|
+
const handleRangeUpdates = (updates, plotDim) => {
|
|
36
|
+
if (rangeUpdateHandlerIdRef.current && axisRef.current) {
|
|
37
|
+
const range = updates.get(axisId);
|
|
38
|
+
if (range) {
|
|
39
|
+
axisRef.current.update(range.current, plotDim, marginRef.current);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
if (axisRef.current === undefined) {
|
|
44
|
+
switch (location) {
|
|
45
|
+
case AxisLocation.Bottom:
|
|
46
|
+
case AxisLocation.Top: {
|
|
47
|
+
axisRef.current = addContinuousNumericXAxis(chartId, axisId, svg, plotDimensions, location, scale, domain, font, margin, label, setAxisIntervalFor);
|
|
48
|
+
// add the x-axis to the chart context
|
|
49
|
+
const [start, end] = AxisInterval.as(domain).asTuple();
|
|
50
|
+
addXAxis(axisRef.current, axisId, ContinuousAxisRange.from(start, end));
|
|
51
|
+
// addXAxis(axisRef.current, axisId, AxisInterval.as(domain))
|
|
52
|
+
// add an update handler
|
|
53
|
+
rangeUpdateHandlerIdRef.current = `x-axis-${chartId}-${location.valueOf()}`;
|
|
54
|
+
addAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current, handleRangeUpdates);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case AxisLocation.Left:
|
|
58
|
+
case AxisLocation.Right: {
|
|
59
|
+
axisRef.current = addContinuousNumericYAxis(chartId, axisId, svg, plotDimensions, location, scale, domain, font, margin, label, setAxisIntervalFor);
|
|
60
|
+
// add the y-axis to the chart context
|
|
61
|
+
const [start, end] = AxisInterval.as(domain).asTuple();
|
|
62
|
+
addYAxis(axisRef.current, axisId, ContinuousAxisRange.from(start, end));
|
|
63
|
+
// addYAxis(axisRef.current, axisId, AxisInterval.as(domain))
|
|
64
|
+
// add an update handler
|
|
65
|
+
rangeUpdateHandlerIdRef.current = `y-axis-${chartId}-${location.valueOf()}`;
|
|
66
|
+
addAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current, handleRangeUpdates);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const axisRange = axisRangeFor(axisId);
|
|
72
|
+
const domain = axisRange
|
|
73
|
+
.map(range => range.current)
|
|
74
|
+
.getOrElse(AxisInterval.empty());
|
|
75
|
+
if (domain.isNotEmpty()) {
|
|
76
|
+
axisRef.current.update(domain, plotDimensions, margin);
|
|
77
|
+
}
|
|
78
|
+
if ((updateAxisBasedOnDomainValues && (domainRef.current.start !== domain.start || domainRef.current.end !== domain.end)) ||
|
|
79
|
+
(!updateAxisBasedOnDomainValues && domainRef.current !== domain)) {
|
|
80
|
+
domainRef.current = domain;
|
|
81
|
+
axisRange.ifPresent(range => setAxisRangeFor(axisId, range.updateOriginal(domain.start, domain.end)));
|
|
82
|
+
}
|
|
83
|
+
svg.select(`#${labelIdFor(chartId, location)}`).attr('fill', color);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, [
|
|
87
|
+
chartId, axisId, label, location, props.font, xAxesState, yAxesState, addXAxis, addYAxis, domain,
|
|
88
|
+
scale, container, margin, plotDimensions, setAxisIntervalFor,
|
|
89
|
+
axisRangeFor,
|
|
90
|
+
addAxesRangesUpdateHandler,
|
|
91
|
+
setAxisRangeFor,
|
|
92
|
+
color, updateAxisBasedOnDomainValues
|
|
93
|
+
]);
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=ContinuousAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContinuousAxis.js","sourceRoot":"","sources":["../../../../../src/app/charts/axes/ContinuousAxis.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,yBAAyB,EACzB,yBAAyB,EAEzB,YAAY,EAEZ,eAAe,EACf,UAAU,EACb,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;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AO,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,CAAA;gBAC1D,CAAC;gBAED,IACI,CAAC,6BAA6B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC;oBACrH,CAAC,CAAC,6BAA6B,IAAI,SAAS,CAAC,OAAO,KAAK,MAAM,CAAC,EAClE,CAAC;oBACC,SAAS,CAAC,OAAO,GAAG,MAAM,CAAA;oBAC1B,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;gBAEzG,CAAC;gBAED,GAAG,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;YACvE,CAAC;QACL,CAAC;IACL,CAAC,EACD;QACI,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM;QAChG,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,kBAAkB;QAC5D,YAAY;QACZ,0BAA0B;QAC1B,eAAe;QACf,KAAK,EAAE,6BAA6B;KACvC,CACJ,CAAA;IAED,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseAxisRange } from "./BaseAxisRange";
|
|
2
|
+
/**
|
|
3
|
+
* An immutable continuous-axis range that holds the current range and the original (no zoom) range.
|
|
4
|
+
* Create an instance using the {@link ContinuousAxisRange.from} factory method.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ContinuousAxisRange extends BaseAxisRange {
|
|
7
|
+
private constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Factory function for creating a new continuous-axis range instance.
|
|
10
|
+
* @param start The start of the axis-range.
|
|
11
|
+
* @param end The end of the axis-range.
|
|
12
|
+
* @param [originalStart=start] The optional original start of the axis-range (e.g. before any zooming or panning.
|
|
13
|
+
* Defaults to the start value if not specified.)
|
|
14
|
+
* @param [originalEnd=end] The optional original end of the axis-range (e.g. before any zooming or panning.
|
|
15
|
+
* Defaults to the end value if not specified.)
|
|
16
|
+
* @return A new continuous-axis range instance.
|
|
17
|
+
*/
|
|
18
|
+
static from(start: number, end: number, originalStart?: number, originalEnd?: number): ContinuousAxisRange;
|
|
19
|
+
/**
|
|
20
|
+
* Scales the axis-range by the specified scale factor from the specified value. The equations
|
|
21
|
+
* are written so that the zooming (scaling) occurs at the specified value and expands/contracts equally
|
|
22
|
+
* from that value.
|
|
23
|
+
* @param factor The scale factor
|
|
24
|
+
* @param value The value from which to scale the interval
|
|
25
|
+
* @return A new continuous-axis range with updated values
|
|
26
|
+
*/
|
|
27
|
+
scale(factor: number, value: number): ContinuousAxisRange;
|
|
28
|
+
/**
|
|
29
|
+
* Scales the axis-range by the specified scale factor from the specified value, while keeping
|
|
30
|
+
* the range within the constraints (start, end). The equations are written so that the zooming
|
|
31
|
+
* (scaling) occurs at the specified value, and expands/contracts equally from that value.
|
|
32
|
+
* @param factor The scale factor
|
|
33
|
+
* @param value The value from which to scale the interval
|
|
34
|
+
* @param constraint The minimum and maximum values that range bounds can be
|
|
35
|
+
* @return A new continuous-axis range with updated values
|
|
36
|
+
*/
|
|
37
|
+
constrainedScale(factor: number, value: number, constraint: [min: number, max: number]): BaseAxisRange;
|
|
38
|
+
/**
|
|
39
|
+
* Translates the axis-range by the specified amount
|
|
40
|
+
* @param amount The amount by which to translate the axis-range
|
|
41
|
+
* @param [constraint=[-Infinity, Infinity]] Optional constraint interval in which the axis range must be within
|
|
42
|
+
* @return An updated {@link ContinuousAxisRange} that has been translated by the specified amount
|
|
43
|
+
*/
|
|
44
|
+
translate(amount: number, constraint?: [start: number, end: number]): ContinuousAxisRange;
|
|
45
|
+
/**
|
|
46
|
+
* Updates the axis-range with the new start and end values, leaving the original range unchanged.
|
|
47
|
+
* @param start The new start of the axis-range
|
|
48
|
+
* @param end The new end of the axis range
|
|
49
|
+
* @return The updated axis-range type, with all other values unchanged.
|
|
50
|
+
*/
|
|
51
|
+
update(start: number, end: number): ContinuousAxisRange;
|
|
52
|
+
/**
|
|
53
|
+
* Updates the original range with the new start and end values.
|
|
54
|
+
* @param start The new value for the start of the original range
|
|
55
|
+
* @param end The new value for the end of the original range
|
|
56
|
+
* @return The updated original range.
|
|
57
|
+
*/
|
|
58
|
+
updateOriginal(start: number, end: number): BaseAxisRange;
|
|
59
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BaseAxisRange } from "./BaseAxisRange";
|
|
2
|
+
/**
|
|
3
|
+
* An immutable continuous-axis range that holds the current range and the original (no zoom) range.
|
|
4
|
+
* Create an instance using the {@link ContinuousAxisRange.from} factory method.
|
|
5
|
+
*/
|
|
6
|
+
export class ContinuousAxisRange extends BaseAxisRange {
|
|
7
|
+
constructor(start, end, originalStart = start, originalEnd = end) {
|
|
8
|
+
super(start, end, originalStart, originalEnd);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Factory function for creating a new continuous-axis range instance.
|
|
12
|
+
* @param start The start of the axis-range.
|
|
13
|
+
* @param end The end of the axis-range.
|
|
14
|
+
* @param [originalStart=start] The optional original start of the axis-range (e.g. before any zooming or panning.
|
|
15
|
+
* Defaults to the start value if not specified.)
|
|
16
|
+
* @param [originalEnd=end] The optional original end of the axis-range (e.g. before any zooming or panning.
|
|
17
|
+
* Defaults to the end value if not specified.)
|
|
18
|
+
* @return A new continuous-axis range instance.
|
|
19
|
+
*/
|
|
20
|
+
static from(start, end, originalStart = start, originalEnd = end) {
|
|
21
|
+
return new ContinuousAxisRange(start, end, originalStart, originalEnd);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Scales the axis-range by the specified scale factor from the specified value. The equations
|
|
25
|
+
* are written so that the zooming (scaling) occurs at the specified value and expands/contracts equally
|
|
26
|
+
* from that value.
|
|
27
|
+
* @param factor The scale factor
|
|
28
|
+
* @param value The value from which to scale the interval
|
|
29
|
+
* @return A new continuous-axis range with updated values
|
|
30
|
+
*/
|
|
31
|
+
scale(factor, value) {
|
|
32
|
+
const scaledInterval = this.scaledRange(factor, value);
|
|
33
|
+
return new ContinuousAxisRange(scaledInterval.start, scaledInterval.end, this.original.start, this.original.end);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Scales the axis-range by the specified scale factor from the specified value, while keeping
|
|
37
|
+
* the range within the constraints (start, end). The equations are written so that the zooming
|
|
38
|
+
* (scaling) occurs at the specified value, and expands/contracts equally from that value.
|
|
39
|
+
* @param factor The scale factor
|
|
40
|
+
* @param value The value from which to scale the interval
|
|
41
|
+
* @param constraint The minimum and maximum values that range bounds can be
|
|
42
|
+
* @return A new continuous-axis range with updated values
|
|
43
|
+
*/
|
|
44
|
+
constrainedScale(factor, value, constraint) {
|
|
45
|
+
const scaledInterval = this.scaledRange(factor, value);
|
|
46
|
+
const [min, max] = constraint;
|
|
47
|
+
return new ContinuousAxisRange(Math.max(min, scaledInterval.start), Math.min(max, scaledInterval.end), this.original.start, this.original.end);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Translates the axis-range by the specified amount
|
|
51
|
+
* @param amount The amount by which to translate the axis-range
|
|
52
|
+
* @param [constraint=[-Infinity, Infinity]] Optional constraint interval in which the axis range must be within
|
|
53
|
+
* @return An updated {@link ContinuousAxisRange} that has been translated by the specified amount
|
|
54
|
+
*/
|
|
55
|
+
translate(amount, constraint = [-Infinity, Infinity]) {
|
|
56
|
+
const [cs, ce] = constraint;
|
|
57
|
+
// when either of the constraints is infinite, or the pan keeps the new axis range
|
|
58
|
+
// within the origin axis range (i.e. zoomed in and the panned), then allow the pan,
|
|
59
|
+
// otherwise don't update
|
|
60
|
+
if ((!isFinite(cs) && !isFinite(ce)) || (this.current.start + amount >= cs && this.current.end + amount <= ce)) {
|
|
61
|
+
return new ContinuousAxisRange(this.current.start + amount, this.current.end + amount, this.original.start, this.original.end);
|
|
62
|
+
}
|
|
63
|
+
return new ContinuousAxisRange(this.current.start, this.current.end, this.original.start, this.original.end);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Updates the axis-range with the new start and end values, leaving the original range unchanged.
|
|
67
|
+
* @param start The new start of the axis-range
|
|
68
|
+
* @param end The new end of the axis range
|
|
69
|
+
* @return The updated axis-range type, with all other values unchanged.
|
|
70
|
+
*/
|
|
71
|
+
update(start, end) {
|
|
72
|
+
return new ContinuousAxisRange(start, end, this.original.start, this.original.end);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Updates the original range with the new start and end values.
|
|
76
|
+
* @param start The new value for the start of the original range
|
|
77
|
+
* @param end The new value for the end of the original range
|
|
78
|
+
* @return The updated original range.
|
|
79
|
+
*/
|
|
80
|
+
updateOriginal(start, end) {
|
|
81
|
+
return new ContinuousAxisRange(this.current.start, this.current.end, start, end);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=ContinuousAxisRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContinuousAxisRange.js","sourceRoot":"","sources":["../../../../../src/app/charts/axes/ContinuousAxisRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAElD,YAAoB,KAAa,EAAE,GAAW,EAAE,gBAAwB,KAAK,EAAE,cAAsB,GAAG;QACpG,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,aAAa,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C,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,MAAM,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;YAC7G,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QAClI,CAAC;QACD,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAChH,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAa,EAAE,GAAW;QAC7B,OAAO,IAAI,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IACtF,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,KAAa,EAAE,GAAW;QACrC,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;IACpF,CAAC;CACJ"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ContinuousAxisRange } from "./ContinuousAxisRange";
|
|
2
|
+
test('creates a time-range', () => {
|
|
3
|
+
const timeRange = ContinuousAxisRange.from(10, 100);
|
|
4
|
+
expect(timeRange.current).toEqual({ start: 10, end: 100 });
|
|
5
|
+
expect(timeRange.scaleFactor).toBe(1);
|
|
6
|
+
});
|
|
7
|
+
test('scaling a time-range', () => {
|
|
8
|
+
const timeRange = ContinuousAxisRange.from(0, 100).scale(2, 50);
|
|
9
|
+
// the midpoint must remain at 50, so the new range will be 50 - 2 * (50 - 0) to
|
|
10
|
+
// 50 + 2 * (100 - 50) => (-50, 150)
|
|
11
|
+
expect(timeRange.current).toEqual({ start: -50, end: 150 });
|
|
12
|
+
expect(timeRange.scaleFactor).toBe(2);
|
|
13
|
+
// setting the scale factor back to 1, from its current value of 2 should
|
|
14
|
+
// return the original time-range (this may be a bit unintuitive, because it
|
|
15
|
+
// may seem like we should pass in a factor of 0.5 to shrink the scale back, but
|
|
16
|
+
// that would mean the new interval has a scale factor 4 times smaller.)
|
|
17
|
+
// this behavior is implemented so that zooming in at out from a point seems
|
|
18
|
+
// natural to the user.
|
|
19
|
+
const original = timeRange.scale(1, 50);
|
|
20
|
+
expect(original.current).toEqual({ start: 0, end: 100 });
|
|
21
|
+
expect(original.scaleFactor).toBe(1);
|
|
22
|
+
// the original shouldn't be changed
|
|
23
|
+
expect(timeRange.current).toEqual({ start: -50, end: 150 });
|
|
24
|
+
expect(timeRange.scaleFactor).toBe(2);
|
|
25
|
+
});
|
|
26
|
+
test('translating a time-range', () => {
|
|
27
|
+
const timeRange = ContinuousAxisRange.from(0, 100).translate(50);
|
|
28
|
+
expect(timeRange.current).toEqual({ start: 50, end: 150 });
|
|
29
|
+
expect(timeRange.scaleFactor).toBe(1);
|
|
30
|
+
});
|
|
31
|
+
test('scaling and translating', () => {
|
|
32
|
+
const original = ContinuousAxisRange.from(0, 100);
|
|
33
|
+
const scaled = original.scale(2, 50);
|
|
34
|
+
const translated = scaled.translate(50);
|
|
35
|
+
expect(translated.current).toEqual({ start: 0, end: 200 });
|
|
36
|
+
expect(translated.scaleFactor).toBe(2);
|
|
37
|
+
// after the translation, the time-range should shrink around the new time
|
|
38
|
+
const rescaled = translated.scale(1, 100);
|
|
39
|
+
expect(rescaled.current).toEqual({ start: 50, end: 150 });
|
|
40
|
+
expect(rescaled.scaleFactor).toBe(1);
|
|
41
|
+
// the original interval, maintained by each new time-range, should not change
|
|
42
|
+
expect(original.matchesOriginal(0, 100)).toEqual(true);
|
|
43
|
+
expect(scaled.matchesOriginal(0, 100)).toEqual(true);
|
|
44
|
+
expect(translated.matchesOriginal(0, 100)).toEqual(true);
|
|
45
|
+
expect(rescaled.matchesOriginal(0, 100)).toEqual(true);
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=ContinuousAxisRange.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContinuousAxisRange.test.js","sourceRoot":"","sources":["../../../../../src/app/charts/axes/ContinuousAxisRange.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAG1D,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAC9B,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACpD,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAC,CAAC,CAAC;IACzD,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAC9B,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChE,gFAAgF;IAChF,oCAAoC;IACpC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAC,CAAC,CAAA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
|
+
interface Props {
|
|
4
|
+
axisId: string;
|
|
5
|
+
location: AxisLocation;
|
|
6
|
+
scale?: ScaleBand<string>;
|
|
7
|
+
categories: Array<string>;
|
|
8
|
+
font?: Partial<AxesFont>;
|
|
9
|
+
axisTickStyle?: Partial<AxisTickStyle>;
|
|
10
|
+
label: string;
|
|
11
|
+
updateAxisBasedOnDomainValues?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Category axis that represents the x-axis when its location is either on the bottom or the top.
|
|
15
|
+
* When the axis location is left or right, then the category axis represents the y-axis. The category
|
|
16
|
+
* axis requires a set of categories that will form the axis. Generally, these categories should
|
|
17
|
+
* be the name of the series used to represent each category.
|
|
18
|
+
* @param props The properties for the component
|
|
19
|
+
* @return null
|
|
20
|
+
* @constructor
|
|
21
|
+
*/
|
|
22
|
+
export declare function OrdinalAxis(props: Props): null;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { addOrdinalStringAxis, AxisLocation, defaultAxesFont, defaultAxisTickStyle, labelIdFor } from "./axes";
|
|
2
|
+
import * as d3 from "d3";
|
|
3
|
+
import { useChart } from "../hooks/useChart";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { usePlotDimensions } from "../hooks/usePlotDimensions";
|
|
6
|
+
import { OrdinalAxisRange } from "./OrdinalAxisRange";
|
|
7
|
+
import { AxisInterval } from "./AxisInterval";
|
|
8
|
+
/**
|
|
9
|
+
* Category axis that represents the x-axis when its location is either on the bottom or the top.
|
|
10
|
+
* When the axis location is left or right, then the category axis represents the y-axis. The category
|
|
11
|
+
* axis requires a set of categories that will form the axis. Generally, these categories should
|
|
12
|
+
* be the name of the series used to represent each category.
|
|
13
|
+
* @param props The properties for the component
|
|
14
|
+
* @return null
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
export function OrdinalAxis(props) {
|
|
18
|
+
const { chartId, container, axes, color, } = useChart();
|
|
19
|
+
const { xAxesState, yAxesState, addXAxis, addYAxis, setAxisIntervalFor, axisRangeFor, addAxesRangesUpdateHandler, setOriginalAxisIntervalFor, } = axes;
|
|
20
|
+
const { plotDimensions, margin, registerPlotDimensionChangeHandler, unregisterPlotDimensionChangeHandler } = usePlotDimensions();
|
|
21
|
+
const { axisId, location, categories, updateAxisBasedOnDomainValues = true, label, } = props;
|
|
22
|
+
const rangeUpdateHandlerIdRef = useRef(undefined);
|
|
23
|
+
const axis = location === AxisLocation.Top || location === AxisLocation.Bottom ?
|
|
24
|
+
xAxesState.axisFor(axisId).getOrUndefined() :
|
|
25
|
+
yAxesState.axisFor(axisId).getOrUndefined();
|
|
26
|
+
// handles plot size changes by updating the range of the axis and the original range of the axis
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (container) {
|
|
29
|
+
const svg = d3.select(container);
|
|
30
|
+
const font = Object.assign(Object.assign(Object.assign({}, defaultAxesFont()), { color }), props.font);
|
|
31
|
+
const axisTickStyle = Object.assign(Object.assign({}, defaultAxisTickStyle()), props.axisTickStyle);
|
|
32
|
+
// lambda that gets called when the axes need to be updated
|
|
33
|
+
const handleRangeUpdates = (updates, plotDim) => {
|
|
34
|
+
if (rangeUpdateHandlerIdRef.current && axis) {
|
|
35
|
+
const range = updates.get(axisId);
|
|
36
|
+
if (range) {
|
|
37
|
+
axis.update(range.current, range.original, plotDim, margin);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (axis === undefined) {
|
|
42
|
+
// add the x-axis or y-axis to the chart context depending on its
|
|
43
|
+
// location
|
|
44
|
+
switch (location) {
|
|
45
|
+
case AxisLocation.Top:
|
|
46
|
+
case AxisLocation.Bottom: {
|
|
47
|
+
const xAxis = addOrdinalStringAxis(chartId, axisId, svg, location, categories, label, font, axisTickStyle, plotDimensions, margin, setAxisIntervalFor, setOriginalAxisIntervalFor);
|
|
48
|
+
// add the x-axis to the chart context
|
|
49
|
+
const [start, end] = AxisInterval.as(xAxis.scale.range()).asTuple();
|
|
50
|
+
addXAxis(xAxis, axisId, OrdinalAxisRange.from(start, end));
|
|
51
|
+
// add an update handler
|
|
52
|
+
rangeUpdateHandlerIdRef.current = `x-axis-${chartId}-${location.valueOf()}`;
|
|
53
|
+
addAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current, handleRangeUpdates);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case AxisLocation.Left:
|
|
57
|
+
case AxisLocation.Right: {
|
|
58
|
+
const yAxis = addOrdinalStringAxis(chartId, axisId, svg, location, categories, label, font, axisTickStyle, plotDimensions, margin, setAxisIntervalFor, setOriginalAxisIntervalFor);
|
|
59
|
+
// add the y-axis to the chart context
|
|
60
|
+
const [start, end] = AxisInterval.as(yAxis.scale.range()).asTuple();
|
|
61
|
+
addYAxis(yAxis, axisId, OrdinalAxisRange.from(start, end));
|
|
62
|
+
// add an update handler
|
|
63
|
+
rangeUpdateHandlerIdRef.current = `y-axis-${chartId}-${location.valueOf()}`;
|
|
64
|
+
addAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current, handleRangeUpdates);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const [range, originalRange] = axisRangeFor(axisId)
|
|
70
|
+
.map(range => ([range.current, range.original]))
|
|
71
|
+
.getOrElse([AxisInterval.empty(), AxisInterval.empty()]);
|
|
72
|
+
if (range && originalRange) {
|
|
73
|
+
axis.update(range, originalRange, plotDimensions, margin);
|
|
74
|
+
}
|
|
75
|
+
svg.select(`#${labelIdFor(chartId, location)}`).attr('fill', color);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, [
|
|
79
|
+
container,
|
|
80
|
+
axis,
|
|
81
|
+
addXAxis, addYAxis,
|
|
82
|
+
addAxesRangesUpdateHandler,
|
|
83
|
+
setAxisIntervalFor, setOriginalAxisIntervalFor, axisRangeFor,
|
|
84
|
+
xAxesState, yAxesState,
|
|
85
|
+
updateAxisBasedOnDomainValues,
|
|
86
|
+
chartId, axisId,
|
|
87
|
+
categories,
|
|
88
|
+
color, label, location, margin, plotDimensions, props.axisTickStyle, props.font,
|
|
89
|
+
]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const handlerId = registerPlotDimensionChangeHandler((oldDimension, newDimension) => {
|
|
92
|
+
if (axis !== undefined) {
|
|
93
|
+
if (location === AxisLocation.Top || location === AxisLocation.Bottom) {
|
|
94
|
+
const [start, end] = axisRangeFor(axisId)
|
|
95
|
+
.map(range => range.current.asTuple())
|
|
96
|
+
.getOrElse(AxisInterval.empty().asTuple());
|
|
97
|
+
const { current, original } = OrdinalAxisRange
|
|
98
|
+
.from(start, end, 0, oldDimension.width)
|
|
99
|
+
.zoom(oldDimension.width, newDimension.width);
|
|
100
|
+
axis.update(current, original, plotDimensions, margin);
|
|
101
|
+
}
|
|
102
|
+
if (location === AxisLocation.Left || location === AxisLocation.Right) {
|
|
103
|
+
const [start, end] = axisRangeFor(axisId)
|
|
104
|
+
.map(range => range.current.asTuple())
|
|
105
|
+
.getOrElse(AxisInterval.empty().asTuple());
|
|
106
|
+
const { current, original } = OrdinalAxisRange
|
|
107
|
+
.from(start, end, 0, oldDimension.height)
|
|
108
|
+
.zoom(oldDimension.height, newDimension.height);
|
|
109
|
+
axis.update(current, original, plotDimensions, margin);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return () => {
|
|
114
|
+
unregisterPlotDimensionChangeHandler(handlerId);
|
|
115
|
+
};
|
|
116
|
+
}, [
|
|
117
|
+
axis,
|
|
118
|
+
axisRangeFor, setAxisIntervalFor, setOriginalAxisIntervalFor,
|
|
119
|
+
axisId, location, margin,
|
|
120
|
+
plotDimensions, registerPlotDimensionChangeHandler, unregisterPlotDimensionChangeHandler,
|
|
121
|
+
]);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=OrdinalAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
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AAE,MAAM;QACxB,cAAc,EAAE,kCAAkC,EAAE,oCAAoC;KAC3F,CACJ,CAAC;IAEF,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { BaseAxisRange } from "./BaseAxisRange";
|
|
2
|
+
/**
|
|
3
|
+
* An immutable ordinal-axis range that holds the current range and the original (no zoom) range.
|
|
4
|
+
* Create an instance using the {@link OrdinalAxisRange.from} factory method.
|
|
5
|
+
*/
|
|
6
|
+
export declare class OrdinalAxisRange extends BaseAxisRange {
|
|
7
|
+
private constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Factory function for creating a new ordinal-axis range instance.
|
|
10
|
+
* @param start The start of the axis-range.
|
|
11
|
+
* @param end The end of the axis-range.
|
|
12
|
+
* @param [originalStart=start] The optional original start of the axis-range (e.g. before any zooming or panning.
|
|
13
|
+
* Defaults to the start value if not specified.)
|
|
14
|
+
* @param [originalEnd=end] The optional original end of the axis-range (e.g. before any zooming or panning.
|
|
15
|
+
* Defaults to the end value if not specified.)
|
|
16
|
+
* @return A new continuous-axis range instance.
|
|
17
|
+
*/
|
|
18
|
+
static from(start: number, end: number, originalStart?: number, originalEnd?: number): OrdinalAxisRange;
|
|
19
|
+
/**
|
|
20
|
+
* Scales the axis-range by the specified scale factor from the specified value. The equations
|
|
21
|
+
* are written so that the zooming (scaling) occurs at the specified value, and expands/contracts equally
|
|
22
|
+
* from that value. This operation does not modify the original range.
|
|
23
|
+
* @param factor The scale factor
|
|
24
|
+
* @param value The value from which to scale the interval
|
|
25
|
+
* @return A new continuous-axis range with updated values
|
|
26
|
+
*/
|
|
27
|
+
scale(factor: number, value: number): OrdinalAxisRange;
|
|
28
|
+
/**
|
|
29
|
+
* Scales the axis-range by the specified scale factor from the specified value, while keeping
|
|
30
|
+
* the range within the constraints (start, end). The equations are written so that the zooming
|
|
31
|
+
* (scaling) occurs at the specified value, and expands/contracts equally from that value.
|
|
32
|
+
* @param factor The scale factor
|
|
33
|
+
* @param value The value from which to scale the interval
|
|
34
|
+
* @param constraint The minimum and maximum values that range bounds can be
|
|
35
|
+
* @return A new continuous-axis range with updated values
|
|
36
|
+
*/
|
|
37
|
+
constrainedScale(factor: number, value: number, constraint: [min: number, max: number]): OrdinalAxisRange;
|
|
38
|
+
/**
|
|
39
|
+
* Translates the axis-range by the specified amount
|
|
40
|
+
* @param amount The amount by which to translate the axis-range
|
|
41
|
+
* @param [constraint=[-Infinity, Infinity]] Optional constraint interval in which the axis range must be within
|
|
42
|
+
* @return An updated {@link OrdinalAxisRange} that has been translated by the specified amount
|
|
43
|
+
*/
|
|
44
|
+
translate(amount: number, constraint?: [start: number, end: number]): OrdinalAxisRange;
|
|
45
|
+
/**
|
|
46
|
+
* Assumes that the original ranges start at 0 and end at the width or height of the plot. Calculates the
|
|
47
|
+
* new range based on the change in dimensions and the previous range. And calculates the new original range
|
|
48
|
+
* based on the change in the dimensions.
|
|
49
|
+
* @param beforeDimension The width or height before the change in dimensions
|
|
50
|
+
* @param afterDimension The width or height after the change in dimensions
|
|
51
|
+
* @return An updated {@link OrdinalAxisRange} that has been zoomed based on the change in
|
|
52
|
+
* the dimensions.
|
|
53
|
+
*/
|
|
54
|
+
zoom(beforeDimension: number, afterDimension: number): OrdinalAxisRange;
|
|
55
|
+
/**
|
|
56
|
+
* Updates the axis-range with the new start and end values, leaving the original range unchanged.
|
|
57
|
+
* @param start The new start of the axis-range
|
|
58
|
+
* @param end The new end of the axis range
|
|
59
|
+
* @return The updated axis-range type, with all other values unchanged.
|
|
60
|
+
*/
|
|
61
|
+
update(start: number, end: number): OrdinalAxisRange;
|
|
62
|
+
/**
|
|
63
|
+
* Updates the original range with the new start and end values.
|
|
64
|
+
* @param start The new value for the start of the original range
|
|
65
|
+
* @param end The new value for the end of the original range
|
|
66
|
+
* @return The updated original range.
|
|
67
|
+
*/
|
|
68
|
+
updateOriginal(start: number, end: number): BaseAxisRange;
|
|
69
|
+
}
|