Using trendlines with datetime axis

Hi,

I am using a chart and I want to add a trendline for this chart. 

I use your example: https://ej2.syncfusion.com/aspnetcore/Chart/TrendLines#/bootstrap5

And it works well.

Then I have changed the x axis for a datetime axis:

For that, I have added the value type for the x axis of the chart:

 <e-chart-primaryxaxis valueType="DateTime" edgeLabelPlacement="Shift">

            <e-majorgridlines width="0"></e-majorgridlines>

</e-chart-primaryxaxis>

And I have changed the series values with :

var series1 = [            { x: "2022-01-04T00:00:00", y: 0 }, { x: "2022-02-07T00:00:00", y: 1 }, { x: "2022-03-31T10:00:00", y: 2 }, { x: "2022-04-09T00:00:00", y: 3 }         ];

The chart is loaded, and the trendline also:


When I use the forward forecast feature, the chart is refreshed but I don't see the trends for the new values on the graph.

To be clear, in your example, when we use the forward forecast feature, we see the trends for 2014/2015/...




Do you have an example that works with datetime x-axis?


Best regards,

Laurent


7 Replies

DG Durga Gopalakrishnan Syncfusion Team May 2, 2022 12:31 PM UTC

Hi Laurent,


Greetings from Syncfusion.


We suggest you to specify forecast values in milliseconds for date time axis. We have prepared sample based on your requirement. Please check with below snippet and sample.


<ejs-chart >

    <e-series-collection>

        <e-series>

            <e-series-trendlines>

                <e-trendline forwardForecast="114679000000">

                </e-trendline>

            </e-series-trendlines>

        </e-series>

    </e-series-collection>

</ejs-chart>



Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Forecast1852970858.zip


Please let us know if you have any concerns.


Regards,

Durga Gopalakrishnan.



LA Laurent May 2, 2022 02:34 PM UTC

Thanks!



SB Sridevi Bharathi Manohar Syncfusion Team May 3, 2022 08:41 AM UTC

Hi Laurent


Most welcome. Kindly get in touch with us, if you would require further assistance. We are always happy in assisting you. 


Regards,

Sridevi Bharathi.



EA Ellie Angel May 14, 2022 07:06 AM UTC

Thanks for the answer.



SB Swetha Babu Syncfusion Team May 16, 2022 05:48 AM UTC

Hi Ellie,


Please get back to us if you would require further assistance.


Regards,

Swetha



EA Ellie Angel May 18, 2022 12:59 PM UTC

Thanks Swetha. I will for sure.



DG Durga Gopalakrishnan Syncfusion Team May 19, 2022 02:05 PM UTC

Okay.


Loader.
Up arrow icon