Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting trendline dataset #100

Open
elorenzorodz opened this issue Dec 18, 2024 · 2 comments
Open

Getting trendline dataset #100

elorenzorodz opened this issue Dec 18, 2024 · 2 comments

Comments

@elorenzorodz
Copy link

elorenzorodz commented Dec 18, 2024

Is there anyway to get the dataset for the trendline? Including X,Y of the data within the dataset.

@Makanz
Copy link
Owner

Makanz commented Dec 18, 2024

Can you give me a example config to try with?

@elorenzorodz
Copy link
Author

Here is my dataset, chart config I did was just default.

datasets: [
    {
        label: '',
        pointRadius: 0,
        pointHoverRadius: 4,
        borderColor: '3',
        borderColor: '#FF7A48',
        data: [0, 0, 0, -72.47, 362.37, 0, 0, 37.27, 450, -2000, -2000, -2000],
        tension: 0.5,
        pointHoverBackgroundColor: '#FF7A48',
        fill: false,
        trendlineLinear: {
            colorMin: "#D1D1D1",
            colorMax: "#D1D1D1",
            lineStyle: "dashed",
            width: 3,
            projection: true,
        },
    }
]

I also created a custom plugin for afterDatasetsDraw to try to read the dataset of the trendline created, but couldn't find it.

const customLabelPlugin = {
    id: 'customLabelPlugin',
    afterDatasetsDraw: function (chart) {
         // omitted
        }
    }
};

Chart.register(customLabelPlugin);

I just need to get the x,y coordinates of the last data in the dataset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants