【问题标题】:How to create dynamic Y-axis inteval using Echarts如何使用 Echarts 创建动态 Y 轴间隔
【发布时间】:2020-10-07 14:04:06
【问题描述】:

是否可以使用 echarts 创建动态 Y 轴区间?我想实现下表中的Y轴间隔:

+---------------+--------------+
| Description   | Percentage   |
+---------------+--------------+
| Exceptional.. |  98% above   |
| Exceed Exp..  |  96-97.9%    |
| Normal        |  90-95.9%    |
| Needs Improv..|  80-89.9%    |
| Failed        |  79.9% below |
+---------------+--------------+

期望的输出:

示例 FIDDLE

【问题讨论】:

  • 您能详细解释一下您的问题吗?像图形表示将有助于更好地理解..
  • 我只想创建一个动态 Yaxis 就像在表格中一样。请参阅所附链接以供参考imgur.com/a/1PlU1B2
  • 你期待这样的事情吗?i.stack.imgur.com/QAe8A.png
  • 条形图必须是静态的,折线图除外。

标签: jquery echarts


【解决方案1】:

如果您尝试显示背景颜色以根据类别区分点,那么在 echarts 中使用标记区域将是一个更好的选择。

例如参考下面的图表,

图表选项

    option = {
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'cross'
        }
    },
    xAxis: {
        type: 'category',
        data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 
        'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    yAxis: {
        type: 'value',
        min: 0,
        max: 100
    },
    series: [
        {
            name: 'Result',
            type: 'line',
            lineStyle: {
                color: '#000',
            },
            smooth: true,
            data: [75, 90, 84, 100, 85, 70, 80, 90, 0, 0, 0, 95],
            markArea: {
                silent: true,
                label: {
                    color: '#000',
                    position: 'inside'
                },
                data: [ [{
                        name: 'Failed The Expectation',
                        yAxis: '0',
                        itemStyle: { color: '#c80500' }
                    }, {
                        yAxis: '80'
                    }], 
                    [{
                        name: 'Needs Improvement',
                        yAxis: '80',
                        itemStyle: { color: '#f00000' }
                    }, {
                        yAxis: '90'
                    }], 
                    [{
                        name: 'Normal/Acceptable',
                        yAxis: '90',
                        itemStyle: { color: '#0072b9' }
                    }, {
                        yAxis: '96'
                    }],
                    [{
                        name: 'Exceed Expectation/Satisfactory',
                        yAxis: '96',
                        itemStyle: { color: '#00fff5' }
                    }, {
                        yAxis: '98'
                    }],
                     [{
                        name: 'Exceptional Performance/Target',
                        yAxis: '98',
                        itemStyle: { color: '#ff29cb' }
                    }, {
                        yAxis: '100'
                    }]
                ]
            }
        }
    ]
};

【讨论】:

  • 我之前尝试添加标记区域,但我需要的输出是在每个 x 轴上添加标记区域
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多