简体   繁体   中英

Highcharts X-Axis as Text

In this fiddle , with out changing the series data, Is it possible to show x-axis labels as text ie {"apple","orange","mango"} instead of decimals ie{0,1,2} with out seperating labels from JSON and providing it to Categories.

$(function () {
$('#container').highcharts({
    chart: {
    },
            xAxis: {
        tickInterval: 1,
        labels: {
            enabled: true
            }
    },

    series:  [{name:"ser1",data:[["apple",29.9], ["orange",71.5], ["mango",106.4]]},{name:"ser2",data:[["apple",40], ["mango",90]]}]        
});

});

use catgories in xAxis

categories: ["apple","orange","mango"],

I've updated your fiddle at http://jsfiddle.net/Lq6me/1/

if don't want to use categories you can go for

labels:{
formatter: function() {}
}

hope this will help you

Try This:

$(function () {
var seriesData = [{name:"ser1",data:[["apple",29.9], ["orange",71.5], ["mango",106.4]]},{name:"ser2",data:[["apple",40], ["mango",90]]}];

$('#container').highcharts({
    chart: {
    },
            xAxis: {
        tickInterval: 1,
        labels: {
            enabled: true,
            formatter: function() { return seriesData[0].data[this.value][0];},
            }
    },
    series:  seriesData     
  });
});

SEE DEMO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM