Highcharts problem - showing labels in zoomable chart -


i have zoom column chart more 200 categories in xaxis. consequently, when in initial state (scale 1:1), these guys shown under x axis, , it's impossible read if place them vertically. need zoom chart make labels visible.

here's screenshot of problem: enter image description here

here's code: http://jsfiddle.net/sherlock85/hjcqm/

is possible adjust concentration of labels (perhaps change step automatically) depending on zoom level?

i appreciate help.

thanks, andrzej

in order easiest difficult...

since categories numeric (e.g. 'mir001'), omit categories, prevent them being displayed. show 1, 2, 3, , on.

alternatively, remove categories , use label formatter. in case, this, again taking advantage of fact labels appear numeric , increasing:

chart = new highcharts.chart({     xaxis: {         labels: {             formatter: function() {                 return "mir" + this.value;             }         }     } }); 

both of above reduce number of labels (the labels follow pattern such 1, 50, 100, until zoomed).

if wanted particular labels, have use label formatter , math find scale of graph determine how labels should displayed. could, example, this, though quite convoluted:

var categories = [] //have categories separate list var buckets = 4;  var labelformatter = function(frequency) {     var count = 0;     frequency = frequency || 0;     return function () {         count++;         if ((count > frequency) || (frequency < 1)) {                 return this.value         }     } };  chart = new highcharts.chart({     zoomtype: 'x',     events: {         selection: function(event) {             if (event.xaxis) {                 var scale = event.xaxis[0];                 var frequency = math.floor((scale.max - scale.min) / buckets)                 this.xaxis[0].labels.formatter = labelformatter(frequency);             }         }     },     xaxis: {         labels: {             formatter: labelformatter(math.floor(categories.length/buckets))         }     } }); 

i should point out last solution doesn't work, further illustrating how difficult is.


Comments