@reside-ic/skadi-chart 1.1.2 → 1.1.4
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 +6 -5
- package/dist/skadi-chart.d.ts +19 -7
- package/dist/skadi-chart.js +1099 -1089
- package/dist/skadi-chart.umd.cjs +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,14 +41,15 @@ const chart = document.getElementById("chart") as HTMLDivElement;
|
|
|
41
41
|
// example custom metadata: define a type that you can attach to lines or scatter points
|
|
42
42
|
type Metadata = { type: "line" | "point" }
|
|
43
43
|
|
|
44
|
-
// two straight lines
|
|
44
|
+
// two straight lines, first one will also display the area underneath the trace
|
|
45
45
|
const lines: Lines<Metadata> = [
|
|
46
46
|
{
|
|
47
47
|
points: [
|
|
48
48
|
{ x: 0, y: 0 },
|
|
49
49
|
{ x: 1, y: 1 },
|
|
50
50
|
],
|
|
51
|
-
|
|
51
|
+
fill: true,
|
|
52
|
+
style: { color: "black", fillColor: "blue", fillOpacity: 0.5 },
|
|
52
53
|
metadata: { type: "line" }
|
|
53
54
|
},
|
|
54
55
|
{
|
|
@@ -97,7 +98,7 @@ class CustomLayer extends OptionalLayer {
|
|
|
97
98
|
const svg = layerArgs.coreLayers[LayerType.Svg];
|
|
98
99
|
const { getHtmlId } = layerArgs;
|
|
99
100
|
svg.append("svg:circle")
|
|
100
|
-
.attr("id",
|
|
101
|
+
.attr("id", `circle-${getHtmlId(this.type)}`)
|
|
101
102
|
.attr("cx", "50%")
|
|
102
103
|
.attr("cy", "50%")
|
|
103
104
|
.attr("r", "5%")
|
|
@@ -167,7 +168,7 @@ fixed scale.
|
|
|
167
168
|
chart.addTraces(lines);
|
|
168
169
|
```
|
|
169
170
|
* `addArea` adds an [AreaLayer](./src/layers/AreaLayer.ts). This will add an area underneath
|
|
170
|
-
the traces to the graph.
|
|
171
|
+
the traces that specify `{ fill: true }` property in their config to the graph.
|
|
171
172
|
```ts
|
|
172
173
|
chart.addArea();
|
|
173
174
|
```
|
|
@@ -229,7 +230,7 @@ class CustomLayer extends OptionalLayer {
|
|
|
229
230
|
const svg = layerArgs.coreLayers[LayerType.Svg];
|
|
230
231
|
const { getHtmlId } = layerArgs;
|
|
231
232
|
svg.append("svg:circle")
|
|
232
|
-
.attr("id",
|
|
233
|
+
.attr("id", `circle-${getHtmlId(this.type)}`)
|
|
233
234
|
.attr("cx", "50%")
|
|
234
235
|
.attr("cy", "50%")
|
|
235
236
|
.attr("r", "5%")
|
package/dist/skadi-chart.d.ts
CHANGED
|
@@ -29,6 +29,9 @@ declare module "types" {
|
|
|
29
29
|
right: number;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
+
export type ClipPathBounds = Partial<Omit<Bounds, "margin">> & {
|
|
33
|
+
margin?: Partial<Bounds["margin"]>;
|
|
34
|
+
};
|
|
32
35
|
export type D3Selection<Element extends d3.BaseType> = d3.Selection<Element, Point, null, undefined>;
|
|
33
36
|
export type AllOptionalLayers = OptionalLayer<any>;
|
|
34
37
|
export type ScaleNumeric = d3.ScaleContinuousNumeric<number, number, never>;
|
|
@@ -44,12 +47,13 @@ declare module "types" {
|
|
|
44
47
|
id: string;
|
|
45
48
|
getHtmlId: (layer: LayerType) => string;
|
|
46
49
|
bounds: Bounds;
|
|
50
|
+
clipPathBounds: Bounds;
|
|
47
51
|
globals: {
|
|
48
52
|
animationDuration: number;
|
|
49
53
|
tickConfig: XY<TickConfig>;
|
|
50
54
|
};
|
|
51
55
|
scaleConfig: {
|
|
52
|
-
|
|
56
|
+
numericalScales: XY<ScaleNumeric>;
|
|
53
57
|
scaleExtents: Scales;
|
|
54
58
|
categoricalScales: Partial<XY<CategoricalScaleConfig>>;
|
|
55
59
|
};
|
|
@@ -142,8 +146,8 @@ declare module "layers/AxesLayer" {
|
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
declare module "helpers" {
|
|
145
|
-
import { LayerArgs, ScaleNumeric, XY, Point,
|
|
146
|
-
export const customLineGen: (lineSC: Point[],
|
|
149
|
+
import { LayerArgs, ScaleNumeric, XY, Point, Scales } from "types";
|
|
150
|
+
export const customLineGen: (lineSC: Point[], layerArgs: LayerArgs) => string[];
|
|
147
151
|
export const numScales: (bands: Partial<XY<string>> | undefined, layerArgs: LayerArgs) => XY<ScaleNumeric>;
|
|
148
152
|
export const getXYMinMax: (points: Point[]) => Scales;
|
|
149
153
|
export const getSvgRectPath: (xStart: number, xEnd: number, yStart: number, yEnd: number) => string;
|
|
@@ -219,8 +223,15 @@ declare module "layers/GridLayer" {
|
|
|
219
223
|
import { LayerArgs } from "types";
|
|
220
224
|
import { LayerType, OptionalLayer } from "layers/Layer";
|
|
221
225
|
export class GridLayer extends OptionalLayer {
|
|
226
|
+
directions: {
|
|
227
|
+
x: boolean;
|
|
228
|
+
y: boolean;
|
|
229
|
+
};
|
|
222
230
|
type: LayerType;
|
|
223
|
-
constructor(
|
|
231
|
+
constructor(directions: {
|
|
232
|
+
x: boolean;
|
|
233
|
+
y: boolean;
|
|
234
|
+
});
|
|
224
235
|
draw: (layerArgs: LayerArgs) => void;
|
|
225
236
|
}
|
|
226
237
|
}
|
|
@@ -249,7 +260,7 @@ declare module "Chart" {
|
|
|
249
260
|
import { TracesOptions } from "layers/TracesLayer";
|
|
250
261
|
import { ZoomOptions } from "layers/ZoomLayer";
|
|
251
262
|
import { TooltipHtmlCallback } from "layers/TooltipsLayer";
|
|
252
|
-
import { AllOptionalLayers, Lines, PartialScales, Scales, ScatterPoints, XY, XYLabel } from "types";
|
|
263
|
+
import { AllOptionalLayers, Lines, PartialScales, Scales, ScatterPoints, XY, XYLabel, ClipPathBounds } from "types";
|
|
253
264
|
import { LifecycleHooks, OptionalLayer } from "layers/Layer";
|
|
254
265
|
export type ChartOptions = {
|
|
255
266
|
logScale: XY<boolean>;
|
|
@@ -286,7 +297,7 @@ declare module "Chart" {
|
|
|
286
297
|
autoscaledMaxExtents: Scales;
|
|
287
298
|
constructor(options?: PartialChartOptions);
|
|
288
299
|
addAxes: (labels?: XYLabel) => this;
|
|
289
|
-
addGridLines: () => this;
|
|
300
|
+
addGridLines: (directions?: Partial<XY<boolean>>) => this;
|
|
290
301
|
private filterLinesForLogAxis;
|
|
291
302
|
private filterLines;
|
|
292
303
|
addTraces: (lines: Lines<Metadata>, options?: Partial<TracesOptions>) => this;
|
|
@@ -302,8 +313,9 @@ declare module "Chart" {
|
|
|
302
313
|
private addLinearPadding;
|
|
303
314
|
private addLogPadding;
|
|
304
315
|
private processScales;
|
|
316
|
+
private appendClipPath;
|
|
305
317
|
private draw;
|
|
306
|
-
appendTo: (baseElement: HTMLDivElement, maxExtents?: PartialScales, initialExtents?: PartialScales, categoricalScales?: CategoricalScales) => this;
|
|
318
|
+
appendTo: (baseElement: HTMLDivElement, maxExtents?: PartialScales, initialExtents?: PartialScales, categoricalScales?: CategoricalScales, clipPathBoundsOptions?: ClipPathBounds) => this;
|
|
307
319
|
private createCategoricalScale;
|
|
308
320
|
}
|
|
309
321
|
}
|