algorithm - Is there any other way to calculate X value in coords of other coord system? -


sorry, weird topic name, don't know how else name it. enter image description here

the problem is.. have zedgraph control. there lines drawn inside.

i have coords of left border of chart area , right border of chart area.

i draw vertical lines pictureboxes on zedgraph control, moves in different coords. vertical lines can moved left , right.

that way trying x value in coords of xaxis:

public double get_x_incontextofchart(int left_coord_of_border) //left of vertical line {     //zed_graph.graphpane.xaxis.scale.min minimal x value shown on xaxis     //zed_graph.graphpane.chart.rect.left left of yaxis     //same else if, aside of using right , maximum x @ right     if (zed_graph.graphpane.xaxis.scale.min != 0) //to avoid division 0         return (left_coord_of_border * zed_graph.graphpane.xaxis.scale.min) / zed_graph.graphpane.chart.rect.left;     else if (zed_graph.graphpane.xaxis.scale.max != 0)         return (left_coord_of_border * zed_graph.graphpane.xaxis.scale.max) / zed_graph.graphpane.chart.rect.right;      return double.nan; } 

this code calculate x fine long else if used, in example calculate wrong.

i hope understand this.

updated new code:

public double get_x_incontextofchart(int left_coord_of_border) {    double scale_left = zed_graph.graphpane.xaxis.scale.min;    double scale_right = zed_graph.graphpane.xaxis.scale.max;    double graph_width = zed_graph.graphpane.chart.rect.width;    double x = left_coord_of_border;     return scale_left + (scale_right - scale_left) / graph_width * x; } 

result: enter image description here

scale_left = -0.1 scale_right = 0.9 graph_width = 540 // pixels x = 190           // pixels  scale_x = scale_left + (scale_right - scale_left) / graph_width * x  // 0.25 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -