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

Message ListMessage List     Post MessagePost Message

  How to do this after Layout() code?
Posted by icm63 on Jun-24-2025 02:50
Attachments:
vb net, ChartD 6.0

I wish to add a DOT at a price point on a line.
Say you have x1 and y1 for the dot on the line.

How can I do this after  layout call (so not using scatter code to add a symbol or jpeg)?

see image

any ideas
SH_0001.png

  Re: How to do this after Layout() code?
Posted by Peter Kwan on Jun-24-2025 19:00
Hi icm63,

You can use the DrawArea object to draw things in pixel coordinates. I assume (x1, y1) you mentioned are data values. The XYChart.getXCoor and XYChart.getYCoor can be used to convert from data values to pixel coordinates.

You mentioned you want to draw after the chart has been "layout". I assume you want to draw the dot after the chart has been "drawn", otherwise the dot will be behind the chart instead of in front of it. In this case, assume your chart is an XYChart, it is like:

' Draw the chart and obtain its DrawArea for further drawing
Dim d As DrawArea = c.makeChart3()

' Get the pixel coordinates
Dim xPixel As Integer = c.getXCoor(x1)
Dim yPixel As Integer = c.getYCoor(y1)

' Draw a black 3x3 pixels rectangle as the "dot"
d.rect(xPixel - 1, yPixel - 1, xPixel + 1, yPixel + 1, &H000000, &H000000)


There may be other factors to consider depending on your chart configuration. For example, if you have more than 1 y-axis in the chart, you have to tell ChartDirector which y-axis to use to convert the data value to the pixel coordinates. If the chart to display is not an XYChart but a MultiChart, you have to get the XYChart inside the MultiChart to convert the get the pixel coordinates inside the XYChart, and then add the XYChart offset to change it to the pixel coordinate inside the MultiChart (as the DrawArea is from the MultiChart).

The "Programmable Track Cursor" examples uses the same method to draw movable track cursors after the chart is drawn. You can use them as a reference. See:

https://www.advsofteng.com/doc/cdnet.htm#BaseChart.makeChart3.htm
https://www.advsofteng.com/doc/cdnet.htm#XYChart.getXCoor.htm
https://www.advsofteng.com/doc/cdnet.htm#XYChart.getYCoor.htm
https://www.advsofteng.com/doc/cdnet.htm#DrawArea.htm

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

Best Regards
Peter Kwan

  Re: How to do this after Layout() code?
Posted by icm63 on Jun-25-2025 01:42
thx