【问题标题】:Spacing between horizontal bars in HighchartsHighcharts中水平条之间的间距
【发布时间】:2018-10-12 15:22:06
【问题描述】:

在我的水平条形图的 Highcharts 配置中,当我添加自定义 pointWidth 时,我无法更改两个条形之间的距离。

请注意 maxPointWidth: 8

{
                chart: {
                    type: 'bar'
                },
                title: {
                    text: ''
                },
                xAxis: {
                    categories: ['Document', 'Image', 'Audio', 'CAD', 'Zip'],
                    title: {
                        text: 'File Type',
                        align: 'high',
                        offset: 0,
                        rotation: 0,
                        y: -10,
                        x: -15
                    },
                    lineColor: 'transparent',
                    minorTickLength: 0,
                    tickLength: 0,
                    labels: {
                        style: {

                        }
                    }
                },
                yAxis: {
                    opposite: true,
                    title: {
                        text: '# Files',
                        align: 'middle',
                        style: {
                            /* TODO: Modify styles to accommodate the bars header */
                            color: '#000000'
                        }
                    },
                    tickInterval: 2,
                    gridLineColor: 'transparent',
                    labels: {
                        enabled: false
                    }
                },
                tooltip: {
                    valueSuffix: ' millions'
                },
                plotOptions: {
                    bar: {
                        dataLabels: {
                            enabled: true
                        }
                    }
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'top',
                    x: -40,
                    y: 80,
                    floating: true,
                    borderWidth: 1,
                    backgroundColor: ('#FFFFFF'),
                    shadow: true,
                    enabled: false
                },
                credits: {
                    enabled: false
                },
                series: [{
                    name: '',
                    data: [56, 30, 15, 11, 5],
                    maxPointWidth: 8
                }],
                colors: this.colors || defaultColors
            }

这是工作中的 JS 小提琴: https://stackblitz.com/edit/highcharts-angular-drilldown?file=app%2Fapp.component.ts

我想减小条形和标签之间的间距并保持 maxPointWidth 不变。 enter image description here

【问题讨论】:

    标签: highcharts


    【解决方案1】:

    要缩小条形之间的间距,请缩小图表height

    chart: {
        type: 'bar',
        height: 200
    }
    

    现场演示:http://jsfiddle.net/BlackLabel/msph2uca/

    API:https://api.highcharts.com/highcharts/chart.height

    【讨论】:

    • 这回答了我的担忧