|
Legend/Axis custom ImageMaps |
Posted by Zev Toledano on Sep-20-2011 09:23 |
|
Hello again,
I was wondering how I can do the following (VB6):
With both legends and axes, I need to be able to get a custom inner value when a user clicks on a legend key or an axis value. For example, although the legend displays "David", I need the ID for David which is "12345".
I can't manually lookup David because there may be two Davids. When I add the Davids, I need to associate them somehow with internal values.
I tried adding ExtraFields to the graph and using {field0} when getting the legend getHTMLImageMap, but this didn't work or I did it wrong.
Also, another relevant question: Is there an easier way to make axes clickable on a MultiChart object besides looping through all the charts and all of their axes manually adding relative coordinates?
Thanks in advance for any pointers... |
Re: Legend/Axis custom ImageMaps |
Posted by Peter Kwan on Sep-21-2011 00:51 |
|
Hi Zev,
You may use extra field to achieve what you need.
Because the legend box has one entry per data set, so the extra field is indexed by the data set count, not by the data value count within the data set. For this usage, {dsField0} should be used.
For example:
Set layer = c.addLineLayer2()
Call layer.addDataSet(myData0, -1, "David")
Call layer.addDataSet(myData2, -1, "Peter")
Call layer.addExtraField(Array("12345", "23456"))
myImageMap = legendBox.getHTMLImageMap("xxx", "yyy={dsField0}")
To use clickable axis in a MultiChart, unluckily, the only method is to obtain the image map for each axis one by one using Axis.getHTMLImageMap with the correct offsetX and offsetY, and append the image maps together.
Regards
Peter Kwan |
Re: Legend/Axis custom ImageMaps |
Posted by Zev Toledano on Sep-21-2011 01:59 |
|
Unfortunately that doesn't seem to work either, probably because I don't have any datasets in the graph (I create the legend manually inside dummy charts using addKey statements because I need multiple customized legends in my graph). Do I have to fake the datasets in order for this to work, or will it not work in any case with addKey?
Also, what about the second part of my question with Axes ExtraFields? Does it also work with datasets? |
Re: Legend/Axis custom ImageMaps |
Posted by Peter Kwan on Sep-22-2011 00:13 |
|
Hi Zev,
In ChartDirector, the extra field element is selected based on a "property" of the object that uses the extra field. For example, suppose you need to associatd an extra field with the 6th data point of the 3rd data set in a layer, if you use {field0}, this would select the 6th extra field element (the selection is based on the "data item number"). If you use {dsField0}, it will select the 3rd extra field element (the selection is based on the "data set number"). (*** NOTE ***: In the above I assume there is only one extra field, that is, the Layer.addExtraField is called only once.)
For a legend entry added as the name of a data set, the only usable property is the "data set number". So it should use {dsField0}.
For a custom legend entry added using LegendBox.addKey, there is currently no usable property for selecting an extra field, so extra field is not supported.
For your case, instead of adding the legend entry using LegendBox.addKey, please add the legend entry by adding a data set. For example, instead of:
Call legendBox.addKey(text1, color1)
Call legendBox.addKey(text2, color2)
please use:
Set legendLayer = c.addLineLayer2()
Call legendLayer.addDataSet(Array(), color1, text1)
Call legendLayer.addDataSet(Array(), color2, text2)
In this way, if you need to use extra fields, you can add the extra fields to the legendLayer and use {dsField0}.
For the axis labels, if it ia a label based axis (configured using Axis.setLabels), the label array index can be used to select the extra field of the chart object that contains the axis using {field0}. For example:
Call c.xAxis().setLabels(myLabels)
Call c.addExtraField(myExtraFieldForAxisLabels)
... can use {field0} in the axis image map .....
Hope this can help.
Regards
Peter Kwan |
Re: Legend/Axis custom ImageMaps |
Posted by Zev Toledano on Sep-22-2011 01:48 |
|
Thanks for your help but unfortunately I must use addKey because I sometimes also add custom graphics into the legend next to each key.
I think I found an ugly trick to get what I need however. Please let know if you foresee any issues with this approach:
In the legend key label, I append "<*size=0*>::IDValue" to the end of the label. Then when I call getHTMLImageMap, I disable the tooltips and add the {label} to the queryformat. This way, the user doesn't see it, it doesn't take up room, but I can still retrieve it when the user clicks it.
Can I depend on this continuing to work in the future? I may also use it in the axis labels because of complications with multiple axes and the fact that I'm using extra fields in the chart for other things... |
Re: Legend/Axis custom ImageMaps |
Posted by Peter Kwan on Sep-22-2011 23:55 |
|
Hi Zev,
Yes. The method you mentioned (including hidden text in the legend text) will work for future versions of ChartDirector as well.
Another method is to add the legend key using a layer. This can work even if you use a custom icon as the legend icon. You just need to use a data symbol to the "legendLayer". In this way, the icon will include the data symbol. An example is like:
Set legendLayer = c.addLineLayer2()
Call legendLayer.setLineWidth(0)
Call legendLayer.addDataSet(Array(), cd.Transparent, text1).setDataSymbol3(myCustomDrawAreaSymbol)
Call legendLayer.addDataSet(Array(), cd.Transparent, text2).setDataSymbol4(myCustomPolygonSymbol, 13, myColor2, myColor2)
Call legendLayer.addDataSet(Array(), cd.Transparent, text3).setDataSymbol2(myCustomImageFile)
Call legendLayer.addDataSet(Array(), cd.Transparent, text4).setDataSymbol(cd.Cross2Shape(), 13, myColor4, myColor4)
Hope this can help.
Regards
Peter Kwan |
|