|
|
@@ -187,6 +187,27 @@ const getMarketColor = (index: number) => {
|
|
|
return colors[index % colors.length] ?? colors[0];
|
|
|
};
|
|
|
|
|
|
+const formatSeriesData = (points: MarketPoint[] = []) => {
|
|
|
+ const data: Array<[number, null | number]> = [];
|
|
|
+ let lastValue: number | null = null;
|
|
|
+
|
|
|
+ points.forEach((point) => {
|
|
|
+ if (point.value === 0) {
|
|
|
+ if (lastValue !== null) {
|
|
|
+ data.push([point.time, lastValue]);
|
|
|
+ }
|
|
|
+ data.push([point.time, null]);
|
|
|
+ lastValue = null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ data.push([point.time, point.value]);
|
|
|
+ lastValue = point.value;
|
|
|
+ });
|
|
|
+
|
|
|
+ return data;
|
|
|
+};
|
|
|
+
|
|
|
const renderChart = () => {
|
|
|
const markets = history.value?.markets ?? {};
|
|
|
const keys = selectedMarkets.value.filter((key) => markets[key]?.length);
|
|
|
@@ -225,10 +246,7 @@ const renderChart = () => {
|
|
|
},
|
|
|
series: keys.map((key, index) => ({
|
|
|
connectNulls: false,
|
|
|
- data: (markets[key] ?? []).map((point) => [
|
|
|
- point.time,
|
|
|
- point.value === 0 ? null : point.value,
|
|
|
- ]),
|
|
|
+ data: formatSeriesData(markets[key]),
|
|
|
itemStyle: {
|
|
|
color: getMarketColor(index),
|
|
|
},
|