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

Message ListMessage List     Post MessagePost Message

  Create small filled circle (dot) on financial chart
Posted by chuck on Aug-27-2020 22:09
Hi Peter,

Can you provide a VB.NET example of how to create a tiny, filled circle (a small colored dot) at a specific X/Y location of a financial chart? As well as how to pass some type of size information to set the actual size of the “dot”? (passing pixel amount preferably).

Thank you for your help!
Chuck

  Re: Create small filled circle (dot) on financial chart
Posted by Peter Kwan on Aug-31-2020 16:29
Hi chuck,

Sorry for the late reply.

There is a "Finance Chart Custom Symbols" sample code included in ChartDirector:

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

In the above sample code, it puts arrow symbols at some (x, y) positions on the chart. This is by adding a scatter layer. You can change the scatter symbols to circles for your case.

When you add the symbol, you can specify a size in pixels. If you have multiple circles in the same scatter layer, and each of them can have a different size, you can add another array to specify the sizes of the symbols, like in the "Bubble Chart" sample code:

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

Hope this can help.

Regards
Peter Kwan

  Re: Create small filled circle (dot) on financial chart
Posted by chuck on Aug-31-2020 22:00
Thank you Peter... it would be nice if in the future “drawing primitives” could be supported.
Chuck

  Re: Create small filled circle (dot) on financial chart
Posted by Peter Kwan on Sep-01-2020 01:12
Hi chuck,

Yes, you can use low level drawing primitives by using the DrawArea object. It is like:

... create chart as usual ...

' draw chart and return the DrawArea object
Dim d As DrawArea = c.makeChart3()

' draw using the DrawArea object
d.circle(.....)

See:

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

Note that the DrawArea object draws in pixel coordinates. It is often used to draw things like a "logo" or "water mark", which do not use data values.

If you want to draw at a certain (x, y) data value, you would need to obtain their pixel coordinates in order to use the DrawArea object. ChartDirector has several API that is used to translate data values to pixel coordinates, such as XYChart.getXCoor and XYChart.getYCoor. For financial charts, it may contain multiple XYChart objects, and an XYChart can contain more than one y-axes. You need to know the (x, y) data value, the chart to use and the axes to use in order to convert to pixel coordinates.

It is often more convenient to use higher level drawings (eg. addScatterLayer) if you are working data values. This avoids all these conversions.

If you only want to use drawing primitives for the symbol shape, you can create a new DrawArea object and draw the shape on it. You can use add that symbol to the chart at the proper data position by using a scatter layer. It is like:

' The symbol shape
Dim myDrawArea As New DrawArea()
myDrawArea.setSize(15, 15, Chart.Transparent)
myDrawArea.circle(.........)
... drawing some more things ....


' The scatter layer
Dim myScatterLayer As ScatterLayer = c.addScatterLayer(......)

' Use myDrawArea as the scatter symbol
myScatterLayer.getDataSet(0).setDataSymbol3(myDrawArea)

See:

https://www.advsofteng.com/doc/cdnet.htm#DataSet.setDataSymbol3.htm


Regards
Peter Kwan

  Re: Create small filled circle (dot) on financial chart
Posted by chuck on Sep-01-2020 01:16
Peter, this is very helpful, thank you!
Chuck