Echarts实战案例代码(28):象形图与dataZoom组件实现大事记进度图

简介: Echarts实战案例代码(28):象形图与dataZoom组件实现大事记进度图


数据API

let xdata = ['2019-06-12', '2019-09-15', '2020-01-10', '2020-03-05', '2020-04-12', '2020-05-18', '2020-06-12', '2020-07-07'],
    data = [120, 90, 10, 80, 90, 20, 56, 150],
    infoData = ['漏刻有时发布', '数据分析系统', '磐安旅游签到', '物联网停车场', '刷脸支付大屏', '扎根版开发', '百度地图开发', '智慧城市3D开发'];


核心代码

option = {
    backgroundColor: '#060f20',
    grid: {
        top: '15%',
        right: '3%',
        left: '8%',
        bottom: '16%'
    },
    xAxis: [{
        type: 'category',
        color: '#cef7fd',
        data: xdata,
        axisPointer: {
            type: 'line'
        },
        axisTick: {
            show: false
        },
        axisLine: {
            lineStyle: {
                color: '#eaeae8'
            }
        },
        axisLabel: {
            margin: 20,
            color: '#cef6fe',
            textStyle: {
                color: "#cbf7ff",
                fontSize: 14,
                fontWeight: 200
            }
        },
    }],
    yAxis: [{
        type: 'value',
        color: '#cef7fd',
        axisLine: {
            lineStyle: {
                color: '#eaeae8'
            },
        },
        axisTick: {
            show: false
        },
        axisLabel: {//Y轴标签定性化
            formatter: function(value) {
                var texts = [];
                if (value == 30) {
                    texts.push('超低');
                } else if (value == 60) {
                    texts.push('低');
                } else if (value == 90) {
                    texts.push('中');
                } else if (value == 120) {
                    texts.push('高');
                } else if (value == 150) {
                    texts.push('超高');
                }
                return texts;
            },
            textStyle: {
                color: "#cbf7ff",
                fontSize: 14,
                fontWeight: 200
            }
        },
        splitLine: {
            lineStyle: {
                color: '#272456'
            }
        }
    }],
    dataZoom: [{
        show: true,
        height: 20,
        xAxisIndex: [0],
        bottom: 50,
        "start": 20,
        "end": 150,
        handleSize: '120%',
        handleStyle: {
            color: "#00b4ff",
        },
        textStyle: {
            color: "#cef6fe",
        },
        fillerColor: "rgba(40,82,106,0.8)",
        borderColor: "rgba(49,65,80,0.5)",
    }, {
        type: "inside",
        show: true,
        height: 15,
        width: 20,
        start: 1,
        end: 35
    }],
    series: [{
        type: 'pictorialBar',
        data: data,
        barWidth: 8,
        symbol: 'path://d="M150 130 L130 50 L170 50 Z"',
        itemStyle: {
            normal: {
                color: { //图形颜色
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0,
                        color: '#4fa5e2' // 0% 处的颜色
                    }, {
                        offset: 1,
                        color: '#c2bc1c' // 100% 处的颜色
                    }],
                    global: false // 缺省为 false
                },
                barBorderRadius: [30, 30, 0, 0],
                shadowColor: 'rgba(0,255,225,1)',
                shadowBlur: 4,
            }
        },
        label: {
            normal: {
                show: true,
                lineHeight: 20,
                width: 100,
                height: 40,
                padding: 5,
                backgroundColor: '#fff',
                borderRadius: 5,
                position: 'top',
                align: 'center',
                formatter: function(params) {
                    console.log(params);
                    return params.name + "\n" + infoData[params.dataIndex];
                },
                rich: {
                    b: {
                        color: '#999',
                        lineHeight: 22,
                        align: 'center'
                    },
                }
            },
        }
    }]
}


LOCKDATAV DONE!

相关文章
|
3月前
|
前端开发 JavaScript BI
Django教程第5章 | Web开发实战-数据统计图表(echarts、highchart)
使用echarts和highcharts图表库实现折线图、柱状图、饼图和数据集图
64 2
|
5天前
|
JavaScript
echarts_自定义graph关系图
echarts_自定义graph关系图
14 0
|
4天前
|
前端开发 JavaScript 定位技术
Docusaurus框架——react+antd+echarts自定义mdx生成图表代码解释文档
Docusaurus框架——react+antd+echarts自定义mdx生成图表代码解释文档
21 0
|
2月前
|
前端开发 JavaScript Apache
web前端-Echarts-5.3安装配置和案例
web前端-Echarts-5.3安装配置和案例
|
4月前
|
数据可视化
Echarts5.3.2可视化案例-时间轴动态柱形图
Echarts5.3.2可视化案例-时间轴动态柱形图
|
5月前
eCharts实现漏斗图
eCharts实现漏斗图
69 0
eCharts实现漏斗图
|
5月前
|
JSON 数据格式
echarts关系图
echarts关系图
39 0
|
6月前
Echarts饼图之-玫瑰图数据交互
Echarts饼图之-玫瑰图数据交互
37 0
|
6月前
|
JSON 数据格式
Echarts的饼状图变成环形图
Echarts的饼状图变成环形图
23 0
|
3月前
|
数据可视化
echarts图表坐标轴数据标签添加下划线
echarts图表坐标轴数据标签添加下划线
55 0