|
add label to candlestick/boxwhisker chart? |
Posted by Jeff Smith on Jan-31-2025 04:11 |
|
Hi Peter, I'm plotting a 2D boxwhisker chart that works except for one thing (attached). I'm using the boxwhisker chart to plot expected values plus or minus 1 standard deviation by settting the high/low to the (mean +/- sd) and open/close=mean. This works fine. However, when I hover over a data point it doesn't show an ID for the corresponding x value.
Is there a way to correlate a label to include in the .SetImage() statement? Currently I have:
m_PlotChart.setImageMap(c->getHTMLImageMap("clickable", "",
"title='ID: {xLabel} \n+1SD:{high}\nEU:{open}\n-1SD:{low}'"));
which shows blank for ID and the 3 correct values for +1sd, EU, and -1sd.
If I replace xLabel with my array name for the x labels, idlabels[] in {} or [{}] it doesn't make the substitution.
maybe i need to create a data set like this?
id,x value, hi, low, open, close.
or, will the image map only work with whatever the x value happens to be? I have another bar chart where the label does work in the imagemap.
thanks for any suggestions,
jeff smith |
Re: add label to candlestick/boxwhisker chart? |
Posted by Peter Kwan on Jan-31-2025 13:27 |
|
Hi Jeff,
{xLabel} refers to the axis label at the given x position. In your chart, 0, 500, 1000, ... are the labels. If the box happens to be in a non-labelled position (like 480), there will be no {xLabel}. You can consider to use {x} instead of {xLabel}. "{x}" refers to the x-data value of the point.
In brief, if your code provides the x-axis labels (eg. using Axis.setLabels), the {xLabel} is the label you provided, and ChartDirector will use the array index (0, 1, 2, 3, ....) as the {x} coordinates. This allows you to add other things to the chart as any x position.
If your code provides the x data values (eg. using Layer.setXData), the {x} will be the data value you provided. ChartDirector will auto-scale the x-axis and put some labels on it (or you may use setLinearScale, etc, to set up the axis yourself), but most of the positions will have no labels.
Best Regards
Peter Kwan
|
Re: add label to candlestick/boxwhisker chart? |
Posted by Peter Kwan on Jan-31-2025 13:35 |
|
Hi Jeff,
I also noted your code only provides the x-coordinates of the candlestick layer, but not the line layer or box-whisker layer. The line layer is has no data so it is not plotted. The box-whisker layer may have some data, but since the x-coordinates is not provided, ChartDirector will use the array index 0, 1, 2, 3, .... as the x-coordinates. The small red lines at the left side of the chart is likely the box-whisker layer.
Best Regards
Peter Kwan |
Re: add label to candlestick/boxwhisker chart? |
Posted by Jeff Smith on Feb-01-2025 04:04 |
|
I am trying to do something like what the john vera thread of may 4, 2024 had. it looks like you created another data set with the same number of points but containing the labels to correlate with the x values. my box/whisker plot is basically x$ versus a value measure +/- the standard deviation. what distinguishes the boxes is not the cost but an ID summarizing the box. It seems like i should be able to create a second dataset of (x, ID) that I could reference in the .setimage statement so the tooltip lists the ID. e.g., if the list of ID's was ds2 i would put {ds2} in the statement:
m_PlotChart.setImageMap(c->getHTMLImageMap("clickable", "",
"title='ID: {xLabel} \n+1SD:{high}\nEU:{open}\n-1SD:{low}'"));
something like:
m_PlotChart.setImageMap(c->getHTMLImageMap("clickable", "",
"title='ID: {ds2} \n+1SD:{high}\nEU:{open}\n-1SD:{low}'"));
what do you think? Am i on the right track? |
Re: add label to candlestick/boxwhisker chart? |
Posted by Peter Kwan on Feb-01-2025 17:23 |
|
Hi Jeff,
If you have a custom series that you want to display in the tooltip, you can add it as an extra field:
BoxWhiskerLayer *markLayer = c->addBoxWhiskerLayer(........);
// One label for each box
char* myLabels[] = {"abc", "", "", "def", "", "hij", ....};
markLayer->addExtraField(StringArray(myLabels, myLabels_count));
Now you can use {field0} for the labels in the myLabels array in your tooltip.
See:
https://www.advsofteng.com/doc/cdcpp.htm#Layer.addExtraField.htm
Best Regards
Peter Kwan |
Re: add label to candlestick/boxwhisker chart? |
Posted by Jeff Smith on Feb-02-2025 07:45 |
|
THANK YOU PETER!!! This solved my problem exactly. Discovered it also works for candlestick chart with addCandleStickLayer(). Turns out I don't need the BoxWhisker. Not sure why I had both--probably newbie desperation. I was running in circles trying to get this to work.
Thanks again,
jeff |
|