|
Add Extra String to ToolTip |
Posted by Lavanya on Oct-20-2010 00:05 |
|
I am plotting multi-line chart.
In the legend I am displaying short name, But in the tool tip I want to display full name along with short name(By using getHTMLImageMap),
Can you please help me How to do customized tool tip on mouseover.
Presently I am using PHP ChartDirector, Licensed Version. |
Re: Add Extra String to ToolTip |
Posted by Peter Kwan on Oct-20-2010 03:13 |
|
Hi Lavanya,
You may add an extra field for your long names, and use them for tooltips. For example:
#one long name for each data set
$myLongNames = array(".... some long name ....", "... another long name ....", ......);
$layer->addExtraField($myLongNames);
Then you may use {dsField0} to represent the extra field. For example, in the tooltip configuration, you may use:
title='{dsField0}: ({xLabel}, {value})'
Hope this can help.
Regards
Peter Kwan |
Re: Add Extra String to ToolTip |
Posted by Lavanya on Oct-20-2010 04:15 |
|
Hi Peter,
I tried with that logic, but no use.
Let me explain you in detail.
$chart = new XYChart($width, $height);
$layer=$chart->addLineLayer2();
for($i=0;I<5;$i++) // here i am creating individual layer for each plot...
{
--- other code----
$layer2=$chart->addLineLayer2();
$layer2->setDataLabelFormat("{field0}");
// normal string that has to be displayed on the chart for individual plot
$layer2->addExtraField($string1);
}
$layer->setDataLabelFormat("{field0}");
$layer->addExtraField($fullName);
$showText = "onmouseover='showInfo(\\"{xLabel}\\", {value});' ";
$hideText = "onmouseout='showInfo(null);' ";
$toolTip = "title='{dsField0}({xLabel}: {value|0}%)'";
$imageMap = $chart->getHTMLImageMap("URL ", " ","$showText$hideText$toolTip");
Should I add that extrafield(FullName) to main layer object "$layer", or individual layer object "$layer2". |
Re: Add Extra String to ToolTip |
Posted by Peter Kwan on Oct-20-2010 16:22 |
|
Hi Lavanya,
The code I suggested assumes your code structure is similar to the "Multi-Line Chart" sample code that comes with ChartDirector. In particular, it assumes you have one layer with multiple data sets. In your case, you seem to have multiple layers. I do not know how many data sets are there per layer, as your have not included that part in your message. I am also not sure what is the purpose of $layer and $layer2 (I am not sure which layer the data are added to). There also seems to be logical error in your code (eg. should "I<5" be "$i<5"). Finally, your code is not using standard tooltips at all, but HTML pop up layers, so the code for tooltips do not apply.
I just guess you are putting one data set per layer, and the data are attached to $layer2.
In this case, $layer seems not used, so you may remove it.
If I were you, I would use something like:
$chart = new XYChart($width, $height);
for($i=0;I<5;$i++) // here i am creating individual layer for each plot...
{
$layer2=$chart->addLineLayer($myDataSeries[$i], -1, $string1);
$layer2->setDataLabelFormat("{dataSetName}");
$layer2->addExtraField(array($fullName));
}
$showText = "onmouseover='showInfo(\\"{dsField0}: {xLabel}\\", {value});' ";
$hideText = "onmouseout='showInfo(null);' ";
$imageMap = $chart->getHTMLImageMap("URL ", " ","$showText$hideText");
Hope this can help.
Regards
Peter Kwan |
Re: Add Extra String to ToolTip |
Posted by Lavanya on Oct-20-2010 21:56 |
|
Hi Peter,
I used "$layer2" for individual plot becoz i need to add an extrafield "short Name" on the chart. It has tobe displayed on the chart. I solved that problem.
In the tooltip or mouse over i need to display full name.
$fullNames = array("FullNmae1","FullName2");
$chart = new XYChart($width, $height);
$layer=$chart->addLineLayer2();
for($i=0;$i<5;$i++) // here i am creating individual layer for each plot...
{
--- other code----
$layer2=$chart->addLineLayer2();
$layer2->addDataSet($data[$i],$colors[$i], $tempString);
// normal string that has to be displayed on the chart for individual plot
$layer2->setDataLabelFormat("{field0}");
$textbox = $layer2->setDataLabelStyle("arial.ttf", 10,$colors[$i]);
$layer2->addExtraField($shortName);
$textbox->setPos($xpos,$ypos);
}
Shall I add
"$fullName" ( full name of individual plot) in the for loop to the "$layer2"
or
"$fullNames" ( array of all the plots) after for loop while generating imagemap. |
Re: Add Extra String to ToolTip |
Posted by Peter Kwan on Oct-21-2010 02:57 |
|
Hi Lavanya,
In general, if the names are added to a layer, it will only affect the layer.
For your case, the data are in $layer2. So the name should be added to $layer2. Each $layer2 only needs one name because there is only one data set in each $layer2. Because you have already used an extra field for some other purpose and it is referenced as {field0}, so the second extra field should be referenced as {dsField1}.
for($i=0;$i<5;$i++) // here i am creating individual layer for each plot...
{
--- other code----
$layer2=$chart->addLineLayer2();
$layer2->addDataSet($data[$i],$colors[$i], $tempString);
// normal string that has to be displayed on the chart for individual plot
$layer2->setDataLabelFormat("{field0}");
$textbox = $layer2->setDataLabelStyle("arial.ttf", 10,$colors[$i]);
$layer2->addExtraField($shortName);
$textbox->setPos($xpos,$ypos);
$layer2->addExtraField(array($oneFullNameForTheLayer));
}
Then in the image map, please use {dsField1} to reference the second extra field (the full name).
Hope this can help.
Regards
Peter Kwan |
Re: Add Extra String to ToolTip |
Posted by Peter Kwan on Oct-22-2010 05:24 |
|
Hi Lavanya,
I have modified your code using the same method as explained in my previous message, and it is now showing the fullname.
Hope this can help.
Regards
Peter Kwan |
Re: Add Extra String to ToolTip |
Posted by Lavanya on Oct-22-2010 18:41 |
|
Thank You Peter. |
|