You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by Parvez Shah <pa...@mytradewall.com> on 2020/06/18 10:17:20 UTC

Finding maximum and minimum axis value of visible chart area

Finding maximum and minimum x, y-axis value of visible chart area.
use case: on click of button need to draw a line on the chart. I am following this example for the same https://echarts.apache.org/examples/en/editor.html?c=line-draggable

setting data for the series as 
var data = [[10, 40], [10, 10]]; 
 but as my chart is zoomable how do i get maximum and minimum x, y-axis value of visible chart area, so that i can compute coordinate for the line on run time 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org


Re: Finding maximum and minimum axis value of visible chart area

Posted by Parvez Shah <pa...@gmail.com>.
Thank you very much, this solved my problem

On Sat, Jun 20, 2020 at 12:45 PM SHUANG SU <su...@gmail.com> wrote:

> Parvez Shah,
>
> There is another example might be related to this issue:
> https://echarts.apache.org/examples/en/editor.html?c=line-pen
>
> This example use the API
> ```js
> var pointInGrid = myChart.convertFromPixel('grid', pointInPixel);
> ```
> to calculate the "value extent" of axes from pixels.
>
> Currently, it might be the only way to get the "value extent" of an axis.
> That is,
> (1) Firstly, we should know the the pixel of the four corner of a
> "grid(cartesian)",
> for example: [10,10] [500, 10] [500, 700] [10, 700]
> (2) Use the API
> https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel
> ```js
> var valueInLeftTop = myChart.convertFromPixel('grid', [10,10]);
> var valueInRightTop = myChart.convertFromPixel('grid', [500, 10]);
> var valueInRightBottom = myChart.convertFromPixel('grid', [500, 700]);
> var valueInLeftBottom = myChart.convertFromPixel('grid', [10, 700]);
> ```
>
> Does that satisfy your requirement?
>
>
> Thanks,
> ------------------------------
>  Su Shuang (100pah)
> ------------------------------
>
>
>
> On Thu, 18 Jun 2020 at 22:34, Parvez Shah <pa...@mytradewall.com>
> wrote:
>
> > Finding maximum and minimum x, y-axis value of visible chart area.
> > use case: on click of button need to draw a line on the chart. I am
> > following this example for the same
> > https://echarts.apache.org/examples/en/editor.html?c=line-draggable
> >
> > setting data for the series as
> > var data = [[10, 40], [10, 10]];
> >  but as my chart is zoomable how do i get maximum and minimum x, y-axis
> > value of visible chart area, so that i can compute coordinate for the
> line
> > on run time
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
> > For additional commands, e-mail: dev-help@echarts.apache.org
> >
> >
>

Re: Finding maximum and minimum axis value of visible chart area

Posted by SHUANG SU <su...@gmail.com>.
Parvez Shah,

There is another example might be related to this issue:
https://echarts.apache.org/examples/en/editor.html?c=line-pen

This example use the API
```js
var pointInGrid = myChart.convertFromPixel('grid', pointInPixel);
```
to calculate the "value extent" of axes from pixels.

Currently, it might be the only way to get the "value extent" of an axis.
That is,
(1) Firstly, we should know the the pixel of the four corner of a
"grid(cartesian)",
for example: [10,10] [500, 10] [500, 700] [10, 700]
(2) Use the API
https://echarts.apache.org/en/api.html#echartsInstance.convertFromPixel
```js
var valueInLeftTop = myChart.convertFromPixel('grid', [10,10]);
var valueInRightTop = myChart.convertFromPixel('grid', [500, 10]);
var valueInRightBottom = myChart.convertFromPixel('grid', [500, 700]);
var valueInLeftBottom = myChart.convertFromPixel('grid', [10, 700]);
```

Does that satisfy your requirement?


Thanks,
------------------------------
 Su Shuang (100pah)
------------------------------



On Thu, 18 Jun 2020 at 22:34, Parvez Shah <pa...@mytradewall.com>
wrote:

> Finding maximum and minimum x, y-axis value of visible chart area.
> use case: on click of button need to draw a line on the chart. I am
> following this example for the same
> https://echarts.apache.org/examples/en/editor.html?c=line-draggable
>
> setting data for the series as
> var data = [[10, 40], [10, 10]];
>  but as my chart is zoomable how do i get maximum and minimum x, y-axis
> value of visible chart area, so that i can compute coordinate for the line
> on run time
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
> For additional commands, e-mail: dev-help@echarts.apache.org
>
>