From 477f93d8197ab013dac344380ca4811624c12186 Mon Sep 17 00:00:00 2001 From: Wadah Esam Date: Tue, 9 Jan 2024 09:06:41 +0300 Subject: [PATCH] feat: add ability for multiple lines to have different number of points --- src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 7be5c55..d5e6a88 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -51,6 +51,7 @@ export const createNewPath = ({ // get the min and max values for the y axis const [minY, maxY] = d3.extent([...allData.map((val) => val.y)]) || [0, 0]; + const [minX, maxX] = d3.extent([...allData.map((val) => val.x)]) || [0, 0]; // Avoid repeated computation const chartMinMax = getChartMinMaxValues(minY || 0, maxY || 10); @@ -64,7 +65,7 @@ export const createNewPath = ({ // create the x scale const x = d3 .scaleUtc() - .domain([data[0]?.x || 0, data[data.length - 1]?.x || 1]) + .domain([minX || 0, maxX || 1]) .range([0, svgWidth - endSpacing]); const curveMapping = {