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

stockchart, dynamic navigator settings

3 Answers 129 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Morten asked on 26 Sep 2015, 12:22 PM

Using 2015.2.827 I have a stockchart that gets data ​from datasource with schema date: { type: "date" }, reportCount: { type: "number" }.

I would like to set the navigator.select.from and navigator.select.to based on datasource values. Specifically, I would like to set navigator.select.from to "datasource.data.max.addDays(-14)" and navigator.select.to to "datasource.data.max".

I would like to only have to read the datasource once.

Is this possible?

3 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 30 Sep 2015, 07:13 AM
Hi Morten,

There is no public API for this requirement, you could dynamically set navigator selection using the following code snippet: 
var chart = $("#stock-chart").data("kendoStockChart");
chart._navigator.selection.set(new Date("2001/01/01"), new Date("2002/01/01"));


Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 01 Oct 2015, 04:31 AM

Thanks Iliana. The navigator gets set correctly, however, how do I make sure the main graph is in sync with navigator?

My chart: 

$("#raid-development").kendoStockChart({
    theme: "bootstrap",
    dataSource: raidDevDs,
    autoBind: false,
    dateField: "date",

Loading of data:

raidDevDs.fetch(function () {
    var dateAggre = raidDevDs.aggregates().date;
    var dateMax = dateAggre.max;
    var dateMin = DateTime.addDays(dateMax, -14);
    var chart = $("#raid-development").data("kendoStockChart");
    chart._navigator.selection.set(dateMin, dateMax);
 

 

 

0
Iliana Dyankova
Telerik team
answered on 02 Oct 2015, 01:25 PM
Hi Morten,

I was thinking on this case and would suggest a bit different approach to achieve the expected result - change the navigator selection via the chart.options and redraw the StockChart:
// get a reference to the StockChart widget
var stockchart = $("#stock-chart").data("kendoStockChart");
// set navigator selection from
stockchart._navigator.options.select.from = new Date("2001/01/01");
// set navigator selection to
stockchart._navigator.options.select.to =  new Date("2002/01/01");
// redraw the chart
chart.redraw();
 

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Iliana Dyankova
Telerik team
Morten
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or