Эх сурвалжийг харах

fix: extend odds curve to market close

flyzto 10 цаг өмнө
parent
commit
39df6c88b9

+ 22 - 4
web/apps/web-antd/src/views/match/odds-curve/index.vue

@@ -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),
       },