javascript - 在 Angular Gauge Highchart 中显示类别并删除数字

标签 javascript highcharts google-visualization gauge

我想在 Highchart 中的 Angular Gauge 仪表中实现类别并删除数字,如 here 所示。到目前为止我所做的是this .

$(function () {

$('#container').highcharts({

    chart: {
        type: 'gauge',
        plotBackgroundColor: null,
        plotBackgroundImage: null,
        plotBorderWidth: 0,
        plotShadow: false
    },

    title: {
        text: null
    },

    pane: {
        startAngle: -150,
        endAngle: 150,
        background: [{
            backgroundColor: {
                linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
                stops: [
                    [0, '#FFF'],
                    [1, '#333']
                ]
            },
            borderWidth: 0,
            outerRadius: '109%'
        }, {
            backgroundColor: {
                linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
                stops: [
                    [0, '#333'],
                    [1, '#FFF']
                ]
            },
            borderWidth: 1,
            outerRadius: '107%'
        }, {
            // default background
        }, {
            backgroundColor: '#DDD',
            borderWidth: 0,
            outerRadius: '105%',
            innerRadius: '103%'
        }]
    },

    // the value axis
    yAxis: {
        min: 0,
        max: 100,
        type:'category',
        categories:['One','Two','Three','Four','Five'],
        tickPixelInterval: 30,
        tickWidth: 2,
        tickPosition: 'outside',
        tickLength: 20,
        tickColor: '#666',

        title: {
            text: null
        },
        plotBands: [{
            from: 0,
            to: 60,
            color: '#55BF3B' // green
        }, {
            from: 60,
            to: 80,
            color: '#DDDF0D' // yellow
        }, {
            from: 80,
            to: 100,
            color: '#DF5353' // red
        }]
    },

    series: [{
        name: 'Speed',
        data: [80]
    }]

});

});

我不想要图表中的任何数字,正如您在所附屏幕截图中看到的那样。 任何帮助表示赞赏。 谢谢。

最佳答案

您的 hive 值 (80),但只有 5 个类别。标准化值以获得所需的结果:http://jsfiddle.net/buaqgvq2/1

$('#container').highcharts({

    chart: {
        type: 'gauge'
    },

    pane: {
        startAngle: -150,
        endAngle: 150
    },

    // the value axis
    yAxis: {
        min: 0,
        max: 4,
        type:'category',
                    categories:['One','Two','Three','Four','Five'],
        tickPixelInterval: 30,
        tickWidth: 2,
        tickPosition: 'outside',
        tickLength: 20,
        tickColor: '#666',

        title: {
            text: null
        },
        plotBands: [{
            from: 0,
            to: 2,
            color: '#55BF3B' // green
        }, {
            from: 2,
            to: 3,
            color: '#DDDF0D' // yellow
        }, {
            from: 3,
            to: 4,
            color: '#DF5353' // red
        }]
    },

    series: [{
        name: 'Speed',
        data: [3.4]
    }]

});

关于javascript - 在 Angular Gauge Highchart 中显示类别并删除数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36083353/

相关文章:

javascript - HighCharts - 单击图例后如何重新定位标签

javascript - 从两个数组创建 Google Chart 数据表数组

javascript - Phonegap Android 写入 SD 卡

javascript - 使用 jQuery 从 JSON 字符串解析 HTML

javascript - 使用 Node.js 作为 highcharts 的数据源

javascript - Google 图表输入数据大小限制

javascript - 用谷歌图表插入空值

javascript - lodash find() 的流式注解

javascript - 在 React (ES6) 中访问 Passport 的 req.user? API 调用返回未定义的 req.user

javascript - Twitter Bootstrap 和 Highchart : horizontal scroll, 响应