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

Message ListMessage List     Post MessagePost Message

  I like to create a Legend with graphics
Posted by Luis Quintela on Jul-06-2009 21:05
Hi,
I want to create a financial chart with a legend. This Legend should show diferent informations as the main chart. In the Legend should be some graphics (PNG) and those graphics should not appear in the main chart. My Problem is that I am not finding a way to create such Legend.

thanks all
Luis

  Re: I like to create a Legend with graphics
Posted by Peter Kwan on Jul-07-2009 05:48
Hi Luis,

If you want to add an icon with some text in a legend, the easiest way is to add an empty scatter layer to the chart (that is, a scatter layer with no data). If you are using the FinanceChart object, the code is like (in VB/VBScript):


'assume this is your main chart
Set m = myFinanceChartObj.addMainChart(.........)

'add a dummy scatter layer
Set layer = m.addScatterLayer(Array(), Array(), "My Legend Text", cd.DiamondShape, 11, &H00cc00)

'add the following line if you want to use your own image as the icon
'Call layer.getDataSet(0).setDataSymbol2("c:\\path\\to\\mySymbol.png")

Hope this can help.

Regards
Peter Kwan

  Re: I like to create a Legend with graphics
Posted by Luis Quintela on Jul-07-2009 16:11
Hi Peter,
many thanks for your help. But I tried it and it did not work (maybe I did not understand anything). I am thinking about to create a new chart and to put it together with the main chart. I could do it with a MultiChart. The question is still, how can I create such chart?.

Regards

Luis

  Re: I like to create a Legend with graphics
Posted by Peter Kwan on Jul-08-2009 01:46
Hi Luis,

Actually, I am thinking, may be I have misunderstood your requirements.

If you are using a FinanceChart object, the main price chart already has a legend box. The code in my last message is to add some custom entries in that legend box.

If you want to an additional legend box to the main price chart, you may try to create another chart just for the legend box, and merge it to the main price chart. The code is like:

.....................

' Add the main price chart as usual, but save the returned XYChart object to a
' variable for later use
Set m = c.addMainChart(....)

........ create financial chart as usual ...........

'layout the FinanceChart to prepare for adding custom objects
Call c.layout()

'add an additional chart with just a legend box
Set cc = cd.XYChart(300, 300, cd.Transparent)
Call cc.addLegend(0, 0)

'put a custom entry into the legend box
Call cc.addScatterLayer(Array(), Array(), "XXXX", cd.DiamondShape, 11, &Hff0000)

'merge it with the main price chart
Call m.makeChart3().merge(cc.makeChart3(), 60, 60, cd.TopLeft, 0)


If the above still does not solve the problem, would you mind to inform me of your charting code, the chart you get so far, and where would you like to have an additional legend box?

Regards
Peter Kwan