首页 > 解决方案 > Highcharts:仅渲染百分比条使用类型:'xrange'

问题描述

想要在没有 Toolchip、标题、xAxis 等的情况下渲染百分比条。

应该使用 x 范围吗?

百分比条

https://www.highcharts.com/docs/chart-and-series-types/x-range-series

标签: javascripthighcharts

解决方案


是的,您应该使用x-range系列类型。我准备了一个简单的例子:

Highcharts.chart('container', {
    chart: {
        type: 'xrange',
        width: 200,
        height: 50,
        spacing: [0, 0, 0, 0]
    },
    credits: {
        enabled: false
    },
    title: {
        text: ''
    },
    xAxis: {
        type: 'datetime',
        visible: false
    },
    yAxis: {
        visible: false,
        title: {
            text: ''
        },
        type: 'category'
    },
    legend: {
        enabled: false
    },
    tooltip: {
        enabled: false
    },
    series: [{
        name: 'Project 1',
        pointPadding: 0,
        groupPadding: 0,
        borderColor: 'gray',
        data: [{
            x: Date.UTC(2014, 10, 21),
            x2: Date.UTC(2014, 11, 2),
            y: 0,
            partialFill: 0.25
        }],
        dataLabels: {
            enabled: true
        }
    }]
});

现场演示:https ://jsfiddle.net/BlackLabel/Lkyhfs4x/


推荐阅读