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

"Live-Ticker" chart showing last(est) values

2 Answers 22 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Ricky
Top achievements
Rank 2
Ricky asked on 30 Nov 2016, 01:33 PM

Hi,

I am trying a very basic thing but cannot find the right option. I would like to have something like a "live-ticker" chart which shows the last(est) x values (just numbers). When I use a DataSource with my sparkline chart I can add records and togehter with categoryAxis.min=0 and categoryAxis.max=16 I get the first 16 values display but not the last 16 values. How can I achieve this?

There is a DataSource.remove but it requires to give a certain object. Is there an index-based remover? Is there a better approach?

Also to make it more advanced I would like not to hardcode the maximum number of values displayed but have it depend on the available space (if the chart is big enough for 100 values, lets show 100 - if smaller then fewer). I know if I make the chart bigger on-the-fly that additional values might not be there yet but that would be okay - the graph can fill with time.

This is like show a value every second.

Best regards,
Ricky

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Dec 2016, 12:03 PM
Hello Ricky,

I can suggest using the total method of the DataSource to retrieve the number of records and use that value as max, then use that value minus 16 to retrieve min value:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-total

In order to dynamically change the min and max values I can suggest two approaches:

1) use the setOptions method to set the new values:

http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#methods-setOptions

2) Set the new values to the Chart options and use the redraw method of the Chart to redraw it with the new options:

var chart = $("#chart").data("kendoChart");
chart.options.categoryAxis.max = currentMaxValue
chart.redraw();

http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#methods-redraw

As for the remove method, it can be used in combination with the at method of the dataSource which is using an index to retrieve the object:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-at

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-remove

If additional assistance is needed, please send a runnable example, so I can investigate.

Regards,
Stefan
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
0
Ricky
Top achievements
Rank 2
answered on 15 Dec 2016, 11:29 AM

Could not continue working on this before today but your hints are appreciated, it is working now, thank you!

Tags
Charts
Asked by
Ricky
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Ricky
Top achievements
Rank 2
Share this question
or