tremor icon indicating copy to clipboard operation
tremor copied to clipboard

Add Scale and Domain Prop for Line Chart X-Axis

Open bquay opened this issue 3 years ago • 6 comments

Love the library!

In my use case I'm looking to be able to leverage tremor for some time series data which requires setting the scale prop on the XAxis to equal "time".

I think this could be done rather straightforwardly by extending the BaseChartProps and/or creating a new LineChartProps interface that includes both a scale and a domain prop. If needed it could be xDomain and yDomain as ReCharts allows for both.

ex:

<LineChart
    autoMinValue
    categories={['x']}
    data={chartData}
    dataKey="y"
    height="h-80"
    marginTop="mt-8"
    scale={'time'}
    showLegend
    xDomain={['auto', 'auto']}
    yAxisWidth="w-12"
/>

If you'd like I'd be happy to put up a PR for it

Edit*: Looks like the yDomain is handled under the hood so perhaps we could do something similar

bquay avatar Dec 29 '22 00:12 bquay

hey @bquay, thanks a lot for the comment! We are planning to migrate to another chart library in the near future, therefore we are a bit careful with implementing re-charts specific props. We will consider it though for our next minor release!

mitrotasios avatar Jan 05 '23 19:01 mitrotasios

Oh interesting! Which library if you don't mind me asking?

bquay avatar Jan 05 '23 20:01 bquay

Sure, we are thinking of visx, but haven't made a final decision yet :) definitely open for recommendations!

mitrotasios avatar Jan 05 '23 23:01 mitrotasios

hey @bquay, sorry for taking so long to come back to this again. Is there a reason why you prefer not to use a callback in the valueFormatter prop to format your time series data? 🙂

E.g.

<AreaChart
  ...
  valueFormatter={(value) => String(new Date(value))}
>

mitrotasios avatar Feb 03 '23 16:02 mitrotasios

@mitrotasios What are your main pain points with recharts? Would be great if you could communicate them as issues. We would be happy to take those into considerations for upcoming feature work.

nikolasrieble avatar Feb 06 '23 13:02 nikolasrieble

Bumping this, is there any workaround to set the scale in the current state?

sebasmagri avatar Nov 30 '23 21:11 sebasmagri