Highcharts bar graph doesn't show yaxis values

I am facing a problem showing the y-axis values in a graph. This is my code :

var options = {
            chart: {
                renderTo: 'charts_container',
                type: 'column'
            },
            title: {
                text: selecte_company+' '+duration+' '+selecte_branch+' '+selected_menu 
            },
            colors: ['#ABD373', '#FFD285', '#EC5657'],
            legend: {
                itemStyle: {
                    color: '#737979'
                }
            },
            xAxis: {
                categories: xAxis
            },
            yAxis: {
                title: {
                    text: yAxis
                }
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            series: [{}]
        };
        $.getJSON(dataLink, function(data) {
        console.log("data");
        console.log(data);
        console.log(data.length);
        console.log(data[0].data.length);
            if (data[0].data.length == 0) {
                $('#charts_container').html('<p id="defalip";>No data found..</p>');
            } else {
                options.series = data;
                var chart = new Highcharts.Chart(options);
            }
        });

And my json is :

[{"name":"value1","data":[[0.91]]},{"name":"valur4 %","data":[[42.63]]}]

enter image description here

I want to show my data like this:

enter image description here

Upvotes: 0

Views: 675

Answers (1)

wergeld
wergeld

Reputation: 14442

If you look at your data [{"name":"value1","data":[[0.91]]},{"name":"valur4 %","data":[[42.63]]}] you have the name set to valueXXX - this is what is going to be shown on the xAxis. If you want your chart to look like the rainfall example it would be best to look at the actual code used to render it. You can see that there are multiple series:

series: [{
  name: 'Tokyo',
  data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]

}, {
  name: 'New York',
  data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]

}, {
  name: 'London',
  data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2]

}, {
  name: 'Berlin',
  data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]
}]

As well as a definition of what the xAxis categories are:

xAxis: {
  categories: [
    'Jan',
    'Feb',
    'Mar',
    'Apr',
    'May',
    'Jun',
    'Jul',
    'Aug',
    'Sep',
    'Oct',
    'Nov',
    'Dec'
  ],
  crosshair: true
},

In your code you have

    xAxis: {
        categories: xAxis
    },

I do not see where you are defining your xAxis list here.

To reproduce a graph like the demo you are going to need to produce multiple series and create an xAxis.categories array to hold what each point in each series will have as its xAxis label.

Upvotes: 1

Related Questions