stream-charts 1.0.0 → 1.1.0
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 +758 -345
- package/changes.md +10 -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} +17 -11
- package/dist/src/app/charts/{tooltipUtils.js → tooltips/tooltipUtils.js} +52 -25
- 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,100 @@
|
|
|
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 class OrdinalAxisRange 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 ordinal-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 OrdinalAxisRange(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. This operation does not modify the original range.
|
|
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 OrdinalAxisRange(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 OrdinalAxisRange(Math.min(min, scaledInterval.start), Math.max(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 OrdinalAxisRange} 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 OrdinalAxisRange(this.current.start + amount, this.current.end + amount, this.original.start, this.original.end);
|
|
62
|
+
}
|
|
63
|
+
return new OrdinalAxisRange(this.current.start, this.current.end, this.original.start, this.original.end);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Assumes that the original ranges start at 0 and end at the width or height of the plot. Calculates the
|
|
67
|
+
* new range based on the change in dimensions and the previous range. And calculates the new original range
|
|
68
|
+
* based on the change in the dimensions.
|
|
69
|
+
* @param beforeDimension The width or height before the change in dimensions
|
|
70
|
+
* @param afterDimension The width or height after the change in dimensions
|
|
71
|
+
* @return An updated {@link OrdinalAxisRange} that has been zoomed based on the change in
|
|
72
|
+
* the dimensions.
|
|
73
|
+
*/
|
|
74
|
+
zoom(beforeDimension, afterDimension) {
|
|
75
|
+
const [start, end] = this.current.asTuple();
|
|
76
|
+
const delta = (end - start) * (afterDimension - beforeDimension) / beforeDimension;
|
|
77
|
+
const lowerBound = start / (end - start) * delta + start;
|
|
78
|
+
const upperBound = end / (end - start) * delta + end;
|
|
79
|
+
return new OrdinalAxisRange(lowerBound, upperBound, 0, afterDimension);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Updates the axis-range with the new start and end values, leaving the original range unchanged.
|
|
83
|
+
* @param start The new start of the axis-range
|
|
84
|
+
* @param end The new end of the axis range
|
|
85
|
+
* @return The updated axis-range type, with all other values unchanged.
|
|
86
|
+
*/
|
|
87
|
+
update(start, end) {
|
|
88
|
+
return new OrdinalAxisRange(start, end, this.original.start, this.original.end);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Updates the original range with the new start and end values.
|
|
92
|
+
* @param start The new value for the start of the original range
|
|
93
|
+
* @param end The new value for the end of the original range
|
|
94
|
+
* @return The updated original range.
|
|
95
|
+
*/
|
|
96
|
+
updateOriginal(start, end) {
|
|
97
|
+
return new OrdinalAxisRange(this.current.start, this.current.end, start, end);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=OrdinalAxisRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrdinalAxisRange.js","sourceRoot":"","sources":["../../../../../src/app/charts/axes/OrdinalAxisRange.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { OrdinalAxisRange } from './OrdinalAxisRange';
|
|
2
|
+
describe('scaleOrdinalBounds', () => {
|
|
3
|
+
function validateRanges(actualRanges, expectedRanges) {
|
|
4
|
+
const { current: actualRange, original: actualOriginal } = actualRanges;
|
|
5
|
+
expect(actualRange.start).toBeCloseTo(expectedRanges.current.start);
|
|
6
|
+
expect(actualRange.end).toBeCloseTo(expectedRanges.current.end);
|
|
7
|
+
expect(actualOriginal.start).toBe(expectedRanges.original.start);
|
|
8
|
+
expect(actualOriginal.end).toBe(expectedRanges.original.end);
|
|
9
|
+
}
|
|
10
|
+
function calculateScale(ranges) {
|
|
11
|
+
return ranges.currentDistance / ranges.originalDistance;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Ranges before and after zoom should have the same scale as calculated by the
|
|
15
|
+
* measure of the zoomed range divided by the measure of the original range.
|
|
16
|
+
* @param previousRanges The ranges before the zoom
|
|
17
|
+
* @param currentRanges The ranges after the zoom
|
|
18
|
+
*/
|
|
19
|
+
function validateScale(previousRanges, currentRanges) {
|
|
20
|
+
expect(Math.abs(calculateScale(previousRanges) - calculateScale(currentRanges))).toBeLessThan(1e-10);
|
|
21
|
+
}
|
|
22
|
+
it('should scale bounds and original bounds the same when they are both the same', () => {
|
|
23
|
+
const expectedRange = OrdinalAxisRange.from(0, 200, 0, 200);
|
|
24
|
+
const range = OrdinalAxisRange.from(0, 100, 0, 100);
|
|
25
|
+
const zoomedRange = range.zoom(100, 200);
|
|
26
|
+
validateRanges(zoomedRange, expectedRange);
|
|
27
|
+
validateScale(range, zoomedRange);
|
|
28
|
+
});
|
|
29
|
+
it('should scale bounds and original bounds when ordinal axis is zoomed by 10 percent', () => {
|
|
30
|
+
const expectedRange = OrdinalAxisRange.from(-55, 220, 0, 110);
|
|
31
|
+
const range = OrdinalAxisRange.from(-50, 200, 0, 100);
|
|
32
|
+
const zoomedRange = range.zoom(100, 110);
|
|
33
|
+
validateRanges(zoomedRange, expectedRange);
|
|
34
|
+
});
|
|
35
|
+
it('should scale bounds and original bounds when ordinal axis is zoomed by 500 percent', () => {
|
|
36
|
+
const expectedRange = OrdinalAxisRange.from(-250, 1000, 0, 500);
|
|
37
|
+
const range = OrdinalAxisRange.from(-50, 200, 0, 100);
|
|
38
|
+
const zoomedRange = range.zoom(100, 500);
|
|
39
|
+
validateRanges(zoomedRange, expectedRange);
|
|
40
|
+
});
|
|
41
|
+
it('should scale bounds and original bounds when ordinal axis is zoomed by 10 percent and ends are same', () => {
|
|
42
|
+
const expectedRange = OrdinalAxisRange.from(-750, 500, 0, 500);
|
|
43
|
+
const range = OrdinalAxisRange.from(-150, 100, 0, 100);
|
|
44
|
+
const zoomedRange = range.zoom(100, 500);
|
|
45
|
+
validateRanges(zoomedRange, expectedRange);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=OrdinalAxisRange.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrdinalAxisRange.test.js","sourceRoot":"","sources":["../../../../../src/app/charts/axes/OrdinalAxisRange.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { Dimensions, Margin } from "../styling/margins";
|
|
2
|
+
import { ContinuousAxisRange } from "./ContinuousAxisRange";
|
|
3
|
+
import { Axis, ScaleBand, ScaleContinuousNumeric, ZoomTransform } from "d3";
|
|
4
|
+
import { AxisElementSelection, SvgSelection } from "../d3types";
|
|
5
|
+
import { AxesState } from "./AxesState";
|
|
6
|
+
import { AxesAssignment } from "../plots/plot";
|
|
7
|
+
import { BaseSeries } from "../series/baseSeries";
|
|
8
|
+
import { OrdinalAxisRange } from "./OrdinalAxisRange";
|
|
9
|
+
import { BaseAxisRange } from "./BaseAxisRange";
|
|
10
|
+
import { AxisInterval } from "./AxisInterval";
|
|
11
|
+
/**
|
|
12
|
+
* Holds the style for the axis tick labels
|
|
13
|
+
*/
|
|
14
|
+
export type AxisTickStyle = {
|
|
15
|
+
font: AxesFont;
|
|
16
|
+
rotation: number;
|
|
17
|
+
useAutoRotation: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Factory function to create a default AxisTickStyle with the default font,
|
|
21
|
+
* no rotation, and no auto-rotation.
|
|
22
|
+
*/
|
|
23
|
+
export declare function defaultAxisTickStyle(): AxisTickStyle;
|
|
24
|
+
/**
|
|
25
|
+
* Holds the font information for the axis labels
|
|
26
|
+
*/
|
|
27
|
+
export interface AxesFont {
|
|
28
|
+
size: number;
|
|
29
|
+
color: string;
|
|
30
|
+
family: string;
|
|
31
|
+
weight: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Factory function to create a default AxesFont with the default font size, color,
|
|
35
|
+
* family, and weight.
|
|
36
|
+
*/
|
|
37
|
+
export declare function defaultAxesFont(): AxesFont;
|
|
38
|
+
/**
|
|
39
|
+
* Holds the style information for a series in a chart
|
|
40
|
+
*/
|
|
41
|
+
export interface SeriesStyle {
|
|
42
|
+
color: string;
|
|
43
|
+
highlightColor: string;
|
|
44
|
+
margin?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Holds the style information for a series line-style in a chart.
|
|
48
|
+
*/
|
|
49
|
+
export interface SeriesLineStyle extends SeriesStyle {
|
|
50
|
+
lineWidth: number;
|
|
51
|
+
highlightWidth: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Factory function to create a default SeriesLineStyle with the default color, line width,
|
|
55
|
+
* highlight color, and highlight width.
|
|
56
|
+
*/
|
|
57
|
+
export declare function defaultLineStyle(): SeriesLineStyle;
|
|
58
|
+
/**
|
|
59
|
+
* The base interface that all Axes must implement. Each axis must have a unique ID,
|
|
60
|
+
* a location (top, bottom, left, right), and d3 SVG selection for the axis.
|
|
61
|
+
*/
|
|
62
|
+
export interface BaseAxis {
|
|
63
|
+
axisId: string;
|
|
64
|
+
location: AxisLocation;
|
|
65
|
+
selection: AxisElementSelection;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Represents a continuous numeric axis.
|
|
69
|
+
*/
|
|
70
|
+
export interface ContinuousNumericAxis extends BaseAxis {
|
|
71
|
+
/**
|
|
72
|
+
* A d3 scale for a continuous numeric axis.
|
|
73
|
+
*/
|
|
74
|
+
scale: ScaleContinuousNumeric<number, number>;
|
|
75
|
+
/**
|
|
76
|
+
* A d3 axis generator for a continuous numeric axis.
|
|
77
|
+
*/
|
|
78
|
+
generator: Axis<number | {
|
|
79
|
+
valueOf(): number;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Updates the axis based on the specified domain and plot dimensions.
|
|
83
|
+
* @param domain The interval representing the domain of the axis.
|
|
84
|
+
* @param plotDimensions The dimensions of the plot (without the margins).
|
|
85
|
+
* @param margin The margins for the plot
|
|
86
|
+
*/
|
|
87
|
+
update: (domain: AxisInterval, plotDimensions: Dimensions, margin: Margin) => void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Represents an ordinal string axis.
|
|
91
|
+
*/
|
|
92
|
+
export interface OrdinalStringAxis extends BaseAxis {
|
|
93
|
+
/**
|
|
94
|
+
* A d3 scale for an ordinal string axis.
|
|
95
|
+
*/
|
|
96
|
+
scale: ScaleBand<string>;
|
|
97
|
+
/**
|
|
98
|
+
* A d3 axis generator for an ordinal string axis.
|
|
99
|
+
*/
|
|
100
|
+
generator: Axis<string>;
|
|
101
|
+
/**
|
|
102
|
+
* The size of each category on the axis.
|
|
103
|
+
*/
|
|
104
|
+
categorySize: number;
|
|
105
|
+
/**
|
|
106
|
+
* Updates the axis based on the specified domain and plot dimensions.
|
|
107
|
+
* @param range An interval representing the range of the axis.
|
|
108
|
+
* @param originalRange An interval representing the original range of the axis (before zooming or panning).
|
|
109
|
+
* @param plotDimensions The dimensions of the plot (without the margins).
|
|
110
|
+
* @param margin The margins for the plot
|
|
111
|
+
* @return The number of pixels for each category on the axis.
|
|
112
|
+
*/
|
|
113
|
+
update: (range: AxisInterval, originalRange: AxisInterval, plotDimensions: Dimensions, margin: Margin) => number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Enumerates the possible locations of an axis.
|
|
117
|
+
*/
|
|
118
|
+
export declare enum AxisLocation {
|
|
119
|
+
Left = 0,
|
|
120
|
+
Right = 1,
|
|
121
|
+
Bottom = 2,
|
|
122
|
+
Top = 3
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Adds a clip area for the chart to the specified SVG element. The clip-area is given
|
|
126
|
+
* an `id` of `clip-series-<chart_id>`, which because the chart ID should be unique, makes
|
|
127
|
+
* this unique as well
|
|
128
|
+
* @param chartId The ID of the chart to which the clip area is to be added
|
|
129
|
+
* @param axisId The ID of the axis to which the clip area is to be added
|
|
130
|
+
* @param svg The SVG element to which the clip area is to be added
|
|
131
|
+
* @param location The location of the axis
|
|
132
|
+
* @param plotDimensions The dimensions of the plot
|
|
133
|
+
* @param margin The margins around the plot
|
|
134
|
+
* @return The ID of the clip-path
|
|
135
|
+
*/
|
|
136
|
+
export declare function setClipPath(chartId: number, axisId: string, svg: SvgSelection, location: AxisLocation, plotDimensions: Dimensions, margin: Margin): string;
|
|
137
|
+
/**
|
|
138
|
+
* Adds a category axis to the specified location. When the location is top or bottom,
|
|
139
|
+
* the category axis represents the x-axis. When the location is left or right, then the
|
|
140
|
+
* category axis represents the y-axis.
|
|
141
|
+
* @param chartId The unique ID of the chart to which this axis belongs
|
|
142
|
+
* @param axisId A unique ID for the axis
|
|
143
|
+
* @param svg The SVG selection (d3)
|
|
144
|
+
* @param location The location of the axis
|
|
145
|
+
* @param categories An array holding the category names
|
|
146
|
+
* @param axisLabel The axis label
|
|
147
|
+
* @param axesLabelFont The font for the axis label
|
|
148
|
+
* @param axisTickStyle Styling information for the ticks (e.g. font, rotation, etc)
|
|
149
|
+
* @param plotDimensions The dimensions of the plot
|
|
150
|
+
* @param margin The plot margin
|
|
151
|
+
* @param setAxisRangeFor Lambda that sets the axis range for the specified axis
|
|
152
|
+
* @param setOriginalAxisRangeFor Lambda that sets the original axis range for the specified axis
|
|
153
|
+
* @return A category axis
|
|
154
|
+
*/
|
|
155
|
+
export declare function addOrdinalStringAxis(chartId: number, axisId: string, svg: SvgSelection, location: AxisLocation, categories: Array<string>, axisLabel: string, axesLabelFont: AxesFont, axisTickStyle: AxisTickStyle, plotDimensions: Dimensions, margin: Margin, setAxisRangeFor: (axisId: string, range: AxisInterval) => void, setOriginalAxisRangeFor: (axisId: string, range: AxisInterval) => void): OrdinalStringAxis;
|
|
156
|
+
/**
|
|
157
|
+
* Adds a new x-axis to the SVG element at the specified location
|
|
158
|
+
* @param chartId The ID of the chart
|
|
159
|
+
* @param axisId The ID of the axis
|
|
160
|
+
* @param svg The SVG selection to which to add the axis
|
|
161
|
+
* @param plotDimensions The dimensions of the plot
|
|
162
|
+
* @param location The location of the axis
|
|
163
|
+
* @param scaleGenerator The higher-order function that returns the axis d3 "scale" function
|
|
164
|
+
* @param domain The axis range (start, end)
|
|
165
|
+
* @param axesLabelFont The font for the axis labels
|
|
166
|
+
* @param margin The plot margins for the border of main SVG group
|
|
167
|
+
* @param axisLabel The label for the axis
|
|
168
|
+
* @param setAxisRangeFor A callback used to set the axis range
|
|
169
|
+
* @return A {@link ContinuousNumericAxis} based on the arguments to this function
|
|
170
|
+
*/
|
|
171
|
+
export declare function addContinuousNumericXAxis(chartId: number, axisId: string, svg: SvgSelection, plotDimensions: Dimensions, location: AxisLocation.Bottom | AxisLocation.Top, scaleGenerator: ScaleContinuousNumeric<number, number>, domain: [minValue: number, maxValue: number], axesLabelFont: AxesFont, margin: Margin, axisLabel: string, setAxisRangeFor: (axisId: string, timeRange: AxisInterval) => void): ContinuousNumericAxis;
|
|
172
|
+
/**
|
|
173
|
+
* Adds a new y-axis to the SVG element at the specified location
|
|
174
|
+
* @param chartId The ID of the chart
|
|
175
|
+
* @param axisId The ID of the axis
|
|
176
|
+
* @param svg The SVG selection to which to add the axis
|
|
177
|
+
* @param plotDimensions The dimensions of the plot
|
|
178
|
+
* @param location The location of the axis
|
|
179
|
+
* @param scaleGenerator The higher-order function that returns the axis d3 "scale" function
|
|
180
|
+
* @param domain The axis range (start, end)
|
|
181
|
+
* @param axesLabelFont The font for the axis labels
|
|
182
|
+
* @param margin The plot margins for the border of main SVG group
|
|
183
|
+
* @param axisLabel The label for the axis
|
|
184
|
+
* @param setAxisRangeFor A callback used to set the axis range
|
|
185
|
+
* @return A {@link ContinuousNumericAxis} based on the arguments to this function
|
|
186
|
+
*/
|
|
187
|
+
export declare function addContinuousNumericYAxis(chartId: number, axisId: string, svg: SvgSelection, plotDimensions: Dimensions, location: AxisLocation.Left | AxisLocation.Right, scaleGenerator: ScaleContinuousNumeric<number, number>, domain: [minValue: number, maxValue: number], axesLabelFont: AxesFont, margin: Margin, axisLabel: string, setAxisRangeFor: (axisId: string, range: AxisInterval) => void): ContinuousNumericAxis;
|
|
188
|
+
/**
|
|
189
|
+
* Calculates a unique ID for the axis based on the location and chart ID
|
|
190
|
+
* @param chartId The unique ID of the chart
|
|
191
|
+
* @param location The axis location (i.e. top, bottom, left, right)
|
|
192
|
+
* @return A unique ID for the axis
|
|
193
|
+
*/
|
|
194
|
+
export declare function labelIdFor(chartId: number, location: AxisLocation): string;
|
|
195
|
+
/**
|
|
196
|
+
* The result of a zoom action
|
|
197
|
+
*/
|
|
198
|
+
export interface ZoomResult<AR extends BaseAxisRange> {
|
|
199
|
+
range: AR;
|
|
200
|
+
zoomFactor: number;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Called when the user uses the scroll wheel (or scroll gesture) to zoom in or out. Zooms in/out
|
|
204
|
+
* at the location of the mouse when the scroll wheel or gesture was applied, while ensure that
|
|
205
|
+
* the range (start, end) is contained within the constraint (min, max).
|
|
206
|
+
* @param transform The d3 zoom transformation information
|
|
207
|
+
* @param x The x-position of the mouse when the scroll wheel or gesture is used
|
|
208
|
+
* @param axis The axis being zoomed
|
|
209
|
+
* @param range The current range for the axis being zoomed
|
|
210
|
+
* @param constraint The minimum and maximum value the scaled range can have
|
|
211
|
+
* @return The updated range and the new zoom factor
|
|
212
|
+
*/
|
|
213
|
+
export declare function calculateConstrainedZoomFor(transform: ZoomTransform, x: number, axis: ContinuousNumericAxis, range: ContinuousAxisRange, constraint: [min: number, max: number]): ZoomResult<ContinuousAxisRange>;
|
|
214
|
+
/**
|
|
215
|
+
* Calculates the zoom for an ordinal axis.
|
|
216
|
+
* @param transform The d3 zoom transformation information
|
|
217
|
+
* @param x The x-position of the mouse when the scroll wheel or gesture is used
|
|
218
|
+
* @param range The current range for the axis being zoomed
|
|
219
|
+
* @param constraint The minimum and maximum value the scaled range can have
|
|
220
|
+
* @return A ZoomResult holding the updated range and the new zoom factor
|
|
221
|
+
*/
|
|
222
|
+
export declare function calculateOrdinalConstrainedZoomFor(transform: ZoomTransform, x: number, range: OrdinalAxisRange, constraint: [min: number, max: number]): ZoomResult<OrdinalAxisRange>;
|
|
223
|
+
/**
|
|
224
|
+
* Adjusts the range and updates the plot when the plot is dragged to the left or right
|
|
225
|
+
* @param delta The amount that the plot is dragged
|
|
226
|
+
* @param axis The axis being zoomed
|
|
227
|
+
* @param range The current range for the axis being zoomed
|
|
228
|
+
* @param [constrainToOriginalRange=false] When set to `true` then the pan requires that the axis
|
|
229
|
+
* range remains a subset of the origin axis range; when `false` the pan allows and range
|
|
230
|
+
* @return The updated range
|
|
231
|
+
*/
|
|
232
|
+
export declare function calculatePanFor(delta: number, axis: ContinuousNumericAxis, range: ContinuousAxisRange, constrainToOriginalRange?: boolean): ContinuousAxisRange;
|
|
233
|
+
export declare function calculateOrdinalPanFor(delta: number, range: OrdinalAxisRange, plotDimensions: Dimensions, constrainToOriginalRange?: boolean): OrdinalAxisRange;
|
|
234
|
+
/**
|
|
235
|
+
* Accepts the series, the assignment of the series to axes, and the current x-axes state, and
|
|
236
|
+
* returns an array of the distinct axis IDs that cover all the series in the plot.
|
|
237
|
+
*
|
|
238
|
+
* @param series The array of series
|
|
239
|
+
* @param axisAssignments A map association a series name with its axis assignments
|
|
240
|
+
* @param axesState The current axis state
|
|
241
|
+
* @return an array of the distinct axes that cover all the series in the plot
|
|
242
|
+
*/
|
|
243
|
+
export declare function axesForSeriesGen<D, A extends BaseAxis>(series: Array<BaseSeries<D>>, axisAssignments: Map<string, AxesAssignment>, axesState: AxesState<A>): Array<string>;
|
|
244
|
+
/**
|
|
245
|
+
* Higher-order function that generates a handler for pan events, given the distinct series IDs that cover all
|
|
246
|
+
* the axes in the chart, the margin, axis-range update function, and the current state of the x-axes. This
|
|
247
|
+
* function returns a handler function. And this handler function adjusts the time-range when the plot is dragged
|
|
248
|
+
* to the left or right. After calling the handler function, the plot needs to be updated as well, and this is
|
|
249
|
+
* left for the caller.
|
|
250
|
+
*
|
|
251
|
+
* Please note that the function generated by this function has side effects -- it updates the axes ranges.
|
|
252
|
+
*
|
|
253
|
+
* @param axesForSeries The distinct axes that cover all the series
|
|
254
|
+
* @param margin The plot margin
|
|
255
|
+
* @param setAxisRangeFor Function for setting the new axis-range for a specific axis
|
|
256
|
+
* @param axesState The current state of the x-axes or y-axes
|
|
257
|
+
* @param [constrainToOriginalRange=false] Optional argument, that when set to `true`, constrains the
|
|
258
|
+
* axis range to remain in the origin axis range; when `false` the axis range is unconstrained
|
|
259
|
+
* @return A handler function for pan events
|
|
260
|
+
*/
|
|
261
|
+
export declare function panHandler(axesForSeries: Array<string>, margin: Margin, setAxisRangeFor: (axisId: string, axisRange: AxisInterval) => void, axesState: AxesState<ContinuousNumericAxis>, constrainToOriginalRange?: boolean): (x: number, plotDimensions: Dimensions, ranges: Map<string, ContinuousAxisRange>) => void;
|
|
262
|
+
/**
|
|
263
|
+
* Higher-order function that generates a handler for pan events, given the distinct series IDs that cover all
|
|
264
|
+
* the axes in the chart, the margin, axis-range update function, and the current state of the x-axes. This
|
|
265
|
+
* function returns a handler function. And this handler function adjusts the time-range when the plot is dragged
|
|
266
|
+
* to the left or right. After calling the handler function, the plot needs to be updated as well, and this is
|
|
267
|
+
* left for the caller.
|
|
268
|
+
*
|
|
269
|
+
* Please note that the function generated by this function has side effects -- it updates the axes ranges.
|
|
270
|
+
*
|
|
271
|
+
* @param axesForSeries The distinct axes that cover all the series
|
|
272
|
+
* @param margin The plot margin
|
|
273
|
+
* @param setAxisRangeFor Function for setting the new axis-range for a specific axis
|
|
274
|
+
* @param axesState The current state of the x-axes or y-axes
|
|
275
|
+
* @param [constrainToOriginalRange=false] Optional argument, that when set to `true`, constrains the
|
|
276
|
+
* axis range to remain in the origin axis range; when `false` the axis range is unconstrained
|
|
277
|
+
* @return A handler function for pan events
|
|
278
|
+
*/
|
|
279
|
+
export declare function ordinalPanHandler(axesForSeries: Array<string>, margin: Margin, setAxisRangeFor: (axisId: string, axisRange: AxisInterval) => void, axesState: AxesState<OrdinalStringAxis>, constrainToOriginalRange?: boolean): (x: number, plotDimensions: Dimensions, series: Array<string>, ranges: Map<string, OrdinalAxisRange>) => void;
|
|
280
|
+
/**
|
|
281
|
+
* Higher-order function that generates a handler for pan events, given the distinct series IDs that cover all
|
|
282
|
+
* the axes in the chart, the margin, time-range update function, and the current state of the x-axes. This
|
|
283
|
+
* function returns a handler function. And this handler function adjusts the time-range when the plot is dragged
|
|
284
|
+
* to the left or right. After calling the handler function, the plot needs to be updated as well, and this is
|
|
285
|
+
* left for the caller.
|
|
286
|
+
*
|
|
287
|
+
* Please note that the function generated by this function has side effects -- it updates the axes ranges.
|
|
288
|
+
*
|
|
289
|
+
* @param xAxesForSeries The distinct x-axes that cover all the series
|
|
290
|
+
* @param yAxesForSeries The distinct y-axes that cover all the series
|
|
291
|
+
* @param margin The plot margin
|
|
292
|
+
* @param setAxisRange Function for setting the new time-range for a specific axis
|
|
293
|
+
* @param xAxesState The current state of the x-axes
|
|
294
|
+
* @param yAxesState The current state of the y-axes
|
|
295
|
+
* @param [constrainToOriginalRange=true] Optional argument, that when set to `true`, constrains the
|
|
296
|
+
* axis range to remain in the origin axis range; when `false` the axis range is unconstrained
|
|
297
|
+
* @return A handler function for pan events
|
|
298
|
+
*/
|
|
299
|
+
export declare function panHandler2D(xAxesForSeries: Array<string>, yAxesForSeries: Array<string>, margin: Margin, setAxisRange: (axisId: string, axisRange: AxisInterval) => void, xAxesState: AxesState<ContinuousNumericAxis>, yAxesState: AxesState<ContinuousNumericAxis>, constrainToOriginalRange?: boolean): (x: number, y: number, plotDimensions: Dimensions, series: Array<string>, xRanges: Map<string, ContinuousAxisRange>, yRanges: Map<string, ContinuousAxisRange>) => void;
|
|
300
|
+
/**
|
|
301
|
+
* Higher-order function that generates a handler for zoom events, given the distinct series IDs that cover all
|
|
302
|
+
* the axes in the chart, the margin, range update function, and the current state of the x- or y-axes. This
|
|
303
|
+
* function returns a handler function. And this handler function adjusts the range when the plot is zoomed.
|
|
304
|
+
* After calling the handler function, the plot needs to be updated as well, and this is left for the caller.
|
|
305
|
+
*
|
|
306
|
+
* Please note that the function generated by this function has side effects -- it updates the axes ranges.
|
|
307
|
+
*
|
|
308
|
+
* @param axesForSeries The distinct axes that cover all the series
|
|
309
|
+
* @param margin The plot margin
|
|
310
|
+
* @param setRangeFor Function for setting the new time-range for a specific axis
|
|
311
|
+
* @param axesState The current state of the x- or y-axes
|
|
312
|
+
* @param scaleExtent The minimum and maximum allowed scale factors
|
|
313
|
+
* @return A handler function for pan events
|
|
314
|
+
*/
|
|
315
|
+
export declare function continuousAxisZoomHandler(axesForSeries: Array<string>, margin: Margin, setRangeFor: (axisId: string, range: AxisInterval) => void, axesState: AxesState<ContinuousNumericAxis>, scaleExtent?: [min: number, max: number]): (transform: ZoomTransform, x: number, plotDimensions: Dimensions, ranges: Map<string, ContinuousAxisRange>) => void;
|
|
316
|
+
/**
|
|
317
|
+
* Higher-order function that generates a handler for zoom events, given the distinct series IDs that cover all
|
|
318
|
+
* the axes in the chart, the margin, range update function, and the current state of the x- or y-axes. This
|
|
319
|
+
* function returns a handler function. And this handler function adjusts the range when the plot is zoomed.
|
|
320
|
+
* After calling the handler function, the plot needs to be updated as well, and this is left for the caller.
|
|
321
|
+
*
|
|
322
|
+
* Please note that the function generated by this function has side effects -- it updates the axes ranges.
|
|
323
|
+
*
|
|
324
|
+
* @param axesForSeries The distinct axes that cover all the series
|
|
325
|
+
* @param margin The plot margin
|
|
326
|
+
* @param setRangeFor Function for setting the new time-range for a specific axis
|
|
327
|
+
* @param setOriginalRangeFor Function for setting the new original range for a specific axis
|
|
328
|
+
* @param axesState The current state of the x- or y-axes
|
|
329
|
+
* @param scaleExtent The minimum and maximum allowed scale factors
|
|
330
|
+
* @return A handler function for pan events
|
|
331
|
+
*/
|
|
332
|
+
export declare function ordinalAxisZoomHandler(axesForSeries: Array<string>, margin: Margin, setRangeFor: (axisId: string, range: AxisInterval) => void, setOriginalRangeFor: (axisId: string, range: AxisInterval) => void, axesState: AxesState<OrdinalStringAxis>, scaleExtent?: [min: number, max: number]): (transform: ZoomTransform, x: number, plotDimensions: Dimensions, ranges: Map<string, OrdinalAxisRange>) => void;
|
|
333
|
+
/**
|
|
334
|
+
* Higher-order function that generates a handler for zoom events, given the distinct series IDs that cover all
|
|
335
|
+
* the axes in the chart, the margin, range update function, and the current state of the x- or y-axes. This
|
|
336
|
+
* function returns a handler function. And this handler function adjusts the time-range when the plot is zoomed.
|
|
337
|
+
* After calling the handler function, the plot needs to be updated as well, and this is left for the caller.
|
|
338
|
+
*
|
|
339
|
+
* Please note that the function generated by this function has side effects -- it updates the axes ranges.
|
|
340
|
+
*
|
|
341
|
+
* @param xAxesForSeries The distinct x-axes that cover all the series
|
|
342
|
+
* @param yAxesForSeries The distinct y-axes that cover all the series
|
|
343
|
+
* @param margin The plot margin
|
|
344
|
+
* @param setRangeFor Function for setting the new time-range for a specific axis
|
|
345
|
+
* @param xAxesState The current state of the x-axes
|
|
346
|
+
* @param yAxesState The current state of the y-axes
|
|
347
|
+
* @param scaleExtent The smallest and largest scale factors allowed
|
|
348
|
+
* @return A handler function for pan events
|
|
349
|
+
*/
|
|
350
|
+
export declare function axesZoomHandler(xAxesForSeries: Array<string>, yAxesForSeries: Array<string>, margin: Margin, setRangeFor: (axisId: string, range: AxisInterval) => void, xAxesState: AxesState<ContinuousNumericAxis>, yAxesState: AxesState<ContinuousNumericAxis>, scaleExtent: [min: number, max: number]): (transform: ZoomTransform, mousePosition: [x: number, y: number], plotDimensions: Dimensions, xRanges: Map<string, ContinuousAxisRange>, yRanges: Map<string, ContinuousAxisRange>) => void;
|
|
351
|
+
/**
|
|
352
|
+
* Calculates the axis-ranges for each of the continuous numeric axes in the map
|
|
353
|
+
* @param axes The map containing the axes and their associated IDs
|
|
354
|
+
* @return a map associating the axis IDs to their continuous axis-range
|
|
355
|
+
*/
|
|
356
|
+
export declare function continuousAxisRanges(axes: Map<string, ContinuousNumericAxis>): Map<string, ContinuousAxisRange>;
|
|
357
|
+
/**
|
|
358
|
+
* Calculates the axis-ranges for each of the ordinal axes in the map
|
|
359
|
+
* @param axes The map containing the axes and their associated IDs
|
|
360
|
+
* @param originalRange The original range of the axis
|
|
361
|
+
* @return a map associating the axis IDs to their ordinal axis-range
|
|
362
|
+
*/
|
|
363
|
+
export declare function ordinalAxisRanges(axes: Map<string, OrdinalStringAxis>, originalRange: AxisInterval): Map<string, OrdinalAxisRange>;
|
|
364
|
+
/**
|
|
365
|
+
* Calculates the axis interval (start, end) for each of the axis
|
|
366
|
+
* @param axes The axes representing the time
|
|
367
|
+
* @return A map associating each axis with a (start, end) interval
|
|
368
|
+
*/
|
|
369
|
+
export declare function continuousAxisIntervals(axes: Map<string, ContinuousNumericAxis>): Map<string, AxisInterval>;
|
|
370
|
+
/**
|
|
371
|
+
* Calculates the axis interval (start, end) for each of the axis
|
|
372
|
+
* @param axes The axes representing the time
|
|
373
|
+
* @return A map associating each axis with a (start, end) interval
|
|
374
|
+
*/
|
|
375
|
+
export declare function ordinalAxisIntervals(axes: Map<string, OrdinalStringAxis>): Map<string, {
|
|
376
|
+
interval: AxisInterval;
|
|
377
|
+
categories: Array<string>;
|
|
378
|
+
}>;
|
|
379
|
+
/**
|
|
380
|
+
* Returns the bounds on the specified continuous numeric axes
|
|
381
|
+
* @param axes A map associating an axis ID with a {@link ContinuousNumericAxis}
|
|
382
|
+
* @return A map associating each specified axis ID with the interval covered (bounds) by the axis
|
|
383
|
+
*/
|
|
384
|
+
export declare function continuousRange(axes: Map<string, ContinuousNumericAxis>): Map<string, ContinuousAxisRange>;
|
|
385
|
+
/**
|
|
386
|
+
* Returns the bounds on the specified continuous numeric axes
|
|
387
|
+
* @param axes A map associating an axis ID with a {@link OrdinalStringAxis}
|
|
388
|
+
* @param originalRange The original range of the axis
|
|
389
|
+
* @return A map associating each specified axis ID with the interval covered (bounds) by the axis
|
|
390
|
+
*/
|
|
391
|
+
export declare function ordinalRange(axes: Map<string, OrdinalStringAxis>, originalRange: AxisInterval): Map<string, OrdinalAxisRange>;
|