当前位置:网站首页>The applet draws a simple pie chart
The applet draws a simple pie chart
2022-06-25 23:08:00 【@Brother Xiaoao】
Preface : Recently, I was working on the completion of a small accounting program , Then there is a data analysis that wants to use a pie chart , It took a long time to finish , Make a note of :
Be careful : Download... First echarts.js This file stay github You can download
JS:
// 1、 Introduce dependency scripts
import * as echarts from '../../ec-canvas/echarts.js'
var chart = null;
// 2、 Initialize data
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、 Put the data in it
},
},
})
JSON:
{
"usingComponents": {
"ec-canvas": "/ec-canvas/ec-canvas",
},
"navigationBarTitleText": " Statistics "
}
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;
}
design sketch :
Be careful , If you have a good brother who needs to do a program graduation design project, you can contact me wx:fa664431710
You can also consult me if you have any questions , Ha ha ha , Make a friend !
边栏推荐
- Intimacy - [comfortable exit] - final communication to reduce injury
- This 110 year old "longevity" enterprise has been planning for the next century
- 2022-2028 global carbon fiber unidirectional tape industry research and trend analysis report
- How to use the find command
- 2022-2028 global extrusion coating and lamination production line industry research and trend analysis report
- Talk about adapter mode
- Three layer architecture + routing experiment
- 提问的智慧?如何提问?
- [WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF
- 再突破!阿里云进入Gartner云AI开发者服务挑战者象限
猜你喜欢
2022-2028 global open source cloud storage industry research and trend analysis report
2022-2028 global carbon fiber unidirectional tape industry research and trend analysis report
为什么OpenCV计算的帧率是错误的?
Which PHP open source works deserve attention
记|一次exists关键字的学习记录
Wpewebkit debugging MSE playback
2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report
Use apiccloud AVM multi terminal component to quickly realize the search function in the app
The new version of Tencent's "peace elite" is coming: add a new account security protection system, and upgrade the detection of in-game violations
2022-2028 global industrial TFT LCD industry survey and trend analysis report
随机推荐
Pit resolution encountered using East OCR (compile LAMS)
Es6-- set
关闭MongoDB一些服务需要注意的地方(以及开启的相关命令)
How to design a complex business system? From the understanding of domain design, cloud native, micro service, and middle platform
小程序绘制一个简单的饼图
腾讯《和平精英》新版本将至:新增账号安全保护系统,游戏内违规行为检测升级
Analysis report on market business model and development direction of China mobile operation industry from 2022 to 2028
MySQL数据库常用函数和查询
Equivalence class, boundary value, application method and application scenario of scenario method
Fastjson反序列化随机性失败
Intimacy - [comfortable exit] - final communication to reduce injury
Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-及外力
2022-2028 global transmission type photoelectric circuit breaker industry research and trend analysis report
ES6-- 集合
Three layer architecture + routing experiment
Initialization process of gstlibav
Relinearization in homomorphic encryption (ckks)
String deformation (string case switching and realization)
Common MySQL database functions and queries
Chapter 3 use of requests Library