Toggle navigation
双向柱状横向对比
By
雨***1
2019-05-21 03:01:03
脚本
16
21
作品使用的第三方脚本
数据管理
上传数据
支持小于 5M 任意格式(csv, xlsx, json, xml, ...)的数据文件
上传后可以通过生成的文件链接异步获取托管的数据。
历史数据
0 条
无历史数据
代码修改记录
信息提示
保存作品
对当前截图不满意?你还可以
上传本地截图
重新截图
作品名称
作品描述
标签
geo
grid
legend
markLine
markPoint
bar
effectScatter
line
lines
map
timeline
title
toolbox
tooltip
visualMap
作品默认版本
最新
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
20:11:45
图表已生成
整理代码
刷新
代码
let myData = [ '张三', '李四', '王二', '麻子', '小明' ] var dataFirm = { 1: [389, 259, 262, 324, 233] } var dataDevice = { 1: [2201, 3808, 2303, 3009, 3302, ] } var timeLineData = [1] var option = { baseOption: { title: { text: '学生阅读量对比', top: '2%', left: '41%' }, timeline: { show: false, top: 0, data: [] }, legend: { // 图例 top: '10%', // 图例距离顶部距离 left: 'center', // 图例距离左侧距离(此处水平居中) itemWidth: 20, itemHeight: 20, itemGap: 300, textStyle: { // 图例文本样式 color: ['#4ca8f6', '#00d484'] }, data: ['阅读书籍', '阅读字数'] // 图例的数据数组,一般对应系列名称,即 series.name }, tooltip: { show: true, trigger: 'axis', formatter: '{b}
{a}: {c}', axisPointer: { type: 'shadow' } }, grid: [{ show: false, left: '9%', top: 100, bottom: 0, containLabel: true, width: '31%' }, { show: false, left: '50%', top: 100, bottom: 0, width: '0%' }, { show: false, right: '9%', top: 100, bottom: 0, containLabel: true, width: '31%' } ], xAxis: [{ type: 'value', inverse: true, axisLine: { show: false }, axisTick: { show: false }, position: 'top', axisLabel: { show: false }, splitLine: { show: false } }, { gridIndex: 1, show: false }, { gridIndex: 2, nameTextStyle: { color: '#000', fontSize: 14 }, axisLine: { show: false }, axisTick: { show: false }, position: 'top', axisLabel: { show: false }, splitLine: { show: false } } ], yAxis: [{ type: 'category', inverse: true, position: 'right', axisLine: { show: false }, axisTick: { show: false }, axisLabel: { show: false }, data: myData }, { gridIndex: 1, type: 'category', inverse: true, position: 'left', axisLine: { show: false }, axisTick: { show: false }, axisLabel: { show: true, interval: 0, textStyle: { color: '#000', fontSize: 14 } }, data: myData.map(function(value) { return { value: value, textStyle: { align: 'center' } } }) }, { gridIndex: 2, type: 'category', inverse: true, position: 'left', axisLine: { show: false }, axisTick: { show: false }, axisLabel: { show: false }, data: myData } ], series: [] }, options: [] } option.baseOption.timeline.data.push(timeLineData[0]) option.options.push({ tooltip: { trigger: 'axis', formatter: '{b}
{a}: {c} ' }, series: [{ name: '阅读书籍', type: 'bar', barWidth: 20, barMinWidth: 5, label: { normal: { show: true, position: 'left', formatter: function(params) { return params.value + "本" }, offset: [0, 0], textStyle: { color: '#000', fontSize: 14 } } }, itemStyle: { normal: { color: '#4ca8f6', barBorderRadius: 5 } }, data: dataFirm[timeLineData[0]] }, { name: '阅读字数', type: 'bar', barWidth: 20, xAxisIndex: 2, yAxisIndex: 2, label: { normal: { show: true, position: 'right', formatter: function(params) { return params.value + "字" }, offset: [0, 0], textStyle: { color: '#000', fontSize: 14 } } }, itemStyle: { normal: { color: '#00d484', barBorderRadius: 5 } }, data: dataDevice[timeLineData[0]] } ] })