|
Tooltip / Hotspot |
Posted by Mrx Rch on Jul-01-2017 04:07 |
|
Hello Peter,
I use finance chart and I set up custom "scatterPlotter" for buy / sell positions:
ScatterLayer *buyLayer = myMainChart->addScatterLayer(DoubleArray(), buySignal, "Buy", Chart::ArrowShape(0, 1, 0.4, 0.4),
11, 0x00ffff);
Q1: What should be the first parameter? (I use now DoubleArray() and seems to work fine).
Q2: I would like to set up some nice tooltips on these signals, how should I proceed?
If I use
viewer->setImageMap(viewer->getChart()->getHTMLImageMap("clickable", "",
"title='X[{dataSetName}] Value = {value}, {xLabel|yyyy-mm-dd}'"));
then this
1) adds up for all the other layers, too (like SMA, Bollinger, etc);
2) slows down the whole chart (when I zoom in / drag the chart).
Q3: I would also show custom data - I guess this can be done easily if I have an array with all the data and I compute the index from coordinate (xValue) ?
thx in advance,
br, Rch |
Re: Tooltip / Hotspot |
Posted by Peter Kwan on Jul-04-2017 02:59 |
|
Hi Mrx Rch,
You can use BaseChart.setHTMLImageMap to configure an image map just for the scatter layer. It is like:
ScatterLayer *buyLayer = myMainChart->addScatterLayer(DoubleArray(), buySignal, "Buy", Chart::ArrowShape(0, 1, 0.4, 0.4),
11, 0x00ffff);
buyLayer->setHTMLImageMap("clickable", "", "title='xxxxx'");
.......
// The default image map is disabled. So only layers with specially configured image map remains.
viewer->setImageMap(viewer->getChart()->getHTMLImageMap("{disable}"));
Hope this can help.
Regards
Peter Kwan |
Re: Tooltip / Hotspot |
Posted by Mrx Rch on Jul-04-2017 04:00 |
|
Hello Peter!
this is impressive! it works and everything is cool!
can I somehow achieve a click on it? (So if I click on it, then a dialog appears or so) ?
and many thanks for your great explanations and answers! Really helpful.
br, Rch |
Re: Tooltip / Hotspot |
Posted by Peter Kwan on Jul-04-2017 14:41 |
|
Hi Mrx Rch,
Most of the charts in the mfcdemo/mfcdemo sample project are all clickable. You can use the code in that project as an example. In brief, you just need to handle the mouse click event (the BN_CLICK message) of the CChartViewer. In the event handler, you can use the ImageMapHandler to find out which hot spot (if any) the mouse has clicked.
Below is the mouse click event handler code I copied ans pasted from the mfcdemo/mfcdemo project.
// Handles mouse clicks on the chart image
void CmfcdemoDlg::OnClickHotSpot(UINT nID)
{
// In this demo program, all ChartViewers are handled by this handler. We need to
// retrieve the ChartViewer that generates the message and get its ImageMapHandler.
int chartViewerIndex = nID - IDC_CHARTVIEWER0;
ImageMapHandler *handler = m_ChartViewer[chartViewerIndex]->getImageMapHandler();
if (0 != handler)
{
// Query the ImageMapHandler to see if the mouse is on a clickable hot spot. We
// consider the hot spot as clickable if its href ("path") parameter is not empty.
const char *path = handler->getValue("path");
if ((0 != path) && (0 != *path))
{
// In this sample code, we just show all hot spot parameters.
CHotSpotDlg hs;
hs.SetData(handler);
hs.DoModal();
}
}
}
Hope this can help.
Regards
Peter Kwan |
|