@qtsurfer/sveltecharts 0.12.0 → 0.13.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/dist/LightweightTimeSeriesChartBuilder.d.ts +2 -7
- package/dist/LightweightTimeSeriesChartBuilder.d.ts.map +1 -1
- package/dist/LightweightTimeSeriesChartBuilder.js +8 -48
- package/dist/TimeSeriesChartBuilder.d.ts +1 -6
- package/dist/TimeSeriesChartBuilder.d.ts.map +1 -1
- package/dist/TimeSeriesChartBuilder.js +4 -47
- package/dist/chartAdapter.d.ts +1 -7
- package/dist/chartAdapter.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type IChartApi } from 'lightweight-charts';
|
|
2
|
-
import type { ChartDataset,
|
|
2
|
+
import type { ChartDataset, ChartDatasetFormatSimpleObject, ChartMarkerPointOptions, OHLCDimensions, TimeSeriesChartAdapter } from './chartAdapter';
|
|
3
3
|
type ConfigBuilder = {
|
|
4
4
|
externalManagerLegend?: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare function getPricePrecision(values:
|
|
6
|
+
export declare function getPricePrecision(values: number[]): number;
|
|
7
7
|
export declare function formatPreciseValue(value: number): string;
|
|
8
8
|
export declare class LightweightTimeSeriesChartBuilder implements TimeSeriesChartAdapter {
|
|
9
9
|
LightweightChart: IChartApi;
|
|
@@ -37,10 +37,6 @@ export declare class LightweightTimeSeriesChartBuilder implements TimeSeriesChar
|
|
|
37
37
|
goToZoom(start: number, end: number): this;
|
|
38
38
|
scrollToTime(timestamp: number): this;
|
|
39
39
|
getTotalRows(): number;
|
|
40
|
-
getLoadedDimensions(): string[];
|
|
41
|
-
getActiveDimensions(): string[];
|
|
42
|
-
updateDimension(data: ChartDatasetFormatSimpleObject, dimName: string): this;
|
|
43
|
-
updateDimensions(data: ChartDatasetFormatSimpleObject, dimNames: string[]): this;
|
|
44
40
|
getRangeValues(): [number, number];
|
|
45
41
|
toggleMarkers(id: number, dimName: string, shape: string): this;
|
|
46
42
|
clearMarkers(): this;
|
|
@@ -58,7 +54,6 @@ export declare class LightweightTimeSeriesChartBuilder implements TimeSeriesChar
|
|
|
58
54
|
private toChartTime;
|
|
59
55
|
private forceTimeRangeToDataset;
|
|
60
56
|
private isPercentageDimension;
|
|
61
|
-
private normalizeDataValue;
|
|
62
57
|
private syncPriceScales;
|
|
63
58
|
private mapMarkerShape;
|
|
64
59
|
private mapMarkerPosition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LightweightTimeSeriesChartBuilder.d.ts","sourceRoot":"","sources":["../src/lib/LightweightTimeSeriesChartBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"LightweightTimeSeriesChartBuilder.d.ts","sourceRoot":"","sources":["../src/lib/LightweightTimeSeriesChartBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,SAAS,EAUd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACX,YAAY,EAGZ,8BAA8B,EAC9B,uBAAuB,EACvB,cAAc,EACd,sBAAsB,EACtB,MAAM,gBAAgB,CAAC;AAExB,KAAK,aAAa,GAAG;IACpB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AA6BF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAWjD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,UAW/C;AAED,qBAAa,iCAAkC,YAAW,sBAAsB;IACxE,gBAAgB,EAAE,SAAS,CAAC;IACnC,OAAO,CAAC,aAAa,CAEnB;IACF,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAA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IAqB7B,OAAO,CAAC,oBAAoB;IA2B5B,OAAO,CAAC,eAAe;IAsCvB,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,SAAS;IAuBjB,OAAO,CAAC,iBAAiB;IAoCzB,OAAO,CAAC,yBAAyB;IA4BjC,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,UAAU;IAsBlB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,uBAAuB;IA4B/B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,iBAAiB;CAWzB"}
|
|
@@ -14,8 +14,6 @@ function getDecimalPrecision(value) {
|
|
|
14
14
|
export function getPricePrecision(values) {
|
|
15
15
|
let precision = DEFAULT_PRICE_PRECISION;
|
|
16
16
|
for (const value of values) {
|
|
17
|
-
if (value === null)
|
|
18
|
-
continue;
|
|
19
17
|
precision = Math.max(precision, getDecimalPrecision(value));
|
|
20
18
|
if (precision >= MAX_PRICE_PRECISION) {
|
|
21
19
|
return MAX_PRICE_PRECISION;
|
|
@@ -73,8 +71,6 @@ export class LightweightTimeSeriesChartBuilder {
|
|
|
73
71
|
setCandlestickSeries(data, dims) {
|
|
74
72
|
this._tsColumn = Object.keys(data)[0];
|
|
75
73
|
this.dataset = data;
|
|
76
|
-
this.yDimensions = [dims.open, dims.high, dims.low, dims.close];
|
|
77
|
-
this.yDimensionNames = [...this.yDimensions];
|
|
78
74
|
this._ohlcDims = dims;
|
|
79
75
|
// Remove existing candlestick series before recreating
|
|
80
76
|
if (this._candlestickSeries) {
|
|
@@ -203,29 +199,8 @@ export class LightweightTimeSeriesChartBuilder {
|
|
|
203
199
|
getTotalRows() {
|
|
204
200
|
return this.dataset[this._tsColumn]?.length ?? 0;
|
|
205
201
|
}
|
|
206
|
-
getLoadedDimensions() {
|
|
207
|
-
return [...this.yDimensions];
|
|
208
|
-
}
|
|
209
|
-
getActiveDimensions() {
|
|
210
|
-
return this.getLoadedDimensions();
|
|
211
|
-
}
|
|
212
|
-
updateDimension(data, dimName) {
|
|
213
|
-
return this.updateDimensions(data, [dimName]);
|
|
214
|
-
}
|
|
215
|
-
updateDimensions(data, dimNames) {
|
|
216
|
-
if (data[this._tsColumn]) {
|
|
217
|
-
this.dataset[this._tsColumn] = data[this._tsColumn];
|
|
218
|
-
}
|
|
219
|
-
for (const dimName of dimNames) {
|
|
220
|
-
if (data[dimName]) {
|
|
221
|
-
this.dataset[dimName] = data[dimName];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
this._dataDirty = true;
|
|
225
|
-
return this.build();
|
|
226
|
-
}
|
|
227
202
|
getRangeValues() {
|
|
228
|
-
const timestamps =
|
|
203
|
+
const timestamps = this.dataset[this._tsColumn] ?? [];
|
|
229
204
|
if (!timestamps.length) {
|
|
230
205
|
return [0, 0];
|
|
231
206
|
}
|
|
@@ -289,10 +264,10 @@ export class LightweightTimeSeriesChartBuilder {
|
|
|
289
264
|
throw new Error('No time dimension found.');
|
|
290
265
|
}
|
|
291
266
|
const dataset = {
|
|
292
|
-
[tsColumn]: data.map((row) =>
|
|
267
|
+
[tsColumn]: data.map((row) => Number(row[tsColumn]))
|
|
293
268
|
};
|
|
294
269
|
for (const key of keys) {
|
|
295
|
-
dataset[key] = data.map((row) =>
|
|
270
|
+
dataset[key] = data.map((row) => Number(row[key]));
|
|
296
271
|
}
|
|
297
272
|
return {
|
|
298
273
|
tsColumn,
|
|
@@ -446,20 +421,12 @@ export class LightweightTimeSeriesChartBuilder {
|
|
|
446
421
|
const seen = new Set();
|
|
447
422
|
const result = [];
|
|
448
423
|
for (let i = 0; i < timestamps.length; i++) {
|
|
449
|
-
const
|
|
450
|
-
const open = opens[i];
|
|
451
|
-
const high = highs[i];
|
|
452
|
-
const low = lows[i];
|
|
453
|
-
const close = closes[i];
|
|
454
|
-
if (timestamp == null || open == null || high == null || low == null || close == null) {
|
|
455
|
-
continue;
|
|
456
|
-
}
|
|
457
|
-
const t = this.toChartTime(timestamp);
|
|
424
|
+
const t = this.toChartTime(timestamps[i]);
|
|
458
425
|
const tNum = t;
|
|
459
426
|
if (seen.has(tNum))
|
|
460
427
|
continue;
|
|
461
428
|
seen.add(tNum);
|
|
462
|
-
result.push({ time: t, open, high, low, close });
|
|
429
|
+
result.push({ time: t, open: opens[i], high: highs[i], low: lows[i], close: closes[i] });
|
|
463
430
|
}
|
|
464
431
|
return result;
|
|
465
432
|
}
|
|
@@ -472,16 +439,12 @@ export class LightweightTimeSeriesChartBuilder {
|
|
|
472
439
|
const seen = new Set();
|
|
473
440
|
const result = [];
|
|
474
441
|
for (let i = 0; i < timestamps.length; i++) {
|
|
475
|
-
const
|
|
476
|
-
if (timestamp == null)
|
|
477
|
-
continue;
|
|
478
|
-
const t = this.toChartTime(timestamp);
|
|
442
|
+
const t = this.toChartTime(timestamps[i]);
|
|
479
443
|
const tNum = t;
|
|
480
444
|
if (seen.has(tNum))
|
|
481
445
|
continue;
|
|
482
446
|
seen.add(tNum);
|
|
483
|
-
|
|
484
|
-
result.push(value == null ? { time: t } : { time: t, value });
|
|
447
|
+
result.push({ time: t, value: values[i] });
|
|
485
448
|
}
|
|
486
449
|
return result;
|
|
487
450
|
}
|
|
@@ -493,7 +456,7 @@ export class LightweightTimeSeriesChartBuilder {
|
|
|
493
456
|
return;
|
|
494
457
|
}
|
|
495
458
|
this._timeRangeForced = true;
|
|
496
|
-
const timestamps =
|
|
459
|
+
const timestamps = this.dataset[this._tsColumn] ?? [];
|
|
497
460
|
if (timestamps.length === 0) {
|
|
498
461
|
return;
|
|
499
462
|
}
|
|
@@ -516,9 +479,6 @@ export class LightweightTimeSeriesChartBuilder {
|
|
|
516
479
|
isPercentageDimension(dim) {
|
|
517
480
|
return !dim.startsWith('_') && dim.endsWith('%');
|
|
518
481
|
}
|
|
519
|
-
normalizeDataValue(value) {
|
|
520
|
-
return value == null ? null : Number(value);
|
|
521
|
-
}
|
|
522
482
|
syncPriceScales() {
|
|
523
483
|
const hasPercentageSeries = this.yDimensions.some((dim) => this.isPercentageDimension(dim));
|
|
524
484
|
const hasValueSeries = this.yDimensions.some((dim) => !this.isPercentageDimension(dim));
|
|
@@ -4,7 +4,7 @@ import type { ChartDatasetFormatSimpleObject, ChartMarkerPointOptions, OHLCDimen
|
|
|
4
4
|
import type { GridOption } from 'echarts/types/dist/shared';
|
|
5
5
|
import type { ZRColor } from 'echarts/types/src/util/types.js';
|
|
6
6
|
type IconType = 'circle' | 'rect' | 'roundRect' | 'triangle' | 'diamond' | 'pin' | 'arrowUp' | 'arrowDown' | 'none';
|
|
7
|
-
type DatasetFormatSimpleObject =
|
|
7
|
+
type DatasetFormatSimpleObject = Record<string, number[]>;
|
|
8
8
|
type DatasetFormatObject = Record<string, any>[];
|
|
9
9
|
type DatasetFormatArray = number[][];
|
|
10
10
|
/**
|
|
@@ -132,11 +132,6 @@ export declare class TimeSeriesChartBuilder {
|
|
|
132
132
|
};
|
|
133
133
|
getLegendStatus(): Record<string, boolean>;
|
|
134
134
|
getTotalRows(): number;
|
|
135
|
-
getLoadedDimensions(): string[];
|
|
136
|
-
getActiveDimensions(): string[];
|
|
137
|
-
updateDimension(data: DatasetFormatSimpleObject, dimName: string): this;
|
|
138
|
-
updateDimensions(data: DatasetFormatSimpleObject, dimNames: string[]): this;
|
|
139
|
-
setDataRange(start: number, end: number): this;
|
|
140
135
|
private isSimpleObject;
|
|
141
136
|
private isRecordArray;
|
|
142
137
|
private isNumberMatrix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeSeriesChartBuilder.d.ts","sourceRoot":"","sources":["../src/lib/TimeSeriesChartBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAE5B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,KAAK,EACX,8BAA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,CAAC,aAAa;IAMrB,OAAO,CAAC,cAAc;IAMtB,cAAc,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IA+ClC,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IA2BxD,YAAY,IAAI,IAAI;CAcpB"}
|
|
@@ -231,12 +231,9 @@ export class TimeSeriesChartBuilder {
|
|
|
231
231
|
if (!ts.length)
|
|
232
232
|
return 0;
|
|
233
233
|
let closest = 0;
|
|
234
|
-
let minDiff =
|
|
235
|
-
for (let i =
|
|
236
|
-
const
|
|
237
|
-
if (value === null)
|
|
238
|
-
continue;
|
|
239
|
-
const diff = Math.abs(value - timestamp);
|
|
234
|
+
let minDiff = Math.abs(ts[0] - timestamp);
|
|
235
|
+
for (let i = 1; i < ts.length; i++) {
|
|
236
|
+
const diff = Math.abs(ts[i] - timestamp);
|
|
240
237
|
if (diff < minDiff) {
|
|
241
238
|
minDiff = diff;
|
|
242
239
|
closest = i;
|
|
@@ -603,8 +600,6 @@ export class TimeSeriesChartBuilder {
|
|
|
603
600
|
if (!seriesDimension)
|
|
604
601
|
throw new Error(`Dimension ${data.dimName} not found`);
|
|
605
602
|
let value = this.searchValueByDimensionKeyAndTimestamp(data.dimName, data.timestamp);
|
|
606
|
-
if (value == null)
|
|
607
|
-
return this;
|
|
608
603
|
/**
|
|
609
604
|
* Creates a data point for the marker
|
|
610
605
|
*/
|
|
@@ -747,41 +742,6 @@ export class TimeSeriesChartBuilder {
|
|
|
747
742
|
return dataset.source[this._tsColumn].length;
|
|
748
743
|
}
|
|
749
744
|
}
|
|
750
|
-
getLoadedDimensions() {
|
|
751
|
-
return [...this.yDimensions];
|
|
752
|
-
}
|
|
753
|
-
getActiveDimensions() {
|
|
754
|
-
return this.getLoadedDimensions();
|
|
755
|
-
}
|
|
756
|
-
updateDimension(data, dimName) {
|
|
757
|
-
return this.updateDimensions(data, [dimName]);
|
|
758
|
-
}
|
|
759
|
-
updateDimensions(data, dimNames) {
|
|
760
|
-
const dataset = this.option.dataset;
|
|
761
|
-
if (!dataset || Array.isArray(dataset) || !this.isSimpleObject(dataset.source))
|
|
762
|
-
return this;
|
|
763
|
-
const source = dataset.source;
|
|
764
|
-
if (data[this._tsColumn]) {
|
|
765
|
-
source[this._tsColumn] = data[this._tsColumn];
|
|
766
|
-
}
|
|
767
|
-
for (const dimName of dimNames) {
|
|
768
|
-
if (data[dimName]) {
|
|
769
|
-
source[dimName] = data[dimName];
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
this.build();
|
|
773
|
-
return this;
|
|
774
|
-
}
|
|
775
|
-
setDataRange(start, end) {
|
|
776
|
-
const xAxis = this.option.xAxis;
|
|
777
|
-
if (Array.isArray(xAxis)) {
|
|
778
|
-
this.option.xAxis = xAxis.map((axis, index) => index === 0 ? { ...axis, min: start, max: end } : axis);
|
|
779
|
-
}
|
|
780
|
-
else {
|
|
781
|
-
this.option.xAxis = { ...xAxis, min: start, max: end };
|
|
782
|
-
}
|
|
783
|
-
return this.build();
|
|
784
|
-
}
|
|
785
745
|
isSimpleObject(s) {
|
|
786
746
|
return !Array.isArray(s) && typeof s === 'object' && s !== null;
|
|
787
747
|
}
|
|
@@ -823,10 +783,7 @@ export class TimeSeriesChartBuilder {
|
|
|
823
783
|
const col = source[this._tsColumn];
|
|
824
784
|
if (!col?.length)
|
|
825
785
|
return [0, 0];
|
|
826
|
-
|
|
827
|
-
if (!timestamps.length)
|
|
828
|
-
return [0, 0];
|
|
829
|
-
return [timestamps[0], timestamps[timestamps.length - 1]];
|
|
786
|
+
return [col[0], col[col.length - 1]];
|
|
830
787
|
}
|
|
831
788
|
return [0, 0];
|
|
832
789
|
}
|
package/dist/chartAdapter.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type ChartDatasetFormatSimpleObject = Record<string, ChartDataValue[]>;
|
|
1
|
+
export type ChartDatasetFormatSimpleObject = Record<string, number[]>;
|
|
3
2
|
export type ChartDatasetFormatObject = Record<string, any>[];
|
|
4
3
|
export type ChartDatasetFormatArray = number[][];
|
|
5
4
|
export type OHLCDimensions = {
|
|
@@ -35,10 +34,5 @@ export interface TimeSeriesChartAdapter {
|
|
|
35
34
|
getTotalRows(): number;
|
|
36
35
|
toggleMarkers(id: number, dimName: string, shape: string): this;
|
|
37
36
|
clearMarkers(): this;
|
|
38
|
-
getLoadedDimensions?(): string[];
|
|
39
|
-
getActiveDimensions(): string[];
|
|
40
|
-
updateDimension(data: ChartDatasetFormatSimpleObject, dimName: string): this;
|
|
41
|
-
updateDimensions?(data: ChartDatasetFormatSimpleObject, dimNames: string[]): this;
|
|
42
|
-
setDataRange?(start: number, end: number): this;
|
|
43
37
|
}
|
|
44
38
|
//# sourceMappingURL=chartAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartAdapter.d.ts","sourceRoot":"","sources":["../src/lib/chartAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"chartAdapter.d.ts","sourceRoot":"","sources":["../src/lib/chartAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;AAC7D,MAAM,MAAM,uBAAuB,GAAG,MAAM,EAAE,EAAE,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,YAAY,GACrB,uBAAuB,GACvB,wBAAwB,GACxB,8BAA8B,CAAC;AAElC,MAAM,MAAM,gBAAgB,GAAG;IAC9B,OAAO,E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rB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as SVECharts } from './SVECharts.svelte';
|
|
2
2
|
export { default as SVELightweightCharts } from './SVELightweightCharts.svelte';
|
|
3
|
-
export type {
|
|
3
|
+
export type { TimeSeriesChartAdapter } from './chartAdapter';
|
|
4
4
|
export { LightweightTimeSeriesChartBuilder } from './LightweightTimeSeriesChartBuilder';
|
|
5
5
|
export { TimeSeriesChartBuilder } from './TimeSeriesChartBuilder';
|
|
6
6
|
export * from './types';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAChF,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAChF,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,cAAc,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@qtsurfer/sveltecharts",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.13.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "QTSurfer (https://github.com/QTSurfer)",
|
|
7
7
|
"homepage": "https://github.com/QTSurfer/svelte-timeseries/tree/main/packages/sveltecharts",
|