当前位置:网站首页>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 !
边栏推荐
- 2022-2028 global proton exchange membrane hydrogen electrolyzer industry survey and trend analysis report
- Civil Aviation Administration: by 2025, China will initially build a safe, intelligent, efficient and green aviation logistics system
- 2022-2028 global SiC igniter industry research and trend analysis report
- 2022-2028 global web and browser isolation platform industry research and trend analysis report
- New network security competition of the secondary vocational group in 2022
- Yyds dry goods inventory JD 2, why is redis so fast?
- Travel notes of 2022giao
- 22 years of a doctor in Huawei
- Utilisation de la classe Ping d'Unity
- This 110 year old "longevity" enterprise has been planning for the next century
猜你喜欢

2022年河南省第一届职业技能大赛网络安全项目试题
Interview shock 23: talk about thread life cycle and transformation process?
![[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF](/img/a1/09d2dc0ec47c54530da4d42d218d1c.jpg)
[WPF] XAML code skills that can be directly used for converting CAD engineering drawings to WPF

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

Ribbon core ⼼ source code analysis

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

Record the learning record of the exists keyword once

记|一次exists关键字的学习记录

QT learning setting executable exe attribute (solving the problem of Chinese attribute garbled)

2022-2028 global co extrusion production line industry research and trend analysis report
随机推荐
Travel notes of 2022giao
作为一个程序员我们如何快乐的学习成长进步呢?(个人感悟和技术无关)
Oracle - getting started
Why absolute positioning overlaps
Analysis report on demand and investment forecast of global and Chinese flame retardant hydraulic oil market from 2022 to 2028
2022年中职组网络安全新赛题
实战:typora里面如何快捷改变字体颜色(博客分享-完美)-2022.6.25(已解决)
Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-及外力
Flex & Bison 开始
Analysis report on market demand situation and investment direction of China's optical transmission equipment industry from 2022 to 2028
2022-2028 global TFT LCD touch screen industry research and trend analysis report
Unity的Ping类使用
Exclusive or operator simple logic operation a^=b
小程序-视图与逻辑
Another breakthrough! Alibaba cloud enters the Gartner cloud AI developer service Challenger quadrant
等价类,边界值,场景法的使用方法和运用场景
2022爱分析· IT运维厂商全景报告
Does jQuery cache any selectors- Does jQuery do any kind of caching of “selectors”?
The Ping class of unity uses
What do l and R of earphone mean?