Toggle navigation
内含生成文字过长而缩略的图片的方法
By
啊很古
2019-04-25 09:08:02
脚本
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
图表已生成
整理代码
刷新
代码
option = { title: { text: 'Awesome Chart' }, xAxis: { data: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] }, yAxis: {}, series: [{ type: 'line', data:[220, 182, 191, 234, 290, 330, 310] }] }; function buildEllipsisTextRect(text, style, isGetSeries) { let option = { series : [], backgroundColor:'transparent', }; let seriesItem = { name:'矩形图', type:'treemap', roam: false, backgroundColor: 'transparent', width: '100%', height: '100%', bottom: '0%', label:{ formatter: text, color: style.color || '#8E9CB9', backgroundColor:'transparent', lineHeight: style.lineHeight || 19, fontSize: style.fontSize || 14, margin: [0,0,0,0], padding:[0,0,0,0], verticalAlign: 'middle' }, itemStyle: { normal: { show: false, borderWidth: 0, borderColor: '#00000000', }, emphasis: { label: { show: true } } }, data:[ // { // color:'transparent', // name: text, // value: 6 // }, ], breadcrumb:{ show: false } }; option.series.push( seriesItem ); let newDiv = document.createElement("div"); newDiv.style.height = `${style.lineHeight || 19}px`; newDiv.style.width = `${style.maxWidth || 80}px`; let ellipsisTextChart = echarts.init( newDiv ); ellipsisTextChart.setOption(option); // let dataUrl1 = ellipsisTextChart.getDataURL( { // type: 'png', // pixelRatio: 1, //2可以避免图片文字像素模糊 //缩放二倍图原理, 否则backgroundSize行宽一致 // backgroundColor: 'transparent', // }); // // if( text == '水表' ){ // $('#logo').attr('src', dataUrl1); // } // return ellipsisTextChart.getDom(); let dataUrl = ellipsisTextChart.getRenderedCanvas( { //返回 HTMLCanvasElement pixelRatio: 1, backgroundColor: 'transparent', }); if( isGetSeries ){ return seriesItem; } return dataUrl // 导出的格式,可选 png, jpeg // type: 'png', // 导出的图片分辨率比例,默认为 1。 // pixelRatio?: number, // 导出的图片背景色,默认使用 option 里的 backgroundColor // backgroundColor: 'transparent', // 忽略组件的列表,例如要忽略 toolbox 就是 ['toolbox'] // excludeComponents?: Array.
}