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

Message ListMessage List     Post MessagePost Message

  Enumerated yaxis
Posted by Zev Toledano on Feb-21-2011 17:56
When the yaxis in a XYChart is enumerated, how do I display the yaxis label in a data-point label/tooltip instead of the numeric {value}? I.e. I need  a {yLabel} equivalent to the {xLabel} otherwise it will display nonsensical numbers to the user. I must be missing something obvious...

  Re: Enumerated yaxis
Posted by Peter Kwan on Feb-22-2011 01:31
Hi Zev,

Unluckily, there is currently no {yLabel} for enumerated y-axis. Instead, extra fields would need to be used. For example:

Set layer = c.addLineLayer(myData, ....)

'The ytooltips for the points, which is the same as the y-axis labels
ReDim tooltips(UBound(myData))
For i = 0 To Ubound(myData)
     ytooltips(i) = yLabel(myData(i))
Next
Call layer.addExtraField(ytooltips)

Now in the tooltips configuration, you may use:

title='{xLabel}: {field0}'

Hope this can help.

Regards
Peter Kwan

  Re: Enumerated yaxis
Posted by Zev Toledano on Feb-22-2011 02:09
Thanks. I'll use this as a workaround. You should consider adding {yLabel} for a future version though...

  Re: Enumerated yaxis
Posted by Zev Toledano on Feb-22-2011 02:45
I keep getting the same value for {field0} over and over again for each point presumably because it is going according to the data point number on the xaxis, not the yaxis position? Is there a {field} variable that is indexed according to the yaxis position? Don't forget that this must work for cases when the xaxis and yaxis don't have an equal amount of points.

  Re: Enumerated yaxis
Posted by Peter Kwan on Feb-22-2011 19:01
Hi Zev,

The {field0} is not based on the x-axis or the y-axis. It is based on the array index of your data. For example, if you have 1346 data points in a layer, the {field0} should contain 1346 elements, each for one data point. It does not matter how many labels are there on the x-axis or y-axis or whether they contain equal number of labels.

You can put anything you like in the 1346 elements. For example, you can put the y-axis labels of the 1346 data points in the 1346 elements. Suppose you only have 2 possible y-axis labels "Yes" and "No", then you just put either "Yes" or "No" to the 1346 elements.

If the above still does not solve the problem, would you mind to inform me of the charting part of your code, so I may try to reproduce the problem?

Regards
Peter Kwan

  Re: Enumerated yaxis
Posted by Zev Toledano on Feb-22-2011 21:19
There are many variations that don't work or that make this complicated.

Let's start with the most obvious: Multiple datasets. How do I get a different label in the same bar layer but from a different dataset? Also, each dataset has a different set of labels because they have different yvalues. I looked this up in your help file and it seems I can use dsFieldN for dataset index, but I also need per point and per dataset so I used {dsdiField0} and it just shows me "{dsdiField0}" in the graph instead of a value. What am I missing?

If the above would work, then I think I could write a function that translates points to ylabels and cover all the variations. But we really need a {yLabel}.

  Re: Enumerated yaxis
Posted by Zev Toledano on Feb-22-2011 21:28
OK I just figured out that I have to add a new set of ExtraFields per dataset for dsdi to work. I'll see if I can handle the rest of the scenarios with mapping code....

  Re: Enumerated yaxis
Posted by Zev Toledano on Feb-23-2011 00:50
I'm breaking my head over this for almost 2 days now and it still doesn't work. Your help file says this:

"dsdiFieldN means the extra fields are indexed by both the data set number and data point number. The Pth data item of the Qth data set corresponds to the Pth element of the (N + Q)th extra field"

Am I to understand from this that if I want to add 5 datasets with 3 points each, each with different extra fields. That I need to add 5 sets of extra fields with 3 values each?

So I used setDataLabelFormat "{dsdiField0}" at the layer level but that didn't work. Using it at the DataSet level worked. But now I don't know how to make the tooltip work because there is no setHTMLImageMap function at the dataset level.

This is way too much work for such a little thing.

  Re: Enumerated yaxis
Posted by Zev Toledano on Feb-23-2011 03:46
Just to clarify my previous post: It uses the same dataset over and over when using it at the layer level because it calls {dsdiField0} every time, whereas in a dataset I call {dsdiFieldN} according to the current data set, and this works.

However, for setHTMLImageMap, I can't find a way to solve this because it doesn't work at the dataset level so every dataset is going to use the same set of values. Am I missing something?

I obviously can't separate each dataset into a different layer because we are talking about bar/area charts.

  Re: Enumerated yaxis
Posted by Peter Kwan on Feb-23-2011 11:25
Hi Zev,

Whenever you add a data set, you also add a corresponding extra field. Then in the setHTMLImageMap, you may just use {dsdiField0}. For example:

Set layer = c.addBarLayer(cd.Stack)

Call layer.addDataSet(myData0, ...)
Call layer.addExtraField(toolTipsForData0)

Call layer.addDataSet(myData1, ...)
Call layer.addExtraField(toolTipsForData1)

Call layer.addDataSet(myData2, ...)
Call layer.addExtraField(toolTipsForData2)

Call layer.setHTMLImageMap("", "", "title='{dsdiField0}'")


For the toolTipsForDataN, you may write a function to generate that, like:

Function getToolTips(data, yAxisLabels)
    ReDim toolTips(Ubound(data))
    For i = 0 To UBound(data)
          toolTips(i) = yAxisLabels(data(i))
    Next
    getToolTips = toolTips
End Function


With the above function, the code becomes:


Set layer = c.addBarLayer(cd.Stack)

Call layer.addDataSet(myData0, ...)
Call layer.addExtraField(getToolTips(myData0, yAxisLabels))

Call layer.addDataSet(myData1, ...)
Call layer.addExtraField(getToolTips(myData1, yAxisLabels))

Call layer.addDataSet(myData2, ...)
Call layer.addExtraField(getToolTips(myData2, yAxisLabels))

Call layer.setHTMLImageMap("", "", "title='{dsdiField0}'")


Hope this can help.

Regards
Peter Kwan

  Re: Enumerated yaxis
Posted by Zev Toledano on Feb-23-2011 16:51
Thank you for your help! I was adding the extrafield to the chart object instead of the layer, and it was using the same dataset over and over when using {dsdiField0}. For some reason I assumed it was the same thing.