Skip to content

Commit

Permalink
fix line chart data order
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlundberg committed Nov 7, 2023
1 parent 07bf2f9 commit 22a3b1e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/charts/LineCharter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Solve } from "@/interfaces/Solve";
import formatTime from "@/lib/formatTime";
import { sort } from "fast-sort";
import { createChart } from "lightweight-charts";
import { useEffect, useRef } from "react";

Expand Down Expand Up @@ -52,12 +51,14 @@ export default function LineCharter({
container.innerHTML = "";
const chart = createChart(container, chartOptions);
const dataArray = cubeSelected ? data.cubeAll : data.global;
const structuredData: any = sort(
dataArray.map((i: Solve, index: number) => ({
time: index,
const structuredData: any[] = [];
dataArray.forEach((i: Solve, index: number) => {
console.log({ time: index, value: i.time });
structuredData.unshift({
time: dataArray.length - index,
value: i.time,
}))
).asc((u: any) => u.time);
});
});

const lineSeries = chart.addLineSeries({
color: cubeSelected ? "#2962FF" : "#F4D03F",
Expand Down

0 comments on commit 22a3b1e

Please sign in to comment.