ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  addline not matching yaxis values
Posted by Craig Roberts on Apr-23-2025 08:05
Hello Peter,

I am setting up a SplineLayer chart.
I am looking to add a line at the min & max values of the dataset.

code below, the lines do not match the yaxis value of the chart. any suggestions.

  Dim minValue As Double = data.Min()
  Dim maxValue As Double = data.Max()

c.addLine(35, c.getYCoor(minValue), spPressBCharts.ActualWidth - 20, c.getYCoor(minValue), &HFF0000)
c.addText(spPressBCharts.ActualWidth - 240, c.getYCoor(minValue), "Minimum PressB Amp Range: " & minValue, "Arial Bold", 9, &HFF0000)

c.addLine(35, c.getYCoor(maxValue), spPressBCharts.ActualWidth - 20, c.getYCoor(maxValue), &HFF0000)
c.addText(spPressBCharts.ActualWidth - 240, c.getYCoor(maxValue) - 14, "Maximum PressB Amp Range: " & maxValue.ToString("F1"), "Arial Bold", 9, &HFF0000)

c.yAxis().setLogScale(minValue - 100, maxValue + 100)

Regards
Craig Roberts

  Re: addline not matching yaxis values
Posted by Peter Kwan on Apr-26-2025 15:01
Hi Craig,

Sorry for the late reply.

To add a line at a specific data value with a label, you may use addMark. For example:

https://www.advsofteng.com/doc/cdnet.htm#markzone.htm

The BaseChart.addLine is for adding a line using pixel coordinates. The XYChart.getYCoor can convert data values to pixel coordinates. This is only possible if the y-axis scale is confirmed. The getYCoor should not be used if the y-axis scale is not confirmed. (This is mentioned in the documentation for getYCoor.)

If the chart is auto-scaled, ChartDirector will include all data points in the chart to determine the y-axis scale. ChartDirector cannot know if your code has already included all the data until your code ask it to draw the chart (eg. until calling makeChart), or your code can inform ChartDirector that the axis scale can be fixed by using XYChart.layoutAxes.

Best Regards
Peter Kwan