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)
Toggling Data Label Visibility (Client Side)
SChu
<p>I have implemented a script which reverses the default show/hide functionality of the legend (see below) to hide all except the selected entry. Unfortunately I am having trouble with the other part of my desired functionality, showing/hiding the data labels on the same event (Due to an issue with the relative sizes of the stacked bar elements involved here, if data labels are on all of the time the chart becomes illegible)<br>
<br>
This part in the page:</p>
<blockquote class="ipsBlockquote">
<p><script type="text/javascript"><br>
var lastSeries = "";<br>
function SeriesToggle(thisVal, thisSeries, bookmark)<br>
{<br>
debugger;<br>
var bpagecontents = thisVal.getCurrentPageContent( );<br>
var bchart = bpagecontents.getChartByBookmark(bookmark);<br>
var series = bchart.getClientChart()._chart.series;<br>
for(i = 0; i < series.length; i++)<br>
{<br>
if(lastSeries != "" && lastSeries == thisSeries)<br>
{<br>
bchart.getClientChart( ).setSeriesVisible(series
.name, true);<br>
}<br>
else if(thisSeries != series
.name && series
.visible)<br>
{<br>
bchart.getClientChart( ).setSeriesVisible(series
.name, false);<br>
}<br>
else if(thisSeries == series
.name)<br>
{<br>
bchart.getClientChart( ).setSeriesVisible(series
.name, true);<br>
}<br>
}<br>
if(lastSeries == thisSeries)<br>
{<br>
lastSeries = "";<br>
}<br>
else<br>
{<br>
lastSeries = thisSeries;<br>
}<br>
}<br>
</script></p>
</blockquote>
<p> </p>
<p>This part in the chart as a script invoked upon click events:</p>
<blockquote class="ipsBlockquote">
<p>SeriesToggle( actuate.getViewer("NavigationBar") ,evt.currentTarget.name, "CHART01103");</p>
</blockquote>
<p> </p>
<p>Does anyone know how I can show/hide those labels? All of the results when I google are from 2006-2009 and are discussions of eclipse BIRT functionality where showing/hiding these labels on a click event was a chart creation pull-down menu option.</p>
Find more posts tagged with
Comments
JFreeman
<p>From what I have been able to figure out, it looks like there is a server side setting for the data labels visibility that takes precedence over the client side high charts visibility settings:</p>
<pre class="_prettyXprint _lang-js">
function beforeDataSetFilled( series, idsp, icsc )
{
series.getLabel().setVisible(true);
}
</pre>
<p>Therefore, hooking the chart client side like you are doesn't appear to allow for changes to this visibility. You can hook the visibility client side like this "series.options.dataLabels.enabled" but from what I can tell there isn't a way to apply changes that will actually take effect.</p>
<p> </p>
<p>However, I have been able to set the visibility to hidden in the CSS properties of the element client side by hooking it from within the DOM tree:</p>
<pre class="_prettyXprint _lang-">
var child = document.getElementsByClassName("highcharts-data-labels highcharts-tracker");
child[0].setAttribute('style','visibility:hidden');
</pre>
<p>This isn't the most elegant solution but it did work in my testing. Please note, if the data labels are set to be off when the chart is rendered the DOM element wont be created so this CSS change wont work. But, if the data labels are all turned on to start with you should be able to set all the required series to hidden then back to visible as needed.</p>