I'm working with Highchart. I've got a multiple series graph in which each series have their own y-axis.
pretty much like this one (jsfiddle)
when we click on the legend item for a series, it hides it and the associated y-axis (using showEmpty:false
helped hiding also the name of the axes)
What I'm trying to achieve is hiding the y-Axis of a given series without hiding the series itself.
I tried to hide it by modifying the showAxis property like this :
serie.yAxis.showAxis = false;
but it doesn't work. Anyone knows how I should do ?
EDIT : I managed to edit the text so I can remove the axis title by setting the text to null but its not enough to hide the whole axis and its values.
here's what i did to edit the text:
serie.yAxis.axisTitle.attr({ text: null });
When we create a plot in R, the Y-axis labels are automatically generated and if we want to remove those labels, the plot function can help us. For this purpose, we need to set ylab argument of plot function to blank as ylab="" and yaxt="n" to remove the axis title.
Chart showing use of multiple y-axes, where each series has a separate axis. Multiple axes allows data in different ranges to be visualized together. While this in some cases can cause charts to be hard to read, it can also be a powerful tool to illustrate correlations.
Re: can i Pass multiple series by single object? you can use loop and addSeries function http://api.highcharts.com/highcharts#Chart.addSeries() to add each of them.
If you are a developer who would like to create hosted charts programmatically, then the Highcharts Cloud API might be for you.
Highcharts 4.1.9+
Since 4.1.9, there is an option Axis.visible which can be used to show/hide an axis, demo: http://jsfiddle.net/3sembmfo/36/
Older versions of Highcharts
It's a new feature for Highcharts 3.0 - that allows to update axes in realtime: chart.yAxis[0].update(object)
- as object takes the same options as for creating chart. For example:
chart.yAxis[0].update({ labels: { enabled: false }, title: { text: null } });
And jsFiddle: http://jsfiddle.net/39xBU/2/
EDIT:
Use below snippet to hide/show axis by just calling axis.hide()
and axis.show()
. Live demo: http://jsfiddle.net/39xBU/183/
(function (HC) { var UNDEFINED; HC.wrap(HC.Axis.prototype, 'render', function (p) { if (typeof this.visible === 'undefined') { this.visible = true; } if(this.visible) { this.min = this.prevMin || this.min; this.max = this.prevMax || this.max; } else { this.prevMin = this.min; this.prevMax = this.max; this.min = UNDEFINED; this.max = UNDEFINED; } this.hasData = this.visible; p.call(this); }); HC.Axis.prototype.hide = function () { this.visible = false; this.render(); HC.each(this.plotLinesAndBands, function (plotLine) { plotLine.render(); }); }; HC.Axis.prototype.show = function () { this.visible = true; this.render(); HC.each(this.plotLinesAndBands, function (plotLine) { plotLine.render(); }); }; })(Highcharts);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With