This is a migrated thread and some comments may be shown as answers.

Line Chart with Date Axis and ChartAxisBaseUnit.Fit

1 Answer 289 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 16 Mar 2017, 02:49 PM

I have a line chart which can be configured to show data from the last month, last 3 months, ... , last 2 years, last 10 years, etc.
In my SQL query I filter the data to return only the last X months and provide this data to the Kendo chart.
I am using ChartAxisBaseUnit.Fit so I can return data over weeks, months, years and the date axis is adjusted accordingly.

It is now March 16th, if I return 6 months of data the chart will show Months (September to March) on the data axis.
The problem is that we are only half way through March so the line drops off as we do not have all the data for that month yet.
What I could do is filter the data in SQL to only return complete months... i.e. filter the data from 1st September to 1st March.

However, if I return data over a longer period of time the chart will automatically show Years on the date axis.
In this case I don't want to show 2017 at all so I want to ignore any data from Jan and Feb 2017 causes.

Hopefully you get the problem... if date axis is showing years, months, weeks then I only want to show data for the last complete year, month, week.
I have seen there is a MaxDateGroups property that can be set to control the number of items shown but that does not really help.
Eventually I want the user to be able to select a custom date range and show a line chart with automatically scaled date axis.
However, I don't want the line chart to suddenly drop down at the end because we are on the first day of the month, etc.

I am hoping I am just missing something simple here and there is some property which I can set?
If not how have other people got around this problem? I would expect this is a common issue.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Mar 2017, 11:10 AM
Hello Paul,

This is not a common issue reported as usually, we try to make examples of these scenarios if possible.

I can suggest checking the min, max and the roundToBaseUnit options of the categoryAxis to set a range:

http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#configuration-categoryAxis.max

http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#configuration-categoryAxis.min

http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#configuration-categoryAxis.roundToBaseUnit

If I misunderstood the scenario, please send a small runnable example demonstrating the undesired result, I will check if there is an available solution to it.

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
Tags
Charts
Asked by
Paul
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or