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

Get current minimum and maximum ticks

7 Answers 321 Views
Charts
This is a migrated thread and some comments may be shown as answers.
OMER
Top achievements
Rank 1
OMER asked on 16 Jun 2014, 01:45 PM
Hi,
I've been looking for it everywhere.
I have a need to look at the minimum and maximum axis values during zoom and pan functions.
I can't get to it though...
How is it done?

7 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 18 Jun 2014, 12:31 PM
Hi,

You can obtain the current axis range from the chart options:
var axis = e.sender.options.categoryAxis[0];
console.log(axis.min + " - " + axis.max);


-- Live demo --

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
OMER
Top achievements
Rank 1
answered on 18 Jun 2014, 03:35 PM
Hi,
Thanks. I'm sorry I did not explain myself so well.
I need this for a scatter chart, which does not have this property:
http://trykendoui.telerik.com/omOh
It somehow calculates it, but I can't find where to access this data.
0
T. Tsonev
Telerik team
answered on 20 Jun 2014, 08:16 AM
Hi,

I see what you mean. The drag and zoom events only provide axis ranges for named axes.
We'll need to update the code as follows:
xAxis: {
  name: "xAxis",
  ...
},
yAxis: {
  name: "yAxis",
  ...
}

function printRange(e) {
  var xRange = e.axisRanges.xAxis;
  if (xRange) {
    console.log(kendo.format("X [{0:N0}, {1:N0}]", xRange.min, xRange.max));
  }
        
  var yRange = e.axisRanges.yAxis;
  if (yRange) {
    console.log(kendo.format("Y [{0:N0}, {1:N0}]", yRange.min, yRange.max));
  }
}

-- Live demo --

Note that the axis range will be passed only if it is changed, hence we need to check for it.
I see that this is not documented clearly and we'll update the docs.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
OMER
Top achievements
Rank 1
answered on 25 Jun 2014, 01:38 PM
Hi,
Thanks.
2 more questions:
1) Can I get this minimum/maximum value from the chart object itself somehow? I need it outside the pan/zoom events (for instance, when a user clicks a button outside the chart).
2) Another thing is - when pan/zoom return this, they return a value that is not correct. For instance, in my chart I'll be able to see 0 to 10,000, and after I zoom in with the wheel, I get 100 to 9900 (that's just an example). Is there a way to get the former limits, before the event?
Thanks
0
Hristo Germanov
Telerik team
answered on 27 Jun 2014, 12:34 PM
Hello OMER,

In both case you can store the min and the max in two variables. You just need to start from the axis.min and axis.max then in the pan/zoom event you need to update these variables.

Regards,
Hristo Germanov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
OMER
Top achievements
Rank 1
answered on 29 Jun 2014, 01:13 PM
Thanks. The question is - how do I even get to these values?
They do not exist anywhere.
For instance - I've just drawn a chart.
Now I have this:
$("mychart").kendoChart({
  seriesDefaults: {
    type: "scatter"
  },
  series: {
    xField: "x",
    yField: "y"
  },
  yAxis: { name: "yAxis" }, xAxis: { name: "xAxis"}
}
Let's assume I bind a datasource to this chart with a 1000 points which I do not know their values.
Now the chart is being drawn and shows an X axis from 0 to 200.  How can I get to these numbers (0 and 200) from the chart's object?
The xAxis and yAxis do not have the min/max values.

0
Hristo Germanov
Telerik team
answered on 02 Jul 2014, 07:14 AM
Hello OMER,

You are right that is not so easy to get these values when the chart is bind via dataSource. In this case the chart should get the data before it calculate the axis min/max. 
You need to hook up to the dataBound event and there with setTimeout you can get the current range.
dataBound: function(e) {
  setTimeout(function() {
      console.log(e.sender._plotArea.axes);
  }, 100)
}

You can get each axis by name. I hope this helps.

We will considered to add methods for getting axis by name and getting range by axis name.

I have updated your telerik points.

Regards,
Hristo Germanov
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
OMER
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
OMER
Top achievements
Rank 1
Hristo Germanov
Telerik team
Share this question
or