@reside-ic/skadi-chart 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 CHANGED
@@ -107,6 +107,7 @@ class CustomLayer extends OptionalLayer {
107
107
  new Chart()
108
108
  .addAxes()
109
109
  .addTraces(lines)
110
+ .addArea()
110
111
  .addScatterPoints(points)
111
112
  .addGridLines()
112
113
  .addZoom()
@@ -165,6 +166,11 @@ fixed scale.
165
166
  ```ts
166
167
  chart.addTraces(lines);
167
168
  ```
169
+ * `addArea` adds an [AreaLayer](./src/layers/AreaLayer.ts). This will add an area underneath
170
+ the traces to the graph.
171
+ ```ts
172
+ chart.addArea();
173
+ ```
168
174
  * `addScatterPoints` add a [ScatterLayer](./src/layers/ScatterLayer.ts). This will add
169
175
  scatter points to the graph. This data will also be used for autoscaling the axes if you
170
176
  haven't provided a fixed scale.
@@ -74,16 +74,19 @@ declare module "types" {
74
74
  end?: number;
75
75
  }>>;
76
76
  export type LineStyle = {
77
- color?: string;
77
+ strokeColor?: string;
78
78
  opacity?: number;
79
79
  strokeWidth?: number;
80
80
  strokeDasharray?: string;
81
+ fillColor?: string;
82
+ fillOpacity?: number;
81
83
  };
82
84
  export type LineConfig<Metadata> = {
83
85
  points: Point[];
84
86
  style: LineStyle;
85
87
  metadata?: Metadata;
86
88
  bands?: Partial<XY<string>>;
89
+ fill?: boolean;
87
90
  };
88
91
  export type Lines<Metadata> = LineConfig<Metadata>[];
89
92
  export type ScatterPointStyle = {
@@ -103,6 +106,7 @@ declare module "layers/Layer" {
103
106
  ClipPath = "clipPath",
104
107
  BaseLayer = "baseLayer",
105
108
  Axes = "axes",
109
+ Area = "area",
106
110
  Zoom = "zoom",
107
111
  Trace = "trace",
108
112
  Tooltip = "skadi-chart-tooltip",
@@ -138,8 +142,11 @@ declare module "layers/AxesLayer" {
138
142
  }
139
143
  }
140
144
  declare module "helpers" {
141
- import { LayerArgs, ScaleNumeric, XY } from "types";
145
+ import { LayerArgs, ScaleNumeric, XY, Point, ZoomExtents, Scales } from "types";
146
+ export const customLineGen: (lineSC: Point[], zoomExtents: ZoomExtents) => string[];
142
147
  export const numScales: (bands: Partial<XY<string>> | undefined, layerArgs: LayerArgs) => XY<ScaleNumeric>;
148
+ export const getXYMinMax: (points: Point[]) => Scales;
149
+ export const getSvgRectPath: (xStart: number, xEnd: number, yStart: number, yEnd: number) => string;
143
150
  }
144
151
  declare module "layers/TracesLayer" {
145
152
  import { LayerArgs, Lines, Point, ZoomExtents } from "types";
@@ -153,13 +160,11 @@ declare module "layers/TracesLayer" {
153
160
  options: TracesOptions;
154
161
  type: LayerType;
155
162
  private traces;
156
- private lowResLinesSC;
157
- private getNewPoint;
163
+ lowResLinesSC: Point[][];
164
+ getNewPoint: null | ((x: number, y: number, t: number) => Point);
165
+ getNewPointInverse: null | ((x: number, y: number, t: number) => Point);
158
166
  constructor(linesDC: Lines<Metadata>, options: TracesOptions);
159
167
  private customTween;
160
- private round;
161
- private getNewSvgPoint;
162
- private customLineGen;
163
168
  private updateLowResLinesSC;
164
169
  draw: (layerArgs: LayerArgs, currentExtentsDC: ZoomExtents) => void;
165
170
  }
@@ -219,6 +224,27 @@ declare module "layers/GridLayer" {
219
224
  draw: (layerArgs: LayerArgs) => void;
220
225
  }
221
226
  }
227
+ declare module "layers/AreaLayer" {
228
+ import { LayerArgs, ZoomExtents } from "types";
229
+ import { LayerType, OptionalLayer } from "layers/Layer";
230
+ type LineBoundaryInfo = {
231
+ xMinDC: number;
232
+ xMaxDC: number;
233
+ canvasPath: Path2D;
234
+ yCoordForXAxisSC: number;
235
+ xMinSC: number;
236
+ xMaxSC: number;
237
+ };
238
+ export class AreaLayer<Metadata> extends OptionalLayer {
239
+ type: LayerType;
240
+ ctx: CanvasRenderingContext2D;
241
+ lineBoundaryInfo: (LineBoundaryInfo | null)[][];
242
+ constructor();
243
+ draw(layerArgs: LayerArgs, currentExtentsDC: ZoomExtents): void;
244
+ private customTween;
245
+ private closeSvgPath;
246
+ }
247
+ }
222
248
  declare module "Chart" {
223
249
  import { TracesOptions } from "layers/TracesLayer";
224
250
  import { ZoomOptions } from "layers/ZoomLayer";
@@ -264,6 +290,7 @@ declare module "Chart" {
264
290
  private filterLinesForLogAxis;
265
291
  private filterLines;
266
292
  addTraces: (lines: Lines<Metadata>, options?: Partial<TracesOptions>) => this;
293
+ addArea: () => this;
267
294
  addZoom: (options?: ZoomOptions) => this;
268
295
  addTooltips: (tooltipHtmlCallback: TooltipHtmlCallback<Metadata>) => this;
269
296
  private filterScatterPointsForLogAxis;
@@ -272,7 +299,6 @@ declare module "Chart" {
272
299
  addCustomLifecycleHooks: (lifecycleHooks: Partial<LifecycleHooks>) => this;
273
300
  addCustomLayer: (customLayer: OptionalLayer) => this;
274
301
  makeResponsive: () => this;
275
- private getXYMinMax;
276
302
  private addLinearPadding;
277
303
  private addLogPadding;
278
304
  private processScales;