前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >echarts标题字体大小_echarts饼图显示百分比

echarts标题字体大小_echarts饼图显示百分比

作者头像
全栈程序员站长
发布2022-08-03 14:08:02
4190
发布2022-08-03 14:08:02
举报

大家好,又见面了,我是你们的朋友全栈君。

解决echarts饼图显示百分比,和显示内容字体及大小 // 基于准备好的dom,初始化echarts实例 var pieEchart = echarts.init(document.getElementById(‘pieEchart’)); // 指定图表的配置项和数据 var pieoption = { title : { text: ‘公里总里程’, x:’left’, textStyle:{ color:’#FFFFFF’, fontSize:25 } }, tooltip : { trigger: ‘item’, formatter: “{a} <br/>{b} : {c} KM” }, legend: { orient : ‘vertical’, x : ‘left’, top:40, itemWidth:70, itemHeight:30, formatter: ‘{name}’, textStyle:{ color: ‘#FFFFFF’ }, data:[{name:’高速50KM’,icon:’rect’},{name:’一级150KM’,icon:’rect’},{name:’二级150KM’,icon:’rect’},{name:’三级100KM’,icon:’rect’},{name:’四级50KM’,icon:’rect’}] } , calculable : true, series : [ { name:’公里总里程’, type:’pie’, radius : ‘70%’,//饼图的半径大小 center: [‘60%’, ‘60%’],//饼图的位置 label:{ //饼图图形上的文本标签 normal:{ show:true, position:’inner’, //标签的位置 textStyle : { fontWeight : 300 , fontSize : 16 //文字的字体大小 }, formatter:'{d}%’ } }, data:[ {value:50,name:’高速50KM’,itemStyle:{normal:{color:’#FE0000′}}}, {value:150,name:’一级150KM’,itemStyle:{normal:{color:’#F29700′}}}, {value:150,name:’二级150KM’,itemStyle:{normal:{color:’#02B0ED’}}}, {value:100,name:’三级100KM’,itemStyle:{normal:{color:’#55E87D’}}}, {value:50,name:’四级50KM’,itemStyle:{normal:{color:’#FFE200′}}}, ] } ] }; // 使用刚指定的配置项和数据显示图表。 pieEchart.setOption(pieoption);

代码语言:javascript
复制
<div id="pieEchart" style="width: 480px;height:300px;">
echarts标题字体大小_echarts饼图显示百分比
echarts标题字体大小_echarts饼图显示百分比

如何给eCharts饼图区域指定颜色

  1. option = {
  2. title : {
  3. text: “全局指标状态分布图”,
  4. x:”left”,
  5. y:”top”
  6. },
  7. tooltip : {
  8. show: true,
  9. formatter: “{a} <br/>{b} : {c} ({d}%)”
  10. },
  11. color:[“red”, “green”,”yellow”,”blueviolet”]
  12. }
echarts标题字体大小_echarts饼图显示百分比
echarts标题字体大小_echarts饼图显示百分比

刷新数据

<div class="foot_ri" id="txt"> <div class="foot_txt"> <span style="color: #6e85bf;font-size: 20px">诉求百分比占比</span> <div id="container" style="height: 100%; -webkit-tap-highlight-color: transparent; user-select: none; position: relative;"_echarts_instance_="ec_1550106173775"> <div style="position: relative; overflow: hidden; width: 1920px; height: 1037px; padding: 0px; margin: 0px; border-width: 0px; cursor: default;"> <canvas data-zr-dom-id="zr_0" width="1920" height="1037" style="position: absolute; left: 0px; top: 0px; width: 1920px; height: 1037px; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); padding: 0px; margin: 0px; border-width: 0px;"></canvas> </div> </div> </div> </div> <img src="../static/images/refresh.png" id="ig" style="margin-top: -370px;margin-left: 935px;"> </div> 点击 id=”ig” 图片,id=”container” 饼图刷新

<#–2019/2/13饼图–> <script type=”text/javascript”> var dom = document.getElementById(“container”); var myChart = echarts.init(dom); var app = {}; option = null; option = { // title: { // text: ‘诉求百分比占比’, // subtext: ”, // x: ‘center’ // }, tooltip: { trigger: ‘item’, formatter: “{a} <br/>{b} : {c} ({d}%)”/*鼠标经过显示*/ }, // color:[‘#0160ae’, ‘#36a5fc’,’#0d86e7′], color: [‘#6f87bf’, ‘#7084a2’, ‘#5e6787’], legend: { orient: ‘vertical’, // bottom: 500, left: ‘right’, data: [‘咨询’, ‘意见建议’, ‘投诉举报’], textStyle: { fontWeight: 300, fontSize: 16, //文字的字体大小 color: ‘#345cc1’//文字的字体颜色 }, }, series: [ { name: ‘访问来源’, type: ‘pie’, radius: ‘65%’, /*饼图大小*/ center: [‘40%’, ‘50%’], /*饼图位置*/ data: [ {value: 335, name: ‘咨询’}, {value: 234, name: ‘意见建议’}, {value: 135, name: ‘投诉举报’} ], itemStyle: { emphasis: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: ‘rgba(0, 0, 0, 0.5)’ } } } ] }; ; if (option && typeof option === “object”) { myChart.setOption(option, true); } </script> <#–结束–> <#–2019/2/15刷新数据–> <script> $(‘#ig’).click(function () { var dom = document.getElementById(“container”); var myChart = echarts.init(dom); myChart.setOption({ //加载数据图表 series: { // 根据名字对应到相应的系列 name: [‘数量’], data: [ {value: 222, name: ‘咨询’}, {value: 555, name: ‘意见建议’}, {value: 56, name: ‘投诉举报’} ] } }) }) </script> <#–结束–>

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/124677.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年4月2,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 如何给eCharts饼图区域指定颜色
  • 刷新数据
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档