|
Add Extrafield for xAxis labels - don't work |
Posted by Fabian on Dec-15-2011 17:09 |
|
Hi Peter,
my Tooltip of the XAxis-labels should show an extra text. This extra text is the label-name. I use a "tree-view" for my labels (for example: " PSR3").
So, I use addExtrafield and refer to it in getHTMLImageMap like below.
for(...)
{
...
c->xAxis()->addLabel(d, TCHARtoUTF8(strTitle));
...
}
...
// field2 is label-name; iAnzTitle is Label count; m_pFilterResult->pTitleBez[3] is "PSR3"
c->addExtraField(StringArray(m_pFilterResult->pTitleBez, iAnzTitle));
..
CString sImageMap;
sImageMap.Format("%s%s"
, c->getHTMLImageMap("clickable",
"title={field1}\\n{field3}\\n{top|dd.mm.yyyy} - {bottom|dd.mm.yyyy}", // Gantt Tooltip
"title='0{field1}'")// Gantt Click
, c->xAxis()->getHTMLImageMap("clickable",
"title=label: {label}\\nfield2: {field2}", // Label: Tooltip What is here wrong???
"title='1{field2}'")); // Label: Click
m_Chart.setImageMap(sImageMap);
The following screenshot shows "PSR2" for field2, but should show "PSR3".
How should I add an "extrafield" to use it for manually added labels?
|
Re: Add Extrafield for xAxis labels - don't work |
Posted by Peter Kwan on Dec-16-2011 08:35 |
|
Hi Fabian,
For labels on the an axis, the extra field is indexed by the x-coordinate, which is "d" in your code "c->xAxis()->addLabel(d, TCHARtoUTF8(strTitle));". If "d" is not an integer, it will be rounded to an integer for indexing the extra field.
For your case, are the position of your labels at d = 0, 1, 2, 3, ..., or are they are other positions?
To further diagnose the problem, I suggest you use:
char buffer[1024];
sprintf(buffer, "%f => %s", (double)d, m_pFilterResult->pTitleBez[(int)(d + 0.5)]);
c->xAxis()->addLabel(d, buffer);
With the above code, we can see the x-coordinate of your label, and which extra field element it should be using. You can then check if the tooltip is showing the same extra field element. If they are the same, then the extra field is working normally.
Actually, in your code, you seem to be using some custom code to show the tooltip (your getHTMLImageMap has two "title" configurations). If this is the case, you may consider to just put the x-coordinate in the tooltip, like "title={value}". In your custom tooltip code, based on the x-coordinate, you can look for the tooltip you want to show in m_pFilterResult->pTitleBez and display it. In this way, there is no need to use extra fields at all.
Hope this can help.
Regards
Peter Kwan |
Re: Add Extrafield for xAxis labels - don't work |
Posted by Fabian on Dec-16-2011 15:15 |
|
Hi Peter,
at the moment I'm using only chartdirector code to show the tooltip:
CString sImageMap;
sImageMap.Format("%s%s"
// gantts: tooltip and click
, c->getHTMLImageMap("clickable",
"title={field1}\\n{field3}\\n{top|dd.mm.yyyy} - {bottom|dd.mm.yyyy}", // Gantt Tooltip
"title='0{field1}'")// Gantt Click
// labels: tooltip and click
, c->xAxis()->getHTMLImageMap("clickable",
"title=label: {label}\\nfield2: {field2}", // Label: Tooltip
"title='1{field2}'")); // Label: Click
m_Chart.setImageMap(sImageMap);
=> "your getHTMLImageMap has two "title" configurations"
Is the 'title=' usage not needed for the tooltip configuration?
By debugging my code like you have recommended me, I get some further informations.
The problem seems to be the index. But, how does chartdirector select the correct label for the tooltip by using "{label}"? {label} works, but with some spaces before the text.
Because of this I would like to use extra field. How should I use addExtrafield in my case?
|
Re: Add Extrafield for xAxis labels - don't work |
Posted by Fabian on Dec-16-2011 15:27 |
|
just a correction:
In my last post I copied the ImageMap code from my first post. The following code is the current one:
CString sImageMap;
sImageMap.Format("%s%s"
, c->getHTMLImageMap("clickable",
"title={field1}\\n{field2}\\n{top|dd.mm.yyyy} - {bottom|dd.mm.yyyy}", // Gantt Tooltip
"title='0{field1}'")// Gantt Click
, c->xAxis()->getHTMLImageMap("clickable",
"title={value} label: {label}\\nfield0: {field0}", // Label: Tooltip
"title='1{field0}'")); // Label: Click
m_Chart.setImageMap(sImageMap); |
Re: Add Extrafield for xAxis labels - don't work |
Posted by Fabian on Dec-16-2011 15:37 |
|
Okay, I have a solution for my problem. Until now, I have used 0.5 steps. By changing them to 1.0 the tooltip corresponds now to the labels.
Old:
for(d=0.0;d<dMax;d+=0.5)
{...c->xAxis()->addLabel(d, TCHARtoUTF8(strTitle));...}
Now:
for(d=0.0;d<dMax;d+=1.0)
{...c->xAxis()->addLabel(d, TCHARtoUTF8(strTitle));...} |
|