echarts-stat icon indicating copy to clipboard operation
echarts-stat copied to clipboard

Linear regression fails on Date format

Open dvago opened this issue 4 years ago • 5 comments

Hi there,

I'm currently looking into an implementation of the default available regressions, it seems like the chart does not draw regression models (just the Linear function) when the input data (source) is containing either a Date object or a timestamp.

Given a source input as dataset with the following structure:

source: [
    [
        Mon Dec 07 2020 00:00:00 GMT+0000 (Greenwich Mean Time),  // This is a valid Date object,
        50.90
    ],
    [
        Wed Oct 30 2019 00:00:00 GMT+0000 (Greenwich Mean Time),  // This is a valid Date object,
        97.90
    ],
]

When I push into the dataset a new transform with the type as ecStat:regression and method as linear no line gets drawn.

note: The same behaviour happens when the Date object gets converted into a timestamp using the standard Date getTime() method.

note 2: Regression models like exponential, logarithmic and polynomial draw perfectly fine using both Date object or timestamp, so I believe there must be something wrong within the linear function.

dvago avatar Jun 16 '21 14:06 dvago

@dvago Have you solved this problem? Or perhaps there is another way out?

alexander26k avatar Sep 14 '22 13:09 alexander26k

no, unfortunately, it still an issue

dvago avatar Sep 14 '22 14:09 dvago

您好,这里是周敏。您的来信我已收到,我会在查看后的第一时间给你回复。

echodis avatar Sep 14 '22 14:09 echodis

i solved the problem. can be closed pass date as timestamp axis type (where date) - time

image

link to example

I really would like to fix something .. if I pass the datetime, it looks great. but if I pass only the date, I get the time - 00:00:00. I would like to remove it in this case. Any ideas?

alexander26k avatar Sep 14 '22 16:09 alexander26k

I solved my problem through axisPointer -> Formatter.

alexander26k avatar Sep 16 '22 10:09 alexander26k