0
votes

I have one highchart with X-axis looks like ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

So,while editing the value in the highchart for Jan month,In the drop event I am getting this.category =Jan. Is there any possiblity to plot x axis point with key-value pair so that I will get key as 'Jan' and value as 1.

2

2 Answers

1
votes

Create an object and use it for categories as follows

//Define this object
cats = {'Jan':1, 'Feb':2, 'Mar':3, 'Apr':4, 'May':5, 'Jun':6, 'Jul':7, 'Aug':8, 'Sep':9, 'Oct':10, 'Nov':11, 'Dec':12};

months=Object.keys(cats); // Prepare categories for x axis


//In Highcharts object set  categories: months



// In drop event use  cats.category
1
votes

Set xAxis type to category.

xAxis: {
    type: 'category'
}

Then using name, instead of x in the series data

data: [
    {name: 'Jan', y:24.13},
    {name: 'Feb', y:17.2},
    {name: 'Mar', y:8.11}
]