zz-chart
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -119,2 +119,3 @@ import { isBoolean, isObject, set } from 'lodash'; | ||
set(this.options, 'data', data); | ||
this.emit(CHART_EVENTS.DATA_CHANGE, data); | ||
return this; | ||
@@ -121,0 +122,0 @@ } |
@@ -66,2 +66,15 @@ import { merge } from 'lodash'; | ||
}); | ||
this.ctrl.on(CHART_EVENTS.DATA_CHANGE, () => { | ||
if (this.uPlot) { | ||
const data = this.getData(); | ||
this.uPlot.setData(data); | ||
if (this.uPlot.series.length < data.length) { | ||
this.getSeries(this.ctrl.getData()).forEach((s, index) => { | ||
if (index) { | ||
this.uPlot.addSeries(s, index); | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -82,3 +95,5 @@ render(size) { | ||
this.uPlot.setSize(size); | ||
this.uPlot.redraw(false); | ||
if (this.ctrl.getData().length) { | ||
this.uPlot.redraw(); | ||
} | ||
} | ||
@@ -91,3 +106,2 @@ /** | ||
getData() { | ||
// TODO: test | ||
const data = this.ctrl.getData(); | ||
@@ -102,2 +116,5 @@ return this.handleData(data); | ||
handleData(data) { | ||
if (!data.length) { | ||
return []; | ||
} | ||
const values = data.map(value => value.values); | ||
@@ -141,8 +158,9 @@ const x = values[0].map(value => value.x); | ||
paths: defaultType, | ||
alpha: 0.5, | ||
width: 2, | ||
alpha: 0.6, | ||
width: 1.5, | ||
// fill: color, | ||
fill: (u, seriesIdx) => { | ||
const s = u.series[seriesIdx]; | ||
return this.scaleGradient(u, s.scale, 1, [ | ||
[0, '#fff'], | ||
[0, color], | ||
[100, color], | ||
@@ -218,3 +236,3 @@ ]); | ||
const values = data.reduce((prev, curr, index) => { | ||
return ySeries[index].show | ||
return ySeries[index]?.show | ||
? [ | ||
@@ -221,0 +239,0 @@ ...prev, |
@@ -14,3 +14,4 @@ export declare const CHART_PREFIX = "achart"; | ||
LEGEND_ITEM_HOVER = "legend-item:hover", | ||
SHAPE_CHANGE = "shape:change" | ||
SHAPE_CHANGE = "shape:change", | ||
DATA_CHANGE = "data:change" | ||
} | ||
@@ -17,0 +18,0 @@ /** |
@@ -40,2 +40,4 @@ export const CHART_PREFIX = 'achart'; | ||
CHART_EVENTS["SHAPE_CHANGE"] = "shape:change"; | ||
// data | ||
CHART_EVENTS["DATA_CHANGE"] = "data:change"; | ||
})(CHART_EVENTS || (CHART_EVENTS = {})); | ||
@@ -42,0 +44,0 @@ /** |
{ | ||
"name": "zz-chart", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Alauda Chart", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
210899
5919