stream-charts 1.1.1 → 1.2.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 +66 -0
- package/changes.md +8 -0
- package/dist/{src/app → app}/charts/Chart.d.ts +27 -6
- package/dist/{src/app → app}/charts/Chart.js +2 -2
- package/dist/app/charts/Chart.js.map +1 -0
- package/dist/{src/app → app}/charts/axes/AxesState.d.ts +4 -4
- package/dist/{src/app → app}/charts/axes/AxesState.js +4 -4
- package/dist/app/charts/axes/AxesState.js.map +1 -0
- package/dist/app/charts/axes/AxesState.test.js.map +1 -0
- package/dist/app/charts/axes/AxisInterval.js.map +1 -0
- package/dist/app/charts/axes/AxisInterval.test.js.map +1 -0
- package/dist/app/charts/axes/BaseAxisRange.js.map +1 -0
- package/dist/{src/app → app}/charts/axes/ContinuousAxis.d.ts +1 -3
- package/dist/{src/app → app}/charts/axes/ContinuousAxis.js +2 -3
- package/dist/app/charts/axes/ContinuousAxis.js.map +1 -0
- package/dist/app/charts/axes/ContinuousAxisRange.js.map +1 -0
- package/dist/app/charts/axes/ContinuousAxisRange.test.js.map +1 -0
- package/dist/app/charts/axes/EmptyAxis.d.ts +12 -0
- package/dist/app/charts/axes/EmptyAxis.js +70 -0
- package/dist/app/charts/axes/EmptyAxis.js.map +1 -0
- package/dist/{src/app → app}/charts/axes/OrdinalAxis.d.ts +1 -3
- package/dist/{src/app → app}/charts/axes/OrdinalAxis.js +10 -4
- package/dist/app/charts/axes/OrdinalAxis.js.map +1 -0
- package/dist/app/charts/axes/OrdinalAxisRange.js.map +1 -0
- package/dist/app/charts/axes/OrdinalAxisRange.test.js.map +1 -0
- package/dist/{src/app → app}/charts/axes/axes.d.ts +28 -0
- package/dist/{src/app → app}/charts/axes/axes.js +86 -6
- package/dist/app/charts/axes/axes.js.map +1 -0
- package/dist/{src/app → app}/charts/d3types.js.map +1 -1
- package/dist/app/charts/filters/regexFilter.js.map +1 -0
- package/dist/app/charts/filters/regexFilter.test.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useAxes.d.ts +3 -5
- package/dist/{src/app → app}/charts/hooks/useAxes.js +0 -1
- package/dist/app/charts/hooks/useAxes.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useChart.d.ts +9 -5
- package/dist/{src/app → app}/charts/hooks/useChart.js +4 -3
- package/dist/app/charts/hooks/useChart.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useDataObservable.d.ts +2 -4
- package/dist/{src/app → app}/charts/hooks/useDataObservable.js +0 -2
- package/dist/app/charts/hooks/useDataObservable.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useInitialData.d.ts +2 -4
- package/dist/{src/app → app}/charts/hooks/useInitialData.js +0 -1
- package/dist/app/charts/hooks/useInitialData.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useMouse.d.ts +6 -2
- package/dist/{src/app → app}/charts/hooks/useMouse.js +14 -14
- package/dist/app/charts/hooks/useMouse.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/usePlotDimensions.d.ts +1 -2
- package/dist/{src/app → app}/charts/hooks/usePlotDimensions.js +0 -1
- package/dist/app/charts/hooks/usePlotDimensions.js.map +1 -0
- package/dist/{src/app → app}/charts/hooks/useTooltip.d.ts +4 -4
- package/dist/{src/app → app}/charts/hooks/useTooltip.js +0 -1
- package/dist/app/charts/hooks/useTooltip.js.map +1 -0
- package/dist/app/charts/legends/Legend.d.ts +88 -0
- package/dist/app/charts/legends/Legend.js +425 -0
- package/dist/app/charts/legends/Legend.js.map +1 -0
- package/dist/app/charts/observables/ChartData.js.map +1 -0
- package/dist/app/charts/observables/iterates.js.map +1 -0
- package/dist/app/charts/observables/iterates.test.js.map +1 -0
- package/dist/app/charts/observables/ordinals.js.map +1 -0
- package/dist/app/charts/observables/ordinals.test.js.map +1 -0
- package/dist/{src/app → app}/charts/plots/BarPlot.d.ts +10 -12
- package/dist/{src/app → app}/charts/plots/BarPlot.js +14 -15
- package/dist/app/charts/plots/BarPlot.js.map +1 -0
- package/dist/{src/app → app}/charts/plots/PoincarePlot.d.ts +1 -3
- package/dist/{src/app → app}/charts/plots/PoincarePlot.js +0 -1
- package/dist/app/charts/plots/PoincarePlot.js.map +1 -0
- package/dist/{src/app → app}/charts/plots/RasterPlot.d.ts +1 -3
- package/dist/{src/app → app}/charts/plots/RasterPlot.js +12 -7
- package/dist/app/charts/plots/RasterPlot.js.map +1 -0
- package/dist/{src/app → app}/charts/plots/ScatterPlot.d.ts +1 -3
- package/dist/{src/app → app}/charts/plots/ScatterPlot.js +7 -6
- package/dist/app/charts/plots/ScatterPlot.js.map +1 -0
- package/dist/app/charts/plots/plot.js.map +1 -0
- package/dist/app/charts/series/baseSeries.js.map +1 -0
- package/dist/app/charts/series/datumSeries.test.js.map +1 -0
- package/dist/app/charts/series/iterateSeries.js.map +1 -0
- package/dist/app/charts/series/ordinalSeries.js.map +1 -0
- package/dist/app/charts/series/timeSeries.js.map +1 -0
- package/dist/app/charts/series/timeSeriesChartData.js.map +1 -0
- package/dist/app/charts/styling/barPlotStyle.js.map +1 -0
- package/dist/app/charts/styling/margins.js.map +1 -0
- package/dist/app/charts/styling/margins.test.js.map +1 -0
- package/dist/app/charts/styling/svgStyle.js.map +1 -0
- package/dist/app/charts/subscriptions/subscription.test.js.map +1 -0
- package/dist/app/charts/subscriptions/subscriptions.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/BarPlotTooltipContent.d.ts +1 -3
- package/dist/{src/app → app}/charts/tooltips/BarPlotTooltipContent.js +0 -1
- package/dist/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/PoincarePlotTooltipContent.d.ts +1 -3
- package/dist/{src/app → app}/charts/tooltips/PoincarePlotTooltipContent.js +0 -1
- package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/RasterPlotTooltipContent.d.ts +1 -3
- package/dist/{src/app → app}/charts/tooltips/RasterPlotTooltipContent.js +0 -1
- package/dist/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/ScatterPlotTooltipContent.d.ts +1 -3
- package/dist/{src/app → app}/charts/tooltips/ScatterPlotTooltipContent.js +3 -2
- package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -0
- package/dist/{src/app → app}/charts/tooltips/Tooltip.d.ts +10 -11
- package/dist/{src/app → app}/charts/tooltips/Tooltip.js +12 -12
- package/dist/app/charts/tooltips/Tooltip.js.map +1 -0
- package/dist/app/charts/tooltips/tooltipUtils.js.map +1 -0
- package/dist/{src/app → app}/charts/trackers/Tracker.d.ts +1 -3
- package/dist/{src/app → app}/charts/trackers/Tracker.js +0 -1
- package/dist/app/charts/trackers/Tracker.js.map +1 -0
- package/dist/app/charts/trackers/trackerUtils.js.map +1 -0
- package/dist/app/charts/utils.js.map +1 -0
- package/dist/{src/index.d.ts → index.d.ts} +20 -24
- package/dist/{src/index.js → index.js} +19 -19
- package/dist/index.js.map +1 -0
- package/package.json +20 -8
- package/src/app/charts/Chart.tsx +29 -5
- package/src/app/charts/axes/AxesState.ts +4 -4
- package/src/app/charts/axes/ContinuousAxis.tsx +3 -4
- package/src/app/charts/axes/EmptyAxis.tsx +119 -0
- package/src/app/charts/axes/OrdinalAxis.tsx +15 -4
- package/src/app/charts/axes/axes.ts +122 -6
- package/src/app/charts/hooks/useAxes.tsx +3 -4
- package/src/app/charts/hooks/useChart.tsx +13 -5
- package/src/app/charts/hooks/useDataObservable.tsx +2 -7
- package/src/app/charts/hooks/useInitialData.tsx +2 -3
- package/src/app/charts/hooks/useMouse.tsx +16 -13
- package/src/app/charts/hooks/usePlotDimensions.tsx +1 -2
- package/src/app/charts/hooks/useTooltip.tsx +4 -5
- package/src/app/charts/legends/Legend.tsx +600 -0
- package/src/app/charts/plots/BarPlot.tsx +15 -16
- package/src/app/charts/plots/PoincarePlot.tsx +1 -2
- package/src/app/charts/plots/RasterPlot.tsx +21 -8
- package/src/app/charts/plots/ScatterPlot.tsx +9 -11
- package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +1 -2
- package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +1 -2
- package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +1 -2
- package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +3 -2
- package/src/app/charts/tooltips/Tooltip.tsx +11 -11
- package/src/app/charts/trackers/Tracker.tsx +1 -2
- package/src/index.ts +322 -0
- package/dist/src/app/charts/Chart.js.map +0 -1
- package/dist/src/app/charts/axes/AxesState.js.map +0 -1
- package/dist/src/app/charts/axes/AxesState.test.js.map +0 -1
- package/dist/src/app/charts/axes/AxisInterval.js.map +0 -1
- package/dist/src/app/charts/axes/AxisInterval.test.js.map +0 -1
- package/dist/src/app/charts/axes/BaseAxisRange.js.map +0 -1
- package/dist/src/app/charts/axes/ContinuousAxis.js.map +0 -1
- package/dist/src/app/charts/axes/ContinuousAxisRange.js.map +0 -1
- package/dist/src/app/charts/axes/ContinuousAxisRange.test.js.map +0 -1
- package/dist/src/app/charts/axes/OrdinalAxis.js.map +0 -1
- package/dist/src/app/charts/axes/OrdinalAxisRange.js.map +0 -1
- package/dist/src/app/charts/axes/OrdinalAxisRange.test.js.map +0 -1
- package/dist/src/app/charts/axes/axes.js.map +0 -1
- package/dist/src/app/charts/filters/regexFilter.js.map +0 -1
- package/dist/src/app/charts/filters/regexFilter.test.js.map +0 -1
- package/dist/src/app/charts/hooks/useAxes.js.map +0 -1
- package/dist/src/app/charts/hooks/useChart.js.map +0 -1
- package/dist/src/app/charts/hooks/useDataObservable.js.map +0 -1
- package/dist/src/app/charts/hooks/useInitialData.js.map +0 -1
- package/dist/src/app/charts/hooks/useMouse.js.map +0 -1
- package/dist/src/app/charts/hooks/usePlotDimensions.js.map +0 -1
- package/dist/src/app/charts/hooks/useTooltip.js.map +0 -1
- package/dist/src/app/charts/observables/ChartData.js.map +0 -1
- package/dist/src/app/charts/observables/iterates.js.map +0 -1
- package/dist/src/app/charts/observables/iterates.test.js.map +0 -1
- package/dist/src/app/charts/observables/ordinals.js.map +0 -1
- package/dist/src/app/charts/observables/ordinals.test.js.map +0 -1
- package/dist/src/app/charts/plots/BarPlot.js.map +0 -1
- package/dist/src/app/charts/plots/PoincarePlot.js.map +0 -1
- package/dist/src/app/charts/plots/RasterPlot.js.map +0 -1
- package/dist/src/app/charts/plots/ScatterPlot.js.map +0 -1
- package/dist/src/app/charts/plots/plot.js.map +0 -1
- package/dist/src/app/charts/series/baseSeries.js.map +0 -1
- package/dist/src/app/charts/series/datumSeries.test.js.map +0 -1
- package/dist/src/app/charts/series/iterateSeries.js.map +0 -1
- package/dist/src/app/charts/series/ordinalSeries.js.map +0 -1
- package/dist/src/app/charts/series/timeSeries.js.map +0 -1
- package/dist/src/app/charts/series/timeSeriesChartData.js.map +0 -1
- package/dist/src/app/charts/styling/barPlotStyle.js.map +0 -1
- package/dist/src/app/charts/styling/margins.js.map +0 -1
- package/dist/src/app/charts/styling/margins.test.js.map +0 -1
- package/dist/src/app/charts/styling/svgStyle.js.map +0 -1
- package/dist/src/app/charts/subscriptions/subscription.test.js.map +0 -1
- package/dist/src/app/charts/subscriptions/subscriptions.js.map +0 -1
- package/dist/src/app/charts/tooltips/BarPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/tooltips/RasterPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/tooltips/ScatterPlotTooltipContent.js.map +0 -1
- package/dist/src/app/charts/tooltips/Tooltip.js.map +0 -1
- package/dist/src/app/charts/tooltips/tooltipUtils.js.map +0 -1
- package/dist/src/app/charts/trackers/Tracker.js.map +0 -1
- package/dist/src/app/charts/trackers/trackerUtils.js.map +0 -1
- package/dist/src/app/charts/utils.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- /package/dist/{src/app → app}/charts/axes/AxesState.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/AxesState.test.js +0 -0
- /package/dist/{src/app → app}/charts/axes/AxisInterval.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/AxisInterval.js +0 -0
- /package/dist/{src/app → app}/charts/axes/AxisInterval.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/AxisInterval.test.js +0 -0
- /package/dist/{src/app → app}/charts/axes/BaseAxisRange.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/BaseAxisRange.js +0 -0
- /package/dist/{src/app → app}/charts/axes/ContinuousAxisRange.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/ContinuousAxisRange.js +0 -0
- /package/dist/{src/app → app}/charts/axes/ContinuousAxisRange.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/ContinuousAxisRange.test.js +0 -0
- /package/dist/{src/app → app}/charts/axes/OrdinalAxisRange.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/OrdinalAxisRange.js +0 -0
- /package/dist/{src/app → app}/charts/axes/OrdinalAxisRange.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/axes/OrdinalAxisRange.test.js +0 -0
- /package/dist/{src/app → app}/charts/d3types.d.ts +0 -0
- /package/dist/{src/app → app}/charts/d3types.js +0 -0
- /package/dist/{src/app → app}/charts/filters/regexFilter.d.ts +0 -0
- /package/dist/{src/app → app}/charts/filters/regexFilter.js +0 -0
- /package/dist/{src/app → app}/charts/filters/regexFilter.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/filters/regexFilter.test.js +0 -0
- /package/dist/{src/app → app}/charts/observables/ChartData.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/ChartData.js +0 -0
- /package/dist/{src/app → app}/charts/observables/iterates.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/iterates.js +0 -0
- /package/dist/{src/app → app}/charts/observables/iterates.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/iterates.test.js +0 -0
- /package/dist/{src/app → app}/charts/observables/ordinals.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/ordinals.js +0 -0
- /package/dist/{src/app → app}/charts/observables/ordinals.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/observables/ordinals.test.js +0 -0
- /package/dist/{src/app → app}/charts/plots/plot.d.ts +0 -0
- /package/dist/{src/app → app}/charts/plots/plot.js +0 -0
- /package/dist/{src/app → app}/charts/series/baseSeries.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/baseSeries.js +0 -0
- /package/dist/{src/app → app}/charts/series/datumSeries.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/datumSeries.test.js +0 -0
- /package/dist/{src/app → app}/charts/series/iterateSeries.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/iterateSeries.js +0 -0
- /package/dist/{src/app → app}/charts/series/ordinalSeries.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/ordinalSeries.js +0 -0
- /package/dist/{src/app → app}/charts/series/timeSeries.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/timeSeries.js +0 -0
- /package/dist/{src/app → app}/charts/series/timeSeriesChartData.d.ts +0 -0
- /package/dist/{src/app → app}/charts/series/timeSeriesChartData.js +0 -0
- /package/dist/{src/app → app}/charts/styling/barPlotStyle.d.ts +0 -0
- /package/dist/{src/app → app}/charts/styling/barPlotStyle.js +0 -0
- /package/dist/{src/app → app}/charts/styling/margins.d.ts +0 -0
- /package/dist/{src/app → app}/charts/styling/margins.js +0 -0
- /package/dist/{src/app → app}/charts/styling/margins.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/styling/margins.test.js +0 -0
- /package/dist/{src/app → app}/charts/styling/svgStyle.d.ts +0 -0
- /package/dist/{src/app → app}/charts/styling/svgStyle.js +0 -0
- /package/dist/{src/app → app}/charts/subscriptions/subscription.test.d.ts +0 -0
- /package/dist/{src/app → app}/charts/subscriptions/subscription.test.js +0 -0
- /package/dist/{src/app → app}/charts/subscriptions/subscriptions.d.ts +0 -0
- /package/dist/{src/app → app}/charts/subscriptions/subscriptions.js +0 -0
- /package/dist/{src/app → app}/charts/tooltips/tooltipUtils.d.ts +0 -0
- /package/dist/{src/app → app}/charts/tooltips/tooltipUtils.js +0 -0
- /package/dist/{src/app → app}/charts/trackers/trackerUtils.d.ts +0 -0
- /package/dist/{src/app → app}/charts/trackers/trackerUtils.js +0 -0
- /package/dist/{src/app → app}/charts/utils.d.ts +0 -0
- /package/dist/{src/app → app}/charts/utils.js +0 -0
|
@@ -6,23 +6,19 @@ export { noop, mouseInPlotAreaFor, textWidthOf, textDimensions, formatNumber, fo
|
|
|
6
6
|
export { defaultAxisTickStyle, defaultAxesFont, defaultLineStyle, AxisLocation, addOrdinalStringAxis, labelIdFor, calculateOrdinalConstrainedZoomFor, calculateConstrainedZoomFor, ordinalAxisZoomHandler, axesZoomHandler, calculatePanFor, panHandler, panHandler2D, axesForSeriesGen, continuousAxisRanges, continuousAxisIntervals, continuousRange } from './app/charts/axes/axes';
|
|
7
7
|
export { AxisInterval } from './app/charts/axes/AxisInterval';
|
|
8
8
|
export { ContinuousAxis, } from './app/charts/axes/ContinuousAxis';
|
|
9
|
-
export { OrdinalAxis } from './app/charts/axes/OrdinalAxis';
|
|
9
|
+
export { OrdinalAxis, } from './app/charts/axes/OrdinalAxis';
|
|
10
|
+
export { EmptyAxis, } from './app/charts/axes/EmptyAxis';
|
|
10
11
|
//
|
|
11
12
|
// filters
|
|
12
13
|
//
|
|
13
14
|
export { regexFilter } from './app/charts/filters/regexFilter';
|
|
14
|
-
export
|
|
15
|
-
export { useAxes, defaultAxesValues } from './app/charts/hooks/useAxes';
|
|
16
|
-
export * from './app/charts/hooks/useChart';
|
|
15
|
+
export { useAxes, defaultAxesValues, } from './app/charts/hooks/useAxes';
|
|
17
16
|
export { useChart, } from './app/charts/hooks/useChart';
|
|
18
|
-
export * from './app/charts/hooks/useDataObservable';
|
|
19
17
|
export { useDataObservable, } from './app/charts/hooks/useDataObservable';
|
|
20
|
-
export * from './app/charts/hooks/useInitialData';
|
|
21
18
|
export { useInitialData, } from './app/charts/hooks/useInitialData';
|
|
22
|
-
export * from './app/charts/hooks/useMouse';
|
|
23
19
|
export { useMouse, defaultMouseValues, } from './app/charts/hooks/useMouse';
|
|
24
|
-
export { usePlotDimensions, defaultPlotDimensions, defaultMargin } from './app/charts/hooks/usePlotDimensions';
|
|
25
|
-
export { useTooltip, defaultTooltipValues } from './app/charts/hooks/useTooltip';
|
|
20
|
+
export { usePlotDimensions, defaultPlotDimensions, defaultMargin, } from './app/charts/hooks/usePlotDimensions';
|
|
21
|
+
export { useTooltip, defaultTooltipValues, } from './app/charts/hooks/useTooltip';
|
|
26
22
|
//
|
|
27
23
|
// observables
|
|
28
24
|
//
|
|
@@ -34,18 +30,18 @@ export { ordinalsObservable, defaultOrdinalStats, defaultOrdinalValueStats, init
|
|
|
34
30
|
// plots
|
|
35
31
|
//
|
|
36
32
|
export { createPlotContainer, setClipPathG, assignAxes } from './app/charts/plots/plot';
|
|
37
|
-
export { BarPlot } from './app/charts/plots/BarPlot';
|
|
38
|
-
export { NoCurveFactory, PoincarePlot } from './app/charts/plots/PoincarePlot';
|
|
39
|
-
export { RasterPlot } from './app/charts/plots/RasterPlot';
|
|
40
|
-
export { ScatterPlot } from './app/charts/plots/ScatterPlot';
|
|
33
|
+
export { BarPlot, } from './app/charts/plots/BarPlot';
|
|
34
|
+
export { NoCurveFactory, PoincarePlot, } from './app/charts/plots/PoincarePlot';
|
|
35
|
+
export { RasterPlot, } from './app/charts/plots/RasterPlot';
|
|
36
|
+
export { ScatterPlot, } from './app/charts/plots/ScatterPlot';
|
|
41
37
|
//
|
|
42
38
|
// series
|
|
43
39
|
//
|
|
44
40
|
export { seriesFrom, emptySeries, emptySeriesFor } from './app/charts/series/baseSeries';
|
|
45
41
|
export { emptyIterateDatum, iterateDatumOf, nonEmptyIterateDatum, iterateSeriesFromTuples, } from './app/charts/series/iterateSeries';
|
|
46
42
|
export { emptyOrdinalDatum, copyOrdinalDatum, ordinalDatumOf, nonEmptyOrdinalDatum, ordinateSeriesFromTuples, initialOrdinalChartData, } from './app/charts/series/ordinalSeries';
|
|
47
|
-
export { datumOf, emptyDatum, timeSeriesFromTuples } from './app/charts/series/timeSeries';
|
|
48
43
|
export { emptyTimeSeriesChartData, initialTimeSeriesChartData, } from './app/charts/series/timeSeriesChartData';
|
|
44
|
+
export { datumOf, emptyDatum, timeSeriesFromTuples } from './app/charts/series/timeSeries';
|
|
49
45
|
//
|
|
50
46
|
// styling
|
|
51
47
|
//
|
|
@@ -59,15 +55,19 @@ export { TimeWindowBehavior, subscriptionTimeSeriesFor, subscriptionTimeSeriesWi
|
|
|
59
55
|
//
|
|
60
56
|
// tooltips
|
|
61
57
|
//
|
|
62
|
-
export { BarPlotTooltipContent } from './app/charts/tooltips/BarPlotTooltipContent';
|
|
63
|
-
export { PoincarePlotTooltipContent } from './app/charts/tooltips/PoincarePlotTooltipContent';
|
|
64
|
-
export { RasterPlotTooltipContent } from './app/charts/tooltips/RasterPlotTooltipContent';
|
|
65
|
-
export { ScatterPlotTooltipContent } from './app/charts/tooltips/ScatterPlotTooltipContent';
|
|
66
|
-
export { Tooltip } from './app/charts/tooltips/Tooltip';
|
|
58
|
+
export { BarPlotTooltipContent, } from './app/charts/tooltips/BarPlotTooltipContent';
|
|
59
|
+
export { PoincarePlotTooltipContent, } from './app/charts/tooltips/PoincarePlotTooltipContent';
|
|
60
|
+
export { RasterPlotTooltipContent, } from './app/charts/tooltips/RasterPlotTooltipContent';
|
|
61
|
+
export { ScatterPlotTooltipContent, } from './app/charts/tooltips/ScatterPlotTooltipContent';
|
|
62
|
+
export { Tooltip, } from './app/charts/tooltips/Tooltip';
|
|
67
63
|
export { defaultTooltipStyle, removeTooltip, tooltipX, tooltipY, categoryTooltipY, boundingPoints, findPointAndNeighbors } from './app/charts/tooltips/tooltipUtils';
|
|
68
64
|
//
|
|
69
65
|
// trackers
|
|
70
66
|
//
|
|
71
67
|
export { TrackerLabelLocation, Tracker, } from './app/charts/trackers/Tracker';
|
|
72
68
|
export { defaultTrackerLabelFont, defaultTrackerStyle, trackerControlInstance, removeTrackerControl, } from './app/charts/trackers/trackerUtils';
|
|
69
|
+
//
|
|
70
|
+
// legend
|
|
71
|
+
//
|
|
72
|
+
export { Legend, defaultLegendStyle, LegendLocation } from './app/charts/legends/Legend';
|
|
73
73
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Charts for steaming data",
|
|
5
5
|
"author": "Rob Philipp",
|
|
6
6
|
"homepage": "https://robphilipp.github.io/stream-charts/",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": "github:robphilipp/stream-charts",
|
|
9
|
-
"main": "dist/
|
|
10
|
-
"types": "dist/
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"test": "jest src/app/charts/**/*.test.ts*",
|
|
13
13
|
"build": "tsc",
|
|
14
14
|
"prepare": "npm run build",
|
|
15
|
-
"gen-docs": "npx typedoc src/app/charts
|
|
15
|
+
"gen-docs": "npx typedoc src/app/charts/ --out docs/ --entryPoints src/index.ts --entryPointStrategy expand"
|
|
16
16
|
},
|
|
17
17
|
"eslintConfig": {
|
|
18
18
|
"extends": "react-app"
|
|
19
19
|
},
|
|
20
|
+
"typedocOptions": {
|
|
21
|
+
"externalSymbolLinkMappings": {
|
|
22
|
+
"result-fn": {
|
|
23
|
+
"Optional": "https://github.com/robphilipp/result-fn/blob/master/docs/Optional.md"
|
|
24
|
+
},
|
|
25
|
+
"typescript": {
|
|
26
|
+
"Set": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set",
|
|
27
|
+
"Map": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
20
31
|
"browserslist": {
|
|
21
32
|
"production": [
|
|
22
33
|
">0.2%",
|
|
@@ -46,21 +57,22 @@
|
|
|
46
57
|
"d3": "^7.9.0",
|
|
47
58
|
"data-frame-ts": "^1.0.3",
|
|
48
59
|
"jest": "^30.2.0",
|
|
49
|
-
"ts-jest": "^29.4.4",
|
|
50
60
|
"jest-util": "^30.2.0",
|
|
51
61
|
"react": "^19.1.1",
|
|
52
62
|
"react-dom": "^19.1.1",
|
|
53
63
|
"result-fn": "^0.5.0",
|
|
54
64
|
"rxjs": "^7.8.2",
|
|
55
65
|
"svg-table": "^0.1.2",
|
|
66
|
+
"ts-jest": "^29.4.4",
|
|
56
67
|
"typescript": "^5.9.2"
|
|
57
68
|
},
|
|
58
69
|
"files": [
|
|
59
70
|
"package.json",
|
|
60
71
|
"README.md",
|
|
61
72
|
"changes.md",
|
|
62
|
-
"dist/
|
|
63
|
-
"dist/
|
|
64
|
-
"src/app/charts/**"
|
|
73
|
+
"dist/app",
|
|
74
|
+
"dist/index.*",
|
|
75
|
+
"src/app/charts/**",
|
|
76
|
+
"src/index.ts"
|
|
65
77
|
]
|
|
66
78
|
}
|
package/src/app/charts/Chart.tsx
CHANGED
|
@@ -21,11 +21,34 @@ import {AxisInterval} from "./axes/AxisInterval";
|
|
|
21
21
|
const defaultBackground = '#202020';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
+
* @param chartId A unique identifier for the chart. This is used to identify the chart in the DOM.
|
|
25
|
+
* @param width The width of the chart container
|
|
26
|
+
* @param height The height of the chart container
|
|
27
|
+
* @param margin The margin between the edges of the chart container and the axes
|
|
28
|
+
* @param color The base/default color of the chart lines. This can be overridden by the {@link Props.svgStyle} property.
|
|
29
|
+
* @param backgroundColor The base/default background color. This can be overridden by the {@link Props.svgStyle} property.
|
|
30
|
+
* @param svgStyle Overrides for the SVG style
|
|
31
|
+
* @param seriesStyles Map holding the series name to the series style associated with that series.
|
|
32
|
+
* @param initialData Initial (static) data to plot before subscribing to the {@link ChartData} observable.
|
|
33
|
+
* @param asChartData Optional conversion function that converts an array of base-series with datum type D to a
|
|
34
|
+
* descendent of a {@link ChartData} object
|
|
35
|
+
* @param seriesFilter Regular expression that filters which series to display on the plot. Can be update while streaming
|
|
36
|
+
* @param seriesObservable {@link ChartData} RxJS `Observable` that feeds the chart data to display (i.e. the data stream).
|
|
37
|
+
* @param windowingTime The time-window (in milliseconds) to buffer the incoming data before updating the chart. This is
|
|
38
|
+
* a lever to reduce the lag between real-time and chart-time when a large amount of data is being
|
|
39
|
+
* sourced by the observable. Smaller time-windows result in smoother scrolling, but more updates, and
|
|
40
|
+
* possibly a larger lag.
|
|
41
|
+
* @param shouldSubscribe When switching to `true` from `false`, subscribes to the {@link seriesObservable}. When switching
|
|
42
|
+
* to `false` from `true`, unsubscribes from the {@link seriesObservable}.
|
|
43
|
+
* @param onSubscribe Callback when the chart subscribes to the {@link ChartData} observable
|
|
44
|
+
* @param onUpdateAxesBounds Callback when the time range changes. This is generally used by plots where the
|
|
45
|
+
* x-axis starts to scroll as the data streams in past the end of the current time
|
|
46
|
+
* @param onUpdateChartTime Callback for updating the current chart time. This is generally used by plots
|
|
24
47
|
* @template CD refers to the chart-data that is used by the Observable that has the stream of data.
|
|
25
48
|
* @template D refers to the datum in the data-series
|
|
26
49
|
* @template S refers to the type for the series style
|
|
27
50
|
*/
|
|
28
|
-
interface Props<CD, D, S extends SeriesStyle> {
|
|
51
|
+
export interface Props<CD, D, S extends SeriesStyle> {
|
|
29
52
|
chartId: number
|
|
30
53
|
/**
|
|
31
54
|
* The width of the chart container
|
|
@@ -60,7 +83,7 @@ interface Props<CD, D, S extends SeriesStyle> {
|
|
|
60
83
|
| INITIAL DATA
|
|
61
84
|
*/
|
|
62
85
|
/**
|
|
63
|
-
* Initial (static) data to plot before subscribing to the {@link
|
|
86
|
+
* Initial (static) data to plot before subscribing to the {@link ChartData} observable.
|
|
64
87
|
*/
|
|
65
88
|
initialData: Array<BaseSeries<D>>
|
|
66
89
|
/**
|
|
@@ -78,7 +101,7 @@ interface Props<CD, D, S extends SeriesStyle> {
|
|
|
78
101
|
| DATA STREAM
|
|
79
102
|
*/
|
|
80
103
|
/**
|
|
81
|
-
* {@link
|
|
104
|
+
* {@link ChartData} RxJS `Observable` that feeds the chart data to display (i.e. the data stream).
|
|
82
105
|
*/
|
|
83
106
|
seriesObservable?: Observable<CD>
|
|
84
107
|
/**
|
|
@@ -94,7 +117,7 @@ interface Props<CD, D, S extends SeriesStyle> {
|
|
|
94
117
|
*/
|
|
95
118
|
shouldSubscribe?: boolean
|
|
96
119
|
/**
|
|
97
|
-
* Callback when the chart subscribes to the {@link
|
|
120
|
+
* Callback when the chart subscribes to the {@link ChartData} observable
|
|
98
121
|
* @param subscription The RxJS subscription
|
|
99
122
|
*/
|
|
100
123
|
onSubscribe?: (subscription: Subscription) => void
|
|
@@ -137,7 +160,6 @@ interface Props<CD, D, S extends SeriesStyle> {
|
|
|
137
160
|
* @template S The type of the series style
|
|
138
161
|
* @template TM The type of the tooltip metadata (the data about the series). If not specified,
|
|
139
162
|
* defaults to an empty object
|
|
140
|
-
* @constructor
|
|
141
163
|
* @example
|
|
142
164
|
*
|
|
143
165
|
|
|
@@ -253,6 +275,7 @@ export function Chart<CD extends ChartData, D, S extends SeriesStyle, TM>(props:
|
|
|
253
275
|
// the container that holds the d3 svg element
|
|
254
276
|
const mainGRef = useRef<GSelection | null>(null)
|
|
255
277
|
const containerRef = useRef<SVGSVGElement>(null)
|
|
278
|
+
const hoveredSeriesRef = useRef<string | null>(null)
|
|
256
279
|
|
|
257
280
|
// creates the main <g> element for the chart if it doesn't already exist, otherwise
|
|
258
281
|
// updates the svg element with the updated dimensions or style properties
|
|
@@ -317,6 +340,7 @@ export function Chart<CD extends ChartData, D, S extends SeriesStyle, TM>(props:
|
|
|
317
340
|
svgStyle={svgStyle}
|
|
318
341
|
seriesStyles={seriesStyles}
|
|
319
342
|
seriesFilter={seriesFilter}
|
|
343
|
+
hoveredSeriesRef={hoveredSeriesRef}
|
|
320
344
|
>
|
|
321
345
|
{
|
|
322
346
|
// the chart elements are the children
|
|
@@ -53,13 +53,13 @@ export class AxesState<A extends BaseAxis> {
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Adds an axis to the current axis state and returns a new axis state. This is an internal state
|
|
56
|
-
* management function. This should generally not be used. Instead, use the {@link
|
|
57
|
-
* and {@link
|
|
56
|
+
* management function. This should generally not be used. Instead, use the {@link UseAxesValues.addXAxis}
|
|
57
|
+
* and {@link UseAxesValues.addYAxis} functions to add axes.
|
|
58
58
|
* @param axis The axis to add
|
|
59
59
|
* @param id The ID of the axis to add
|
|
60
60
|
* @return An updated axes state that has the new axis
|
|
61
|
-
* @see
|
|
62
|
-
* @see
|
|
61
|
+
* @see UseAxesValues.addXAxis
|
|
62
|
+
* @see UseAxesValues.addYAxis
|
|
63
63
|
*/
|
|
64
64
|
addAxis(axis: A, id: string): AxesState<A> {
|
|
65
65
|
const updatedAxes = this.axes.set(id, axis)
|
|
@@ -17,7 +17,7 @@ import {Datum} from "../series/timeSeries";
|
|
|
17
17
|
import {AxisInterval} from "./AxisInterval";
|
|
18
18
|
import {ContinuousAxisRange} from "./ContinuousAxisRange";
|
|
19
19
|
|
|
20
|
-
interface Props {
|
|
20
|
+
export interface Props {
|
|
21
21
|
// the unique ID of the axis
|
|
22
22
|
axisId: string
|
|
23
23
|
// the location of the axis. for x-axes, this must be either top or bottom. for
|
|
@@ -56,7 +56,6 @@ interface Props {
|
|
|
56
56
|
* React won't render it because we are updating the SVG element and don't want React
|
|
57
57
|
* involved, except to call this function if the props change.
|
|
58
58
|
* @param props The properties for the axis
|
|
59
|
-
* @constructor
|
|
60
59
|
*/
|
|
61
60
|
export function ContinuousAxis(props: Props): null {
|
|
62
61
|
const {
|
|
@@ -134,7 +133,7 @@ export function ContinuousAxis(props: Props): null {
|
|
|
134
133
|
// addXAxis(axisRef.current, axisId, AxisInterval.as(domain))
|
|
135
134
|
|
|
136
135
|
// add an update handler
|
|
137
|
-
rangeUpdateHandlerIdRef.current = `x-axis-${chartId}-${location.valueOf()}`
|
|
136
|
+
rangeUpdateHandlerIdRef.current = `x-axis-${chartId}-${axisId}-${location.valueOf()}`
|
|
138
137
|
addAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current, handleRangeUpdates)
|
|
139
138
|
|
|
140
139
|
break
|
|
@@ -152,7 +151,7 @@ export function ContinuousAxis(props: Props): null {
|
|
|
152
151
|
// addYAxis(axisRef.current, axisId, AxisInterval.as(domain))
|
|
153
152
|
|
|
154
153
|
// add an update handler
|
|
155
|
-
rangeUpdateHandlerIdRef.current = `y-axis-${chartId}-${location.valueOf()}`
|
|
154
|
+
rangeUpdateHandlerIdRef.current = `y-axis-${chartId}-${axisId}-${location.valueOf()}`
|
|
156
155
|
addAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current, handleRangeUpdates)
|
|
157
156
|
}
|
|
158
157
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {addEmptyXAxis, addEmptyYAxis, AxisLocation, ContinuousNumericAxis,} from "./axes";
|
|
2
|
+
import {useChart} from "../hooks/useChart";
|
|
3
|
+
import {useEffect, useRef} from "react";
|
|
4
|
+
import * as d3 from "d3";
|
|
5
|
+
import {Margin} from "../styling/margins";
|
|
6
|
+
import {usePlotDimensions} from "../hooks/usePlotDimensions";
|
|
7
|
+
import {Datum} from "../series/timeSeries";
|
|
8
|
+
import {AxisInterval} from "./AxisInterval";
|
|
9
|
+
import {ContinuousAxisRange} from "./ContinuousAxisRange";
|
|
10
|
+
|
|
11
|
+
export interface Props {
|
|
12
|
+
// the unique ID of the axis
|
|
13
|
+
axisId: string
|
|
14
|
+
// the location of the axis. for x-axes, this must be either top or bottom. for
|
|
15
|
+
// y-axes, this mut be either left or right
|
|
16
|
+
location: AxisLocation
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// linear scale
|
|
20
|
+
const EMPTY_AXIS_SCALE = d3.scaleLinear()
|
|
21
|
+
|
|
22
|
+
// the min and max values for the axis
|
|
23
|
+
const EMPTY_AXIS_DOMAIN: [min: number, max: number] = [0, 1]
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Represents an empty axis (x or y) that can be place on the top, bottom,
|
|
27
|
+
* left, or right of the chart. An empty axis is just a line where the axis
|
|
28
|
+
* would be, without any ticks or labels.
|
|
29
|
+
* @param props The properties for the axis
|
|
30
|
+
*/
|
|
31
|
+
export function EmptyAxis(props: Props): null {
|
|
32
|
+
const {
|
|
33
|
+
chartId,
|
|
34
|
+
container,
|
|
35
|
+
axes,
|
|
36
|
+
} = useChart<Datum, any, any, ContinuousAxisRange, ContinuousNumericAxis>()
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
addXAxis,
|
|
40
|
+
addYAxis,
|
|
41
|
+
axisRangeFor,
|
|
42
|
+
setAxisRangeFor,
|
|
43
|
+
setAxisIntervalFor,
|
|
44
|
+
} = axes
|
|
45
|
+
|
|
46
|
+
const {
|
|
47
|
+
plotDimensions,
|
|
48
|
+
margin
|
|
49
|
+
} = usePlotDimensions()
|
|
50
|
+
|
|
51
|
+
const {
|
|
52
|
+
axisId,
|
|
53
|
+
location,
|
|
54
|
+
} = props
|
|
55
|
+
|
|
56
|
+
const axisRef = useRef<ContinuousNumericAxis>(undefined)
|
|
57
|
+
const axisIdRef = useRef<string>(axisId)
|
|
58
|
+
const marginRef = useRef<Margin>(margin)
|
|
59
|
+
|
|
60
|
+
useEffect(
|
|
61
|
+
() => {
|
|
62
|
+
axisIdRef.current = axisId
|
|
63
|
+
marginRef.current = margin
|
|
64
|
+
},
|
|
65
|
+
[axisId, plotDimensions, margin]
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
useEffect(
|
|
69
|
+
() => {
|
|
70
|
+
if (container) {
|
|
71
|
+
const svg = d3.select<SVGSVGElement, any>(container)
|
|
72
|
+
|
|
73
|
+
if (axisRef.current === undefined) {
|
|
74
|
+
switch (location) {
|
|
75
|
+
case AxisLocation.Bottom:
|
|
76
|
+
case AxisLocation.Top: {
|
|
77
|
+
axisRef.current = addEmptyXAxis(
|
|
78
|
+
axisId, svg, plotDimensions, location, EMPTY_AXIS_SCALE,
|
|
79
|
+
margin, setAxisIntervalFor, EMPTY_AXIS_DOMAIN
|
|
80
|
+
)
|
|
81
|
+
// add the x-axis to the chart context
|
|
82
|
+
const [start, end] = AxisInterval.as(EMPTY_AXIS_DOMAIN).asTuple()
|
|
83
|
+
addXAxis(axisRef.current, axisId, ContinuousAxisRange.from(start, end))
|
|
84
|
+
|
|
85
|
+
break
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
case AxisLocation.Left:
|
|
89
|
+
case AxisLocation.Right: {
|
|
90
|
+
axisRef.current = addEmptyYAxis(
|
|
91
|
+
axisId, svg, plotDimensions, location, EMPTY_AXIS_SCALE,
|
|
92
|
+
margin, setAxisIntervalFor, EMPTY_AXIS_DOMAIN
|
|
93
|
+
)
|
|
94
|
+
// add the y-axis to the chart context
|
|
95
|
+
const [start, end] = AxisInterval.as(EMPTY_AXIS_DOMAIN).asTuple()
|
|
96
|
+
addYAxis(axisRef.current, axisId, ContinuousAxisRange.from(start, end))
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
const axisRange = axisRangeFor(axisId)
|
|
101
|
+
const domain = axisRange
|
|
102
|
+
.map(range => range.current)
|
|
103
|
+
.getOrElse(AxisInterval.empty())
|
|
104
|
+
if (domain.isNotEmpty()) {
|
|
105
|
+
axisRef.current.update(domain, plotDimensions, margin)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
[
|
|
111
|
+
chartId, axisId, location, addXAxis, addYAxis,
|
|
112
|
+
container, margin, plotDimensions, setAxisIntervalFor,
|
|
113
|
+
axisRangeFor,
|
|
114
|
+
setAxisRangeFor,
|
|
115
|
+
]
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
return null
|
|
119
|
+
}
|
|
@@ -18,7 +18,7 @@ import {OrdinalAxisRange} from "./OrdinalAxisRange";
|
|
|
18
18
|
import {Datum} from "../series/timeSeries";
|
|
19
19
|
import {AxisInterval} from "./AxisInterval";
|
|
20
20
|
|
|
21
|
-
interface Props {
|
|
21
|
+
export interface Props {
|
|
22
22
|
// the unique ID of the axis
|
|
23
23
|
axisId: string
|
|
24
24
|
// the location of the axis. for y-axes, this mut be either left or right,
|
|
@@ -59,7 +59,6 @@ interface Props {
|
|
|
59
59
|
* be the name of the series used to represent each category.
|
|
60
60
|
* @param props The properties for the component
|
|
61
61
|
* @return null
|
|
62
|
-
* @constructor
|
|
63
62
|
*/
|
|
64
63
|
export function OrdinalAxis(props: Props): null {
|
|
65
64
|
const {
|
|
@@ -77,6 +76,7 @@ export function OrdinalAxis(props: Props): null {
|
|
|
77
76
|
setAxisIntervalFor,
|
|
78
77
|
axisRangeFor,
|
|
79
78
|
addAxesRangesUpdateHandler,
|
|
79
|
+
removeAxesRangesUpdateHandler,
|
|
80
80
|
setOriginalAxisIntervalFor,
|
|
81
81
|
} = axes
|
|
82
82
|
|
|
@@ -136,7 +136,7 @@ export function OrdinalAxis(props: Props): null {
|
|
|
136
136
|
addXAxis(xAxis, axisId, OrdinalAxisRange.from(start, end))
|
|
137
137
|
|
|
138
138
|
// add an update handler
|
|
139
|
-
rangeUpdateHandlerIdRef.current = `x-axis-${chartId}-${location.valueOf()}`
|
|
139
|
+
rangeUpdateHandlerIdRef.current = `x-axis-${chartId}-${axisId}-${location.valueOf()}`
|
|
140
140
|
addAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current, handleRangeUpdates)
|
|
141
141
|
break
|
|
142
142
|
}
|
|
@@ -152,7 +152,7 @@ export function OrdinalAxis(props: Props): null {
|
|
|
152
152
|
const [start, end] = AxisInterval.as(yAxis.scale.range()).asTuple()
|
|
153
153
|
addYAxis(yAxis, axisId, OrdinalAxisRange.from(start, end))
|
|
154
154
|
// add an update handler
|
|
155
|
-
rangeUpdateHandlerIdRef.current = `y-axis-${chartId}-${location.valueOf()}`
|
|
155
|
+
rangeUpdateHandlerIdRef.current = `y-axis-${chartId}-${axisId}-${location.valueOf()}`
|
|
156
156
|
addAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current, handleRangeUpdates)
|
|
157
157
|
}
|
|
158
158
|
}
|
|
@@ -218,6 +218,17 @@ export function OrdinalAxis(props: Props): null {
|
|
|
218
218
|
]
|
|
219
219
|
);
|
|
220
220
|
|
|
221
|
+
useEffect(
|
|
222
|
+
() => {
|
|
223
|
+
return () => {
|
|
224
|
+
if (rangeUpdateHandlerIdRef.current) {
|
|
225
|
+
removeAxesRangesUpdateHandler(rangeUpdateHandlerIdRef.current)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
[removeAxesRangesUpdateHandler]
|
|
230
|
+
)
|
|
231
|
+
|
|
221
232
|
return null
|
|
222
233
|
}
|
|
223
234
|
|
|
@@ -616,6 +616,122 @@ function ordinalLabelYTranslation(
|
|
|
616
616
|
continuous numeric axes
|
|
617
617
|
*/
|
|
618
618
|
|
|
619
|
+
/**
|
|
620
|
+
* Adds a new empty x-axis to the SVG element at the specified location. An empty axis
|
|
621
|
+
* is just a line where the axis would be, without any ticks or labels.
|
|
622
|
+
* @param axisId The ID of the axis
|
|
623
|
+
* @param svg The SVG selection to which to add the axis
|
|
624
|
+
* @param plotDimensions The dimensions of the plot
|
|
625
|
+
* @param location The location of the axis
|
|
626
|
+
* @param scaleGenerator The higher-order function that returns the axis d3 "scale" function
|
|
627
|
+
* @param domain The axis range (start, end)
|
|
628
|
+
* @param margin The plot margins for the border of main SVG group
|
|
629
|
+
* @param setAxisRangeFor A callback used to set the axis range
|
|
630
|
+
* @return A {@link ContinuousNumericAxis} based on the arguments to this function
|
|
631
|
+
*/
|
|
632
|
+
export function addEmptyXAxis(
|
|
633
|
+
axisId: string,
|
|
634
|
+
svg: SvgSelection,
|
|
635
|
+
plotDimensions: Dimensions,
|
|
636
|
+
location: AxisLocation.Bottom | AxisLocation.Top,
|
|
637
|
+
scaleGenerator: ScaleContinuousNumeric<number, number>,
|
|
638
|
+
margin: Margin,
|
|
639
|
+
setAxisRangeFor: (axisId: string, timeRange: AxisInterval) => void,
|
|
640
|
+
domain: [minValue: number, maxValue: number] = [0, 1],
|
|
641
|
+
): ContinuousNumericAxis {
|
|
642
|
+
const scale = scaleGenerator.domain(domain).range([0, plotDimensions.width])
|
|
643
|
+
|
|
644
|
+
const selection = svg
|
|
645
|
+
.append<SVGGElement>('g')
|
|
646
|
+
.attr('transform', `translate(${margin.left}, ${yTranslation(location, plotDimensions, margin)})`)
|
|
647
|
+
|
|
648
|
+
const line = selection.append('line')
|
|
649
|
+
.attr('x1', 0)
|
|
650
|
+
.attr('y1', 0)
|
|
651
|
+
.attr('x2', plotDimensions.width)
|
|
652
|
+
.attr('y2', 0)
|
|
653
|
+
.attr('stroke', 'currentColor')
|
|
654
|
+
|
|
655
|
+
const axis: ContinuousNumericAxis = {
|
|
656
|
+
axisId,
|
|
657
|
+
location,
|
|
658
|
+
selection,
|
|
659
|
+
scale,
|
|
660
|
+
generator: d3.axisBottom(scale).tickValues([]).tickSize(0),
|
|
661
|
+
update: noop
|
|
662
|
+
}
|
|
663
|
+
return {
|
|
664
|
+
...axis,
|
|
665
|
+
update: (domain: AxisInterval, plotDimensions: Dimensions, margin: Margin) => {
|
|
666
|
+
axis.scale.domain(domain.asTuple()).range([0, plotDimensions.width])
|
|
667
|
+
axis.selection
|
|
668
|
+
.attr('transform', `translate(${margin.left}, ${yTranslation(location, plotDimensions, margin)})`)
|
|
669
|
+
|
|
670
|
+
line.attr('x2', plotDimensions.width)
|
|
671
|
+
|
|
672
|
+
setAxisRangeFor(axisId, domain)
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Adds a new empty y-axis to the SVG element at the specified location. An empty axis
|
|
679
|
+
* is just a line where the axis would be, without any ticks or labels.
|
|
680
|
+
* @param axisId The ID of the axis
|
|
681
|
+
* @param svg The SVG selection to which to add the axis
|
|
682
|
+
* @param plotDimensions The dimensions of the plot
|
|
683
|
+
* @param location The location of the axis
|
|
684
|
+
* @param scaleGenerator The higher-order function that returns the axis d3 "scale" function
|
|
685
|
+
* @param domain The axis range (start, end)
|
|
686
|
+
* @param margin The plot margins for the border of main SVG group
|
|
687
|
+
* @param setAxisRangeFor A callback used to set the axis range
|
|
688
|
+
* @return A {@link ContinuousNumericAxis} based on the arguments to this function
|
|
689
|
+
*/
|
|
690
|
+
export function addEmptyYAxis(
|
|
691
|
+
axisId: string,
|
|
692
|
+
svg: SvgSelection,
|
|
693
|
+
plotDimensions: Dimensions,
|
|
694
|
+
location: AxisLocation.Left | AxisLocation.Right,
|
|
695
|
+
scaleGenerator: ScaleContinuousNumeric<number, number>,
|
|
696
|
+
margin: Margin,
|
|
697
|
+
setAxisRangeFor: (axisId: string, timeRange: AxisInterval) => void,
|
|
698
|
+
domain: [minValue: number, maxValue: number] = [0, 1],
|
|
699
|
+
): ContinuousNumericAxis {
|
|
700
|
+
const scale = scaleGenerator.domain(domain).range([plotDimensions.height, 0])
|
|
701
|
+
|
|
702
|
+
const selection = svg
|
|
703
|
+
.append<SVGGElement>('g')
|
|
704
|
+
.attr('transform', `translate(${xTranslation(location, plotDimensions, margin)}, ${margin.top})`)
|
|
705
|
+
|
|
706
|
+
const line = selection.append('line')
|
|
707
|
+
.attr('x1', 0)
|
|
708
|
+
.attr('y1', 0)
|
|
709
|
+
.attr('x2', 0)
|
|
710
|
+
.attr('y2', plotDimensions.height)
|
|
711
|
+
.attr('stroke', 'currentColor')
|
|
712
|
+
|
|
713
|
+
const axis: ContinuousNumericAxis = {
|
|
714
|
+
axisId,
|
|
715
|
+
location,
|
|
716
|
+
selection,
|
|
717
|
+
scale,
|
|
718
|
+
generator: d3.axisLeft(scale).tickValues([]).tickSize(0),
|
|
719
|
+
update: noop
|
|
720
|
+
}
|
|
721
|
+
return {
|
|
722
|
+
...axis,
|
|
723
|
+
update: (domain: AxisInterval, plotDimensions: Dimensions, margin: Margin) => {
|
|
724
|
+
axis.scale.domain(domain.asTuple()).range([plotDimensions.height, 0])
|
|
725
|
+
axis.selection
|
|
726
|
+
.attr('transform', `translate(${xTranslation(location, plotDimensions, margin)}, ${margin.top})`)
|
|
727
|
+
|
|
728
|
+
line.attr('y2', plotDimensions.height)
|
|
729
|
+
|
|
730
|
+
setAxisRangeFor(axisId, domain)
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
619
735
|
/**
|
|
620
736
|
* Adds a new x-axis to the SVG element at the specified location
|
|
621
737
|
* @param chartId The ID of the chart
|
|
@@ -653,13 +769,13 @@ export function addContinuousNumericXAxis(
|
|
|
653
769
|
svg
|
|
654
770
|
.append<SVGTextElement>('text')
|
|
655
771
|
.attr('id', labelIdFor(chartId, location))
|
|
656
|
-
.
|
|
772
|
+
.attr('text-anchor', 'middle')
|
|
657
773
|
// when the axis is at the top, want the label to hang from the top (y=0) of the plot
|
|
658
|
-
.
|
|
659
|
-
.
|
|
660
|
-
.
|
|
661
|
-
.
|
|
662
|
-
.
|
|
774
|
+
.attr('dominant-baseline', location === AxisLocation.Top ? "hanging" : "baseline")
|
|
775
|
+
.attr('font-size', axesLabelFont.size)
|
|
776
|
+
.attr('fill', axesLabelFont.color)
|
|
777
|
+
.attr('font-family', axesLabelFont.family)
|
|
778
|
+
.attr('font-weight', axesLabelFont.weight)
|
|
663
779
|
.attr('transform', `translate(${margin.left + plotDimensions.width / 2}, ${continuousLabelYTranslation(location, plotDimensions, margin)})`)
|
|
664
780
|
.text(axisLabel)
|
|
665
781
|
|
|
@@ -28,7 +28,7 @@ export type UseAxesValues<AR extends BaseAxisRange, A extends BaseAxis> = {
|
|
|
28
28
|
* Adds an x-axis to the axes and updates the internal state
|
|
29
29
|
* @param axis The axis to add
|
|
30
30
|
* @param id The ID of the axis to add
|
|
31
|
-
* @param
|
|
31
|
+
* @param range The initial axis range (start, end)
|
|
32
32
|
*/
|
|
33
33
|
addXAxis: (axis: A, id: string, range?: AR) => void
|
|
34
34
|
/**
|
|
@@ -39,7 +39,7 @@ export type UseAxesValues<AR extends BaseAxisRange, A extends BaseAxis> = {
|
|
|
39
39
|
* Adds a y-axis to the axes and updates the internal state
|
|
40
40
|
* @param axis The axis to add
|
|
41
41
|
* @param id The ID of the axis to add
|
|
42
|
-
* @param
|
|
42
|
+
* @param range The initial axis range (start, end)
|
|
43
43
|
*/
|
|
44
44
|
addYAxis: (axis: A, id: string, range?: AR) => void
|
|
45
45
|
/**
|
|
@@ -153,7 +153,7 @@ export const defaultAxesValues = (): UseAxesValues<any, any> => ({
|
|
|
153
153
|
// the context for axes
|
|
154
154
|
const AxesContext = createContext<UseAxesValues<any, any>>(defaultAxesValues())
|
|
155
155
|
|
|
156
|
-
type Props = {
|
|
156
|
+
export type Props = {
|
|
157
157
|
/**y
|
|
158
158
|
* Callback when axes bounds change.
|
|
159
159
|
* @param ranges The ranges (start, end) for each axis in the plot
|
|
@@ -167,7 +167,6 @@ type Props = {
|
|
|
167
167
|
* The React context provider for the {@link UseAxesValues}
|
|
168
168
|
* @param props The properties
|
|
169
169
|
* @return The children wrapped in this provider
|
|
170
|
-
* @constructor
|
|
171
170
|
*/
|
|
172
171
|
export default function AxesProvider<AR extends BaseAxisRange, A extends BaseAxis>(props: Props): JSX.Element {
|
|
173
172
|
const {onUpdateAxesInterval, children} = props
|