Incubator-echarts: markArea可以给不同的区间分配不同的颜色吗?

Created on 1 Jul 2016  ·  2Comments  ·  Source: apache/incubator-echarts

问题简述 (One-line summary)

最新发布的3.2版本,增加了markArea,用来标记不同区域,给出的例子是“用电量分布”,
效果如下:
qq 20160701114332

我试图给“早高峰”和“晚高峰”不同的颜色,尝试几次均未成功。

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version): 3.2
  • 浏览器类型和版本 (Browser version):chrome 51.0.2704.106 m
  • 操作系统类型和版本 (OS Version):win7 64

    重现步骤 (Steps to reproduce)

1.打开用电量分布
2.在markArea增加了itemStyle代码
itemStyle:{ normal:{ color:['rgba(193, 210, 240, 0.3)','rgba(193, 210, 240, 1)'] } }
尽管color是个颜色数组,但早高峰和晚高峰显示都是color数组中的第一个颜色。

期望结果 (Expected behaviour)

早高峰和晚高峰显示不同的颜色。

ECharts配置项 (ECharts option)

option = {
    title: {
        text: '一天用电量分布',
        subtext: '纯属虚构'
    },
    tooltip: {
        trigger: 'axis'
    },
    toolbox: {
        show: true,
        feature: {
            saveAsImage: {}
        }
    },
    xAxis:  {
        type: 'category',
        boundaryGap: false,
        data: ['00:00', '01:15', '02:30', '03:45', '05:00', '06:15', '07:30', '08:45', '10:00', '11:15', '12:30', '13:45', '15:00', '16:15', '17:30', '18:45', '20:00', '21:15', '22:30', '23:45']
    },
    yAxis: {
        type: 'value',
        axisLabel: {
            formatter: '{value} W'
        }
    },
    visualMap: {
        show: false,
        dimension: 0,
        pieces: [{
            lte: 6,
            color: 'green'
        }, {
            gt: 6,
            lte: 8,
            color: 'red'
        }, {
            gt: 8,
            lte: 14,
            color: 'green'
        }, {
            gt: 14,
            lte: 17,
            color: 'red'
        }, {
            gt: 17,
            color: 'green'
        }]
    },
    series: [
        {
            name:'用电量',
            type:'line',
            smooth: true,
            data: [300, 280, 250, 260, 270, 300, 550, 500, 400, 390, 380, 390, 400, 500, 600, 750, 800, 700, 600, 400],
            markArea: {
                data: [
                [{
                    name: '早高峰',
                    xAxis: '07:30'
                }, {
                    xAxis: '11:15'
                }],

                [{
                    name: '晚高峰',
                    xAxis: '17:30'
                }, {
                    xAxis: '21:15'
                }] 

                ],

                itemStyle:{
                    normal:{
                        color:['rgba(193, 210, 240, 0.3)','rgba(193, 210, 240, 1)']
                    }
                }
            }
        }
    ]
};


其他信息 (Other comments)

Most helpful comment

每个数据项都可以配置 itemStyle.normal.color

data: [
                [{
                    name: '早高峰',
                    xAxis: '07:30',
                    itemStyle: { normal: { color: 'blue' } }
                }, {
                    xAxis: '11:15'
                }]
 ]

All 2 comments

每个数据项都可以配置 itemStyle.normal.color

data: [
                [{
                    name: '早高峰',
                    xAxis: '07:30',
                    itemStyle: { normal: { color: 'blue' } }
                }, {
                    xAxis: '11:15'
                }]
 ]

应该是这样写

```data: [
[{
name: '早高峰',
xAxis: '07:30',
itemStyle: { color: 'blue' }
}, {
xAxis: '11:15'
}]
]

Was this page helpful?
0 / 5 - 0 ratings