Toggle navigation
表格双联动+布局自适应
By
膝***纹
2020-07-23 11:56:13
脚本
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
图表已生成
整理代码
刷新
代码
const seriesBar = new Array(5).fill({ type: 'bar', stack: 'total', smooth: true, seriesLayoutBy: 'row', label: { show: true, position: 'inside' } }); let lastBarDataIndex = 0 setTimeout(function() { option = { baseOption: { legend: { show: true }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', shadowStyle: { color: 'rgba(0, 0, 0, 0.08)' } }, showContent: false }, dataset: { source: [ ['year', '2017', '2018', '2019', '2020'], ['Matcha Latte', 41.1, 30.4, 65.1, 98.7], ['Milk Tea', 86.5, 83.1, 73.4, 55.1], ['Cheese Cocoa', 24.1, 86.4, 65.2, 82.5], ['Walnut Brownie', 55.2, 72.4, 53.9, 39.1], ['Walnut sdfd', 55.2, 67.1, 86.2, 48.1], ] }, xAxis: { type: 'category' }, yAxis: { gridIndex: 0 }, series: [ ...seriesBar, { type: 'pie', id: 'pie', tooltip: { trigger: 'item', showContent: true }, label: { position: 'center', show: false }, labelLine: { show: false }, emphasis: { label: { show: true, fontSize: '23', fontWeight: 'bold', formatter: '{d}%' } }, encode: { itemName: 'year', value: '2017', tooltip: '2017' } } ] }, // 添加移动端适配配置 media: [{ option: { legend: { right: 'center', top: 0, orient: 'horizontal', itemWidth: 25, itemHeight: 14, itemGap: 10 }, grid: { top: '15%', left: '8%', bottom: '10%', right: '50%' }, series: [ ...seriesBar, { radius: ['20%', '50%'], center: ['76%', '50%'] } ] } }, { query: { // 宽度为容器宽度,并非window宽度 maxWidth: 900 }, option: { legend: { right: '12%', top: '62%', orient: 'vertical', itemWidth: 20, itemHeight: 11, itemGap: 6 }, grid: { top: '8%', left: '15%', bottom: '55%', right: '12%' }, series: [ ...seriesBar, { radius: ['25%', '45%'], center: ['35%', '72%'], emphasis: { label: { fontSize: '18' } } } ] } } ] }; myChart.on('mouseover', function({ seriesIndex, dataIndex, seriesType }) { if (seriesType === 'bar') { myChart.setOption({ series: { id: 'pie', label: { formatter: '{b}' }, encode: { value: dataIndex + 1, tooltip: dataIndex + 1 } } }); lastBarDataIndex = dataIndex //高亮显示饼图 myChart.dispatchAction({ type: 'highlight', seriesIndex: 5, // 第5个固定是饼图 dataIndex: seriesIndex }); } }); // 当鼠标离开柱状图每个堆叠项时 myChart.on('mouseout', function({ seriesType }) { if (seriesType === 'bar') { myChart.dispatchAction({ type: 'downplay', seriesIndex: 5, dataIndex: [0, 1, 2, 3, 4] //鼠标移出时取消全部高亮 }); } }); // 当鼠标在饼图时,高亮显示柱状图 myChart.on('mousemove', function({ seriesType }) { if (seriesType === 'pie') { myChart.dispatchAction({ type: 'showTip', seriesIndex: 0, dataIndex: lastBarDataIndex }); } }); myChart.setOption(option); });