|
How to enable hotspot on CDMLTable |
Posted by David on Feb-06-2024 12:50 |
|
I have a CDMLTable under my BarChart. Its layout looks like the datatable.png below.
I want to be notified the row and column of table cell when I click the cursor over table. It should be a hot spot but I have no idea how to do that via getHTMLImageMap(). Please help.
I am using C++.
Thanks,
David
|
Re: How to enable hotspot on CDMLTable |
Posted by Peter Kwan on Feb-07-2024 02:16 |
|
Hi David,
In other editions of ChartDirector that supports web applications, there are examples that demonstrate how to create custom image maps. A custom image map can be used if there is no built-in image map for an object, such as custom icons (eg. as company logo), addMark labels, etc). However, we have not included such examples in C++.
The image map used by ChartDirector is the standard HTML image map (<area> tags). If we can find out the pixel coordinates of the object, we can construct the image map.
For the CDMLTable in your attached image, the following is one way to generate the image map
// Output the chart
viewer->setChart(c);
//include tool tip for the chart
std::ostringstream imageMap;
// Construct image map for the table by finding the pixel coordinates of the cells
int py = c->getPlotArea()->getBottomY();
for (int row = 0; row < table->getRowCount(); ++row)
{
int height = table->getCell(table->getColCount() / 2, row)->getHeight();
for (int col = 0; col < labels_size; ++col)
{
imageMap << "<area href='clickable?col=" << col << "&row=" << row
<< "' title='(" << col << ", " << row << ")'" << "shape='rect' coords='"
<< c->getXCoor(col - 0.5) << "," << py << "," << c->getXCoor(col + 0.5) << "," << (py + height) << "'>";
}
py += height;
}
// Include the original image map
imageMap << c->getHTMLImageMap("clickable", "", "title='Revenue of {dataSetName} in {xLabel}: US$ {value}M'");
viewer->setImageMap(imageMap.str().c_str());
Best Regards
Peter Kwan |
Re: How to enable hotspot on CDMLTable |
Posted by David on Feb-07-2024 07:40 |
|
Hi Peter,
Thank you very much. It perfectly solved my problem.
Regards,
David |
|