Use chartjs-plugin-trendline
I can't seem to figure out how to use chartjs-plugin-trendline with this project, any tips? What I've done so far is npm i chartjs-plugin-trendline import 'chartjs-plugin-trendline'; then added the trendlineLinear: { style: "rgba(255,105,180, .8)", lineStyle: "solid", width: 2 } to the dataset, but no line appears Thanks!
It started working after a bit, must of been a caching issue
@XopherDesign Can you share the code that worked? I am having a similar issue. I even tried to clear cache using Ctrl+Shift+R, but it didn't work. Is the plugin supposed to be just imported, or registered globally via componentDidMount or just passed as plugins prop?
This works for me:
// "react-chartjs-2": "^3.1.1",
import {Chart, Bar} from 'react-chartjs-2';
Chart.register(chartTrendline);
function MyBarChart() {
const chartData = {
...
datasets: [
{
...,
trendlineLinear: {...},
},
],
};
const chartOptions = {...};
return <Bar data={chartData} options={chartOptions} />;
}