Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Label some points on a scatter plot
Lotuseater
I have drawn a scatter plot and want to label some of the points with the integers 1, ,n. I have done an initial version of the code with a default condition for whether to label a point, and this works just as I want. Now I have created a boolean column in the data set which specifies whether a point should have a label. The x values of my points are typically unique (they are large floats produced by a monte carlo simulation), so I made an array of the x values of the points I wanted to label using the OnCreate event of a hidden table. When I try and access this array through a dynamic text item, I can with no problem.
In the onRender event for the chart, I put the following (and defined the function contains())
var labelCount = 1;
function beforeDrawDataPointLabel(dph, label, icsc)
{
if(contains(myLabelArray,dph.getBaseValue()))
{
var newval = labelCount.toFixed(0);
label.getCaption().setValue(newval);
labelCount++;
}
else label.setVisible(false);
}
Since it worked with a value condition in place of contains(myLabelArray,dph.getBaseValue()), and the error message is that the array is undefined, the problem should be something to do with the onRender event for the chart not having access to the array. What am I doing wrong?
Find more posts tagged with
Comments
kclark
I looks like you could pass the array as a persistentGlobalVariable into your chart script.