Toggle navigation
aa
By
ubflchi
2019-03-22 01:21:59
脚本
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
图表已生成
整理代码
刷新
代码
// 设置每个bar的颜色 function setColor(index){ var colorList = ['#FF9983', '#038DFF', '#72DC93', '#8B87FF', '#00D3FF', '#C6CAD3']; var length = colorList.length; var Index = index; function change(){ if(Index>=length) { Index = Index-length; change(); } } change(); return colorList[Index]; } // 设置每个data的值 function setData(item, index) { var _array = []; _array[index] = item.count; for(var i=0; i
{ // echarts的series数据 chartData.push({ name: item.subjectName, type: 'bar', barGap:'-100%', z: 3, itemStyle: { normal: { color: setColor(index) } }, data: setData(item,index), label: { normal: { formatter: function(data){ return list[data.dataIndex].percentage+' '+data.value+'个'; }, position: 'left', offset: [250,0], show: true, color: '#666', } }, }); // 数据的‘数量’数组 counts.push(item.count); chartNames.push(item.subjectName); // 设置最大值 max = max + item.count; }); // 差值数组 counts.forEach(item => { differences.push(max-item); }); // 在尾巴添加一个底色 chartData.push({ type: 'bar', stack: 'chart', silent: true, itemStyle: { normal: { color: '#eee' } }, data: differences }); } option = { tooltip: {}, color: ['#FF9983', '#038DFF', '#72DC93', '#8B87FF', '#00D3FF', '#C6CAD3'], legend: { // data: yarray, formatter: '{name}', icon: 'circle', itemWidth: 8, itemHeight: 8, borderRadius: 8, textStyle: { color: '#999999', borderRadius: 8, } }, grid: [{ top: 0, width: '100%', bottom: 20, left: 0, right:0, containLabel: true }], xAxis: [{ show: false, type: 'value', max: max, splitLine: { show: false } }], yAxis: [{ type: 'category', data: chartNames, axisLabel: { margin:16, interval: 0, color: '#333333', fontFamily: "PingFang SC", fontSize: 12 }, inverse: true, axisLine:{ //y轴 show:false }, axisTick:{ show:false }, splitLine: { show: false }, }], series: this.chartData }