swiftplot 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,5 +9,5 @@ export { areaChart, barChart, lineChart, scatterChart } from './xy.js';
9
9
  export { equal, plain } from '../equal.js';
10
10
  export type { EasyChart } from './controller.js';
11
11
  export { mount } from './mount.js';
12
- export type { Mount } from './mount.js';
13
- export type { AreaProps as AreaChartProps, BarProps as BarChartProps, BoxPlotProps as BoxPlotChartProps, CandlestickProps as CandlestickChartProps, ComboProps as ComboChartProps, FunnelProps as FunnelChartProps, HeatmapProps as HeatmapChartProps, HistogramProps as HistogramChartProps, LineProps as LineChartProps, PieProps as PieChartProps, RadarProps as RadarChartProps, RadialBarProps as RadialBarChartProps, SankeyProps as SankeyChartProps, ScatterProps as ScatterChartProps, SunburstProps as SunburstChartProps, TreemapProps as TreemapChartProps, } from './types.js';
12
+ export type { Mount, PlotOptions } from './mount.js';
13
+ export type { AreaProps as AreaChartProps, BarProps as BarChartProps, BoxPlotProps as BoxPlotChartProps, CandlestickProps as CandlestickChartProps, ComboProps as ComboChartProps, FunnelProps as FunnelChartProps, HeatmapProps as HeatmapChartProps, HistogramProps as HistogramChartProps, LineProps as LineChartProps, PieProps as PieChartProps, RadarProps as RadarChartProps, RadialBarProps as RadialBarChartProps, SankeyProps as SankeyChartProps, ScatterProps as ScatterChartProps, SunburstProps as SunburstChartProps, TreemapProps as TreemapChartProps, ScaledY2AxisProps, ScaledYAxisProps, XAxisProps, Y2AxisProps, YAxisProps, } from './types.js';
@@ -1,5 +1,7 @@
1
1
  import type { Options } from '../types.js';
2
2
  import { type EasyChart } from './controller.js';
3
+ import type { Base } from './types.js';
3
4
  export type Mount<P> = (el: HTMLElement, props: P) => EasyChart<P>;
5
+ export type PlotOptions = Omit<Options, 'theme'> & Pick<Base, 'theme'>;
4
6
  /** plot() behind the easy charts' controller: an update sends the core only the options that changed. */
5
- export declare const mount: Mount<Options>;
7
+ export declare const mount: Mount<PlotOptions>;
@@ -1,24 +1,11 @@
1
- import { light } from '../theme.js';
2
1
  import { create, PASSED } from './controller.js';
3
2
  /** plot() behind the easy charts' controller: an update sends the core only the options that changed. */
4
3
  export const mount = (el, options) => {
5
4
  const use = options.use ?? [];
6
- const c = create(el, { ...options, theme: options.theme ?? light }, props => {
5
+ return create(el, options, (props, { theme }) => {
7
6
  const { use: _, ...rest } = props;
8
7
  for (const k of PASSED)
9
8
  delete rest[k];
10
- return { options: rest, features: null, use: () => use };
9
+ return { options: { ...rest, theme }, features: null, use: () => use };
11
10
  });
12
- return {
13
- get chart() {
14
- return c.chart;
15
- },
16
- get overlay() {
17
- return c.overlay;
18
- },
19
- update(partial) {
20
- c.update('theme' in partial ? { ...partial, theme: partial.theme ?? light } : partial);
21
- },
22
- destroy: () => c.destroy(),
23
- };
24
11
  };
@@ -56,15 +56,16 @@ type Aligned = {
56
56
  /** 'zero' puts zero at the same height on y and y2, widening each to take it in; a number given in `domain` is never moved, and both axes must be linear. */
57
57
  align?: 'zero';
58
58
  };
59
- type ScaledYAxisProps = YAxisProps & {
59
+ export type ScaledYAxisProps = YAxisProps & {
60
60
  /** 'log' spaces equal ratios equally; a value at or below zero is then a gap, and `step` does not apply. @default 'linear' */
61
61
  scale?: 'linear' | 'log';
62
62
  };
63
+ export type ScaledY2AxisProps = ScaledYAxisProps & Aligned;
63
64
  export type ScaledAxes = {
64
65
  /** Settings for the y axis. */
65
66
  yAxis?: ScaledYAxisProps;
66
67
  /** Settings for the right-hand axis of `y2`, which is drawn only with it. */
67
- y2Axis?: ScaledYAxisProps & Aligned;
68
+ y2Axis?: ScaledY2AxisProps;
68
69
  };
69
70
  /** A date, as a Date, in ms or as an ISO string, a number, or a category: whichever the x axis shows. */
70
71
  export type XValue = number | string | Date;
@@ -112,9 +113,10 @@ export type Overlays = {
112
113
  /** Called with the range brushed, in axis values, on release, and with null once a range left standing is cleared. */
113
114
  onBrush?: BrushOptions['onSelect'];
114
115
  };
116
+ export type Y2AxisProps = YAxisProps & Aligned;
115
117
  export type SecondAxis = {
116
118
  /** Settings for the right-hand axis of `y2`, which is drawn only with it. */
117
- y2Axis?: YAxisProps & Aligned;
119
+ y2Axis?: Y2AxisProps;
118
120
  };
119
121
  export type Base = {
120
122
  /** Bump after changing the data in place, so that it is converted again. */
@@ -573,7 +575,7 @@ type ComboBase = Axes & ScaledAxes & Overlays & Base & {
573
575
  /** Settings for the y axis; a log scale is for lines alone. */
574
576
  yAxis?: ScaledYAxisProps;
575
577
  /** Settings for the right-hand axis of `y2Lines` and `y2Bars`, drawn only with one of them; a log scale is for lines alone. */
576
- y2Axis?: ScaledYAxisProps & Aligned;
578
+ y2Axis?: ScaledY2AxisProps;
577
579
  };
578
580
  export type ComboRowProps<R> = ComboBase & {
579
581
  /** Row objects; missing, null or empty draws an empty frame. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swiftplot",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Small, fast charts on Canvas 2D and WebGL2",
5
5
  "keywords": [
6
6
  "chart",