Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C3 graph overlapping x-axis label

C3 graph overlap x-axis labels which is in date time format. I have googled this query but didn't get any solution for it.Is it possible that c3 only shows couple of date time rather then showing altogether which result in overlap x-axis labels enter image description here

var data = {
    x: 'x',
    xFormat:'%Y-%m-%d/%H:%M',
    empty: {
        label: {
          text: "No Data"
        }
    },
    columns: [
        ['x', '{$dateArray}'],
        ['Attack', {$data}],
    ],colors: {
        Attack: '#67b7dc',
    },
    types: {
        Attack: 'area'
    }};
var chart = c3.generate({bindto: '#chart1',
size: {
    height: 630,
},
data: data,
grid: {
    x: {
        show: true
    },
    y: {
        show: true
    }
},
tooltip: {
    format: {
        value: function (value, ratio, id) {
            var format = value+' Gbps  [ IP: '+destIp[value]+' ]';
            return format;            
        }
    }
},
zoom: {
    enabled: true
},
subchart: {
    show: true
},axis: {
    x: {
        type: 'timeseries',
        tick: {
            format: '%b %d, %H:%M',
            rotate: 90,
            multiline: false
        }
    },
    y: {
        tick: {
            format: function (d) {
                return d.toFixed(3);
            }
        },
        label: {
            text: 'Attack Size ( Gbps )',
            position: 'outer-middle'
        }
    }
}
});
like image 771
Shishir Mudliyar Avatar asked Aug 01 '16 11:08

Shishir Mudliyar


People also ask

How do you prevent X axis labels from overlapping each other?

0 A common problem in making plots, say a barplot or boxplot with a number of groups is that, names of the groups on x-axis label often overlap with each other. Till now, one of the solutions to avoid overlapping text x-axis is to swap x and y axis with coord_flip() and make a horizontal barplot or boxplot.

What should be the label for the X axis?

A chart can contain the following types of axis labels: Horizontal axis labels represent the X axis. They do not apply to pie, funnel, or gauge charts. Vertical axis labels represent the Y1 axis in a single axis chart.

What does X axis label mean?

The horizontal (category) axis, also known as the x axis, of a chart displays text labels instead of numeric intervals and provides fewer scaling options than are available for a vertical (value) axis, also known as the y axis, of the chart.


1 Answers

Use c3.js chart config tick.count, set it to desired integer value like 2,3 or 4.

Use c3.js Timeseries Chart exmaple to play with this config.

Problem without tick.count:- enter image description here

Problem solved with tick.count config:- enter image description here

like image 69
Chetan Avatar answered Sep 24 '22 02:09

Chetan