Makanz / chartjs-plugin-trendline

This plugin draws an linear trendline in your Chart. Made for Chart.js > 3.0
MIT License
84 stars 59 forks source link

Does this work for time series data? #10

Closed melissamcewen closed 3 years ago

melissamcewen commented 5 years ago

Thanks for this great plugin! I am working with time series data in the format like:

 data:  [{
                        x: "01/04/2014", y: 175
                    }, {
                        x: "01/10/2014", y: 175
                    }, {
                        x: "01/04/2015", y: 178
                    }, {
                        x: "01/10/2015", y: 178
                    }]

For time series lines and I can't seem to figure out how to get this Plugin to work. I get chartjs-plugin-trendline.min.js:1 Uncaught TypeError: Cannot read property 'getPixelForValue' of undefined

sharpcodepro commented 5 years ago

No it did not work. We have forked and added support for time series. You can get it here before (if at all) the original author adds it. https://github.com/SigloTech/chartjs-plugin-trendline

jamrsim commented 5 years ago

Thanks for this great plugin! I am working with time series data in the format like:

 data:  [{
                        x: "01/04/2014", y: 175
                    }, {
                        x: "01/10/2014", y: 175
                    }, {
                        x: "01/04/2015", y: 178
                    }, {
                        x: "01/10/2015", y: 178
                    }]

For time series lines and I can't seem to figure out how to get this Plugin to work. I get chartjs-plugin-trendline.min.js:1 Uncaught TypeError: Cannot read property 'getPixelForValue' of undefined

Agreed, great plug-in!

I am able to plot the timestamp JSON data, gathered via AJAX, along the X-axis and the 10 numeric datum on the Y-axis, without issue using chartjs + nonforked version of the trendline plugin, as is.

{
    "chartData": [{
            "timestamp": "2019-03-07T08:00:04.340",
            "branch": "6ATL",
            "done": 0,
            "received": 1,
            "diag": 19,
            "revised": 18,
            "nextq": 21,
            "shop": 24,
            "parts": 12,
            "pickup": 17,
            "offlot": 10,
            "trucks": 112
        },
        {
            "timestamp": "2019-03-07T09:00:04.477",
            "branch": "6ATL",
            "done": 0,
            "received": 2,
            "diag": 18,
            "revised": 18,
            "nextq": 20,
            "shop": 25,
            "parts": 12,
            "pickup": 18,
            "offlot": 10,
            "trucks": 113
        },
        {
            "timestamp": "2019-03-07T10:00:03.996",
            "branch": "6ATL",
            "done": 0,
            "received": 2,
            "diag": 18,
            "revised": 18,
            "nextq": 20,
            "shop": 26,
            "parts": 11,
            "pickup": 18,
            "offlot": 9,
            "trucks": 113
        }
    ]
}
Makanz commented 5 years ago

No it did not work. We have forked and added support for time series. You can get it here before (if at all) the original author adds it. https://github.com/SigloTech/chartjs-plugin-trendline

@nilstate Please make a pull request.

Nickholas commented 4 years ago

Can not get worked for me but it would be very interesting if it works with time series.

Makanz commented 3 years ago

Please try the new version v0.2.1. Maybe it will solve your problem.