Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make simple bar chart using C3 with separate columns on the x axis

Tags:

People also ask

What is the x-axis on a bar chart?

Understanding a Bar Graph The bars display the value for a particular category of data. The vertical axis on the left or right side of the bar graph is called the y-axis. The horizontal axis at the bottom of a bar graph is called the x-axis. The height or length of the bars represents the value of the data.

How do you make a split bar graph in Excel?

Right-click the chart, and select Change Series Chart Type from the context menu. See screenshot: 4. In the Change Chart Type dialog box, please click Bar in the left bar, click to highlight Stacked Bar, next click to select the chart with two series, and finally click the OK button.


I'm trying to create a bar chart using C3 and D3 but I'm having trouble getting the columns to be unrelated to each other, other than for the fact that they use the same scale on the Y-axis.

I've included images to better explain.

var chart = c3.generate({
    bindto: '#designerChart',
    data: {

      columns: [
        ['MA', 6],
        ['ME', 8],
        ['NY', 6],
        ['CN', 5],
        ['TX', 2]
      ],
      type: 'bar',

    },
    axis: {
        y: {
            max: 10,
            min: 0,
            padding: { top: 0, bottom: 0 }
        }
    }
});

Results in a group of bars and when I hover over them I get the details for all the bars - not what I want.

Bar chart but grouped like a stepped column

I can change the data, so that it displays separate columns, but they are the same color and when I want to transition it to a pie chart you can't distinguish between the states.

var chart = c3.generate({
    bindto: '#designerChart',
    data: {
      x: 'x',
      columns: [
        ['x','MA', 'ME', 'NY', 'CN', 'TX'],
        ['rainfall', 6, 8, 6, 5, 4 ]
      ],
      type: 'bar',

    },
    axis: {
        x: {
            type: 'category'
        },
        y: {
            max: 10,
            min: 0,
            padding: { top: 0, bottom: 0 }
        }
    }
});

chart, but not different colors pointless pie chart

This is what I want:

enter image description here