Take the 2-minute tour ×


I'm trying to change categories dynamically in a column chart with a json. Something like this...



  xAxis: {
                    categories: this.category,
                    maxZoom: 1

Is it possible?

Thanks. :D

share|improve this question
you need to post some code. you can parse json as a javascript object, change the parameter you want to modify and re-render your chart. –  josh Jan 7 at 17:28
maxZoom is depracated, so I advice to use afterSetExtremes and check range. –  Sebastian Bochan Jan 9 at 9:31
I see in api, and then I replace by minRange. –  luckasx Jan 9 at 14:05
add comment

3 Answers

up vote 0 down vote accepted

Ok, maybe you can try it something like this:

var jsonData = [{
    "y": "1",
        "other": "other",
        "category": "namecategory1"
}, {
    "y": "2",
        "other": "another",
        "category": "namecategory2"

// var jsObject = JSON.parse(jsonData);
var categories = new Array();
for (var p in jsonData) {
share|improve this answer
add comment

You can dynamically load your categoreis i.e by json or other and then use setCategories which allows to change categoreis, dynamically.

share|improve this answer
see comment above. –  luckasx Jan 8 at 14:45
add comment

I think you need to set categories as an Array of primitive js types such as number or string.



As it is mentioned here: http://api.highcharts.com/highcharts#xAxis.categories : "If categories are present for the xAxis, names are used instead of numbers for that axis."

Maybe, when you mention JSON are you talking about Object Literals? (because "y" key in your sample is not quoted.)

In fact , you CAN use an Array of Object Literals. But they will be displayed as "[Object]" in the xAxis.

An object literal is a pair of curly braces surrounding zero or more name/value pairs. An object literal can appear anywhere an expression can appear:

var empty_object = {};
var stooge = {
first_name: "Jerome",
last_name: "Howard"


Maybe you can pre-process your JSON data an build an Array to be used in categories.

share|improve this answer
this way I already know. What I want is to 'fill' the chart data and categories with one json file if it is possible. –  luckasx Jan 8 at 14:44
are you going to use a specific 'key/value' contained in your JSON file to be displayed in xAxis? Give us a sample of your JSON file. –  Alberto Montellano Jan 8 at 14:53
Now with y quoted. [{""y"":1,"other":"other","category":"namecategory"}] –  luckasx Jan 8 at 17:35
Is the answer below helpful? If not, give more details of what you want to accomplish. –  Alberto Montellano Jan 8 at 18:03
Now it works, but I can't do like I imagine, something like... options.xAxis[0].setCategories(categories), before instantiate the chart. –  luckasx Jan 8 at 19:51
add comment

Your Answer


