score:14
in case when you destroy legend, then you need to generate full legend. simpler solution is use hide() / show() function for elements.
http://jsfiddle.net/sbochan/3bh7b/1/
$('#updatelegend').click(function (e) {
var legend = chart.legend;
if(legend.display) {
legend.group.hide();
legend.box.hide();
legend.display = false;
} else {
legend.group.show();
legend.box.show();
legend.display = true;
}
});
score:-1
so far only working solution in the world:
for (i = 0; i < chart.series.length; i++)
chart.series[i].options.showinlegend = true;
chart.series[0].setdata(chart.series[0].data);
rendering manually doesn't work (hiding legend.box etc, always if there are multiple pages in legend, then browser button stays).
setdata
calls internal renderer which acts quite good and does all what is needed.
hmm, maybe in the end you can do this:
chart.setsize(
chartwidth,
chartheight+chart.legend.fullheight,
false
);
score:0
update a code little bit of selected answer. now it will increase the space when show/hide legend.
$('#updatelegend').click(function (e) {
var legend = chart.legend;
if(legend.display) {
legend.group.hide();
legend.box.hide();
legend.display = false;
} else {
legend.group.show();
legend.box.show();
legend.display = true;
}
var series = chart.series[0];
$(chart.series).each(function(){
this.setvisible(true, false);
});
chart.redraw();
});
score:5
a fairly simple way to make this is to loop over the series and update them to not show in legend. this allows you to animate in and out of showing the legend and utilize the entire container space, as the methods are built in.
for example, toggling legend items would look like this:
$('#togglebutton').click(function() {
for(i in chart.series)
chart.series[i].update({ showinlegend: chart.series[i].options.showinlegend == null ? false : !chart.series[i].options.showinlegend }, false);
chart.redraw();
});
see this jsfiddle demonstration for toggle, show and hide using buttons.
score:8
as simple as
mychartobject.legend.update({
enabled:true
)};
score:14
here is an interesting solution i came up with - works for highcharts3 and highstocks1.3 https://bitbucket.org/jkowalleck/highcharts-legendextension
all you have to do is to add the highchartsextension i wrote to your html page, and you get 3 new functions added to the chart:
mychart.legendhide()
,
mychart.legendshow()
and
mychart.legendtoggle()
see the examples:
in highcharts with floating legend: http://jsfiddle.net/p2g6h/
in highstocks with static legend: http://jsfiddle.net/ps6pd/
Source: stackoverflow.com
Related Query
- Change the legend in highcharts heatmap to show instead of a color bar, a set of fixed icons with hide and show on click
- Highcharts: Hide and show legend
- How can I hide and show a category in highcharts
- Show tootip and select pie slice on legend click of pie chart in HighCharts
- Highcharts show max., min., and average for each serie in legend
- plotBands Hide and Show parameters do not work in Highcharts
- Highcharts - Xaxis should show only days and month, hide milliseconds
- Highcharts - show markers on zoom event (selection) and hide on reset zoom. Is it possible?
- HighCharts Hide Series Name from the Legend
- Hide axis and gridlines Highcharts
- Highcharts - How to programmatically toggle legend items and determine which items are selected
- Highcharts - How to hide series name and Y value in tooltip
- Highcharts : Venn Diagram how to show total and union numbers?
- Is it possible to hide the line & symbol next to Highcharts legend items?
- How to Check and Uncheck all the Legend elements in HighCharts Linechart?
- Highcharts - Hide child labels in a multiple levels and multiple layouts treemap
- Highcharts connecting scatter chart and pie chart with single legend
- How can i force Highcharts to use same symbols in Legend and Series?
- Legend and Axis titles not showing in Highcharts Graph
- Legend and Axis titles not showing in Highcharts Graph
- Highcharts - Global configuration with common code and unique data & Headings
- Show only first and last xAxis label in Highcharts
- How do I hide a Highcharts series from the chart, but always show it in the tooltip?
- Highcharts hide series without change legend color
- Show / Hide plotband in Highcharts - Javascript
- Highcharts: show series on legend but hide on chart
- Highcharts - Hide series "points" (labels) on both x- and y-axis
- How to center highcharts pie chart and legend on a page?
- Showing HighCharts series name on x-axis and in legend
- Highcharts show the same yAxis start and end value with multiple data series
More Query from same tag
- How to programatically hide a tooltip in highcharts?
- How could you supply multiple series to a line chart in R shiny using highcharter package and without hardcoding the series?
- Highcharts x-axis tick starts with an offset
- How can I get every bar in different colour using Highchart?
- highstocks chart showing extra month
- Highcharts not zooming series using option Highcharts.Series.prototype.drawPoints = function() { }
- can't enter django chartit formatter field
- Highcharts-serverside-export not rendering graph with Rhino 1.7R3
- Highcharts width exceeds container div on first load
- How to create column-range chart from data of a HTML table?
- How to set width limitation for text in highcharts?
- Highchart: xAxis Label text not displayed when plotting 2 points
- create a chart with date values in highchart
- Highcharts : remove custom legend tooltip from export
- Highcharts not rendering in jQuery tooltip
- Additive Color in Highcharts
- Change data periodicity in Highcharts time series?
- Highcharts tooltip date format when using pointFormat
- See Highcharts tooltip under a image
- Using css to customise highcharts in Ionic 4
- How to pass array in highchart ??
- Spline graph not showing in highchart
- How to create a div container for a highcharts graphic by means of code?
- Highcharts: How to show marker in X range chart?
- highcharter hc_axis not working correctly
- How to handle HighCharts zooming with large data sets
- How to pass a value to javascript?
- Percentage for left style of a custom label in highcharts
- Display legend and colorAxis at different positions in Highchart
- Define yAxis value with two different yAxis scale highcharts