Pregunta

I generate a stacked bar graph with Highcharts, and I have a problem with my interval between labels.

My data interval is only 6 and the labels interval generated by highchart is 100, see demo here : http://jsfiddle.net/NjaEw/2/

I want a label interval corresponding from data.

Here the code :

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<h1>Testing</h1>
<div id="conformity-by-page" style="width: 100%; height:250px; margin: 0 auto"></div>

        $(document).ready(function() {
            chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'conformity-by-page',
                    type: 'bar',
                    borderWidth: 1,
                    borderColor: '#000',
                    borderRadius: 0,
                    marginTop: 50
                },
                exporting: {
                    enabled: false
                },
                title: {
                    text: ''
                },
                xAxis: {
                    lineWidth:5,      
                    categories: ['Web site'],
                    //tickWidth: 0,
                    title: {
                        text: null
                    },
                    labels: {
                        style: {
                            color: '#000000',
                            fontWeight: 'bold',
                            fontSize: '14px'
                        }
                    }
                },
                yAxis: {
                    lineWidth:0,
                    title: {
                        text: 'Number of page',
                        align: 'high',
                        style: {
                            color: '#000000',
                            fontSize: '16px'
                        }
                    },
                    labels: {
                        overflow: 'justify',
                        style: {
                            color: '#000000',
                            fontWeight: 'bold',
                            fontSize: '14px'
                        }
                    }

                },
                tooltip: {
                    formatter: function() {
                        return ''+
                            this.series.name +': '+ this.y +' règles';
                    },
                    backgroundColor: '#FFFFFF',
                    style: {
                        color: '#000',
                        fontSize: '14px',
                        padding: '5px'
                    }
                },
                plotOptions: {
                    bar: {
                        borderColor: '#000000',
                        borderWidth: 1,
                        /*minPointLength: 10,*/
                        pointWidth: 25,
                        stacking: 'percent',
                        dataLabels: {
                            enabled: true
                        }
                    }
                },
                legend: {
                    verticalAlign: 'top',
                    backgroundColor: '#FFFFFF',
                    reversed: true,
                    shadow: true,
                    symbolWidth: 50,
                    itemStyle: {
                        color: '#000000',
                        fontSize: '15px'
                    }
                },
                credits: {
                    enabled: false
                },      series: [{
                    name: 'Warning',data: [null], color: '#FFFF40',
                    dataLabels: {
                        style: {
                            fontSize: '15px',
                            color: '#000000'
                        }
                    }
                }, {
                    name: 'Error',data: [3], color: '#FF8080',
                    dataLabels: {
                        style: {
                            fontSize: '15px',
                            color: '#000000'
                        }
                    }
                }, {
                    name: 'N/A',data: [1], color: '#B5EBFB',
                    dataLabels: {
                        style: {
                            fontSize: '15px',
                            color: '#000000'
                        }
                    }
                }, {
                    name: 'OK',data: [2], color: '#80FF80',
                    dataLabels: {
                        style: {
                            fontSize: '15px',
                            color: '#000000'
                        }
                    }
                }]
            });
       });
¿Fue útil?

Solución

The problem is that you're using stacking: 'percent'.
Change it to 'normal'.

Demo

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top