ecomfe / echarts-stat

Statistics tool for Apache ECharts
597 stars 309 forks source link

Linear regression fails on Date format #39

Open dvago opened 3 years ago

dvago commented 3 years ago

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.

alexander26k commented 2 years ago

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

dvago commented 2 years ago

no, unfortunately, it still an issue

echodis commented 2 years ago

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

alexander26k commented 2 years ago

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 commented 2 years ago

I solved my problem through axisPointer -> Formatter.