question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chart with categories and rotated axis does not display correctly

See original GitHub issue

Example:

chart = c3.generate({
    data: {
        columns: [
            ['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250]
        ]
    },
    axis: {
        x: {
            type: 'categorized',
            categories: ['category 1', 'category 2', 'category 3', 'this is another category', 'cat5', 'cat6', 'cat7', 'cat8', 'cat9']
        },
        rotated: true
    }
});

In the following screnshot, see how the category ‘ticks’ are clipped on the left (not shown is how the tooltips are pushed to the right as well): rotated_categories

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
radiodariocommented, Oct 8, 2015

I have found an error with the calculation where if we have two labels and the longest one is second on the chart, the padding isn’t calculated correctly: screen shot 2015-10-08 at 11 27 41

However, when the longest label is first, it works just fine: screen shot 2015-10-08 at 11 27 27

Note that this only happens when there are 2 categories, and if we add 3 or more it works fine.

Here’s the c3 code to reproduce the issue:

var chart = c3.generate({
    data: {
        json: [
            {
                thing: 'Short',
                value: 1000
            }, 
            {
                thing: 'AlongerName',
                value: 2304
            }

        ],
        keys : {
            x: 'thing',
            value:  ['value']
        },
        type: 'bar'
    },
    axis: {
        rotated: true,
        x: {
            type: 'category',
            label: 'thingy'
        },
        y: {
            label: 'something'
        }
    }
});

I’ve created a jsfiddle to illustrate the point

0reactions
phandelcommented, Mar 2, 2017

+1 … only happens with 2 entries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the display of chart axes - Microsoft Support
In a chart, right-click the axis that displays the labels that you want to format. On the Home toolbar, click the formatting options...
Read more >
Excel Chart not showing SOME X-axis labels - Super User
On the sidebar, click on "CHART OPTIONS" and select "Horizontal (Category) Axis" from the drop down menu. Four icons will appear below the...
Read more >
Rotate charts in Excel - spin bar, column, pie and line charts
You can rotate your chart based on the Horizontal (Category) Axis. ... screenshot below, you can see that the chart doesn't fit correctly....
Read more >
Graph category axis labels not displaying correctly - Telerik
Hi, Ive got a graph which is very small but has a lot of bars on it, using a category scale. Obviously theres...
Read more >
X Axis does not display correctly date and time intervals
I don't know why the min value for the Y axis is so low, assuming you left it as "auto" in the chart...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found