当前位置:网站首页>小程序绘制一个简单的饼图
小程序绘制一个简单的饼图
2022-06-25 21:50:00 【@小傲哥哥】
前言:最近在做一个记账小程序的毕设,然后有一个数据分析想用饼图,弄了好久才弄好了,记录一下:
注意:要先下载 echarts.js 这个文件 在github中可以下载
JS:
// 1、引入依赖脚本
import * as echarts from '../../ec-canvas/echarts.js'
var chart = null;
// 2、进行初始化数据
function initChart(canvas, width, height) {
chart = echarts.init(canvas, null, {
width: width,
height: height
});
canvas.setChart(chart);
var option = {
title: {
left: 'center'
},
tooltip: {
trigger: 'item',
},
legend: {
bottom: 10,
left: 'center',
data: ['CityA', 'CityB', 'CityD', 'CityC', 'CityE']
},
series: [
{
type: 'pie',
radius: '65%',
center: ['50%', '50%'],
selectedMode: 'single',
data: [
{
value: 1548,name: 'CityE',},
{
value: 735, name: 'CityC' },
{
value: 510, name: 'CityD' },
{
value: 434, name: 'CityB' },
{
value: 335, name: 'CityA' }
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
chart.setOption(option);
return chart;
}
Page({
onShareAppMessage: function (res) {
return {
title: 'ECharts',
path: '/pages/index/index',
success: function () {
},
fail: function () {
}
}
},
data: {
ec1: {
onInit: initChart // 3、将数据放入到里面
},
},
})
JSON:
{
"usingComponents": {
"ec-canvas": "/ec-canvas/ec-canvas",
},
"navigationBarTitleText": "统计"
}
WXML:
<view class="box">
<ec-canvas
id="mychart-dom-bar"
canvas-id="mychart-bar"
ec="{
{ ec1 }}"
></ec-canvas>
</view>
WXSS:
.box {
width:100%;
height:600rpx;
// position: absolute;
margin-top: 30;
font-size: 42rpx;
font-weight: bold;
}
效果图:
注意,有好兄弟需要做程序毕业设计项目的可以联系我wx:fa664431710
有什么问题也可以咨询我,哈哈哈,就当交个朋友!
边栏推荐
- 2022giao考游记
- 2022-2028 global vacuum jacket system industry survey and trend analysis report
- 实战:typora里面如何快捷改变字体颜色(博客分享-完美)-2022.6.25(已解决)
- Use apiccloud AVM multi terminal component to quickly realize the search function in the app
- 2022-2028 global industrial TFT LCD industry survey and trend analysis report
- 记|一次exists关键字的学习记录
- Analysis report on scale investigation and investment development suggestions of China's special equipment inspection and testing industry 2022-2028
- How to guarantee idempotency of message queue
- c语言与数据库的创建使用
- This 110 year old "longevity" enterprise has been planning for the next century
猜你喜欢

Record the learning record of the exists keyword once

2022-2028 global industrial touch screen industry research and trend analysis report

万亿热钱砸向太空经济,真的是一门好生意?

2022-2028 global TFT touch screen industry research and trend analysis report

作为一个程序员我们如何快乐的学习成长进步呢?(个人感悟和技术无关)

Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology

简单好用的缓存库 gcache

2022 love analysis · panoramic report of it operation and maintenance manufacturers

Huasheng lithium battery IPO meeting: 9-month revenue of 690million; shenjinliang's family relationship is complex

ES6 -- 形参设置初始值、拓展运算符、迭代器、生成函数
随机推荐
Dialog+: Audio dialogue enhancement technology based on deep learning
Relinearization in homomorphic encryption (ckks)
Record the learning record of the exists keyword once
Oracle - 基本入门
What is 5g? What can 5g do? What will 5g bring in the future?
Why is BeanUtils not recommended?
c语言与数据库的创建使用
Market demand analysis and investment prospect research report of China's CNC machine tool industry 2022-2028
2022-2028 global TFT touch screen industry research and trend analysis report
哪些PHP开源作品值得关注
如何用jmeter做接口测试
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
ES6-- 集合
How to disable the optical drive
Does jQuery cache any selectors- Does jQuery do any kind of caching of “selectors”?
Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?
Unity technical manual - color in life cycle coloroverlifetime-- speed color colorbyspeed
Tiger DAO VC产品正式上线,Seektiger生态的有力补充
Unity技术手册 - GetKey和GetAxis和GetButton
Ribbon core ⼼ source code analysis