search
HomeWeChat AppletMini Program DevelopmentIntroduction to WeChat applet chart plug-in (wx-charts)

This article mainly introduces the example code of the WeChat applet chart plug-in (wx-charts), which has certain reference value. Interested friends can refer to it.

Charts for WeChat small app

Based on canvas drawing, small size

Support chart types

  • pie chartpie

  • Donut chart ring

  • line chart line

  • Bar chart column

  • Region chart area

  • Code analysisHere

Parameter description

opts Object

opts.canvasId String required WeChat applet canvas-id

opts.width Number required canvas width, unit is px

opts.height Number required canvas height, unit is px

opts.title Object (only for ring chart)

opts.title.name String Title content

opts.title.fontSize Number Title font size (optional, unit is px)

opts.title.color String Title color (optional)

opts.subtitle Object (only for ring chart )

opts.subtitle.name String Subtitle content

opts.subtitle.fontSize Number Subtitle font size (optional, unit is px)

opts.subtitle.color String Subtitle color (optional)

opts.animation Boolean default true Whether to display animation

opts.legend Boolean default true Whether to display the identification of each category below the chart

opts.type String required Chart type, optional values ​​are pie, line, column, area, ring

opts.categories Array required (not required for pie charts and donut charts) Data category classification

opts. dataLabel Boolean default true Whether to display the data content value in the chart

opts.dataPointShape Boolean default true Whether to display the graphic identifier of the data point in the chart

opts.xAxis Object X-axis configuration

opts.xAxis.disableGrid Boolean default false Do not draw the X-axis grid

opts.yAxis Object Y-axis configuration

opts.yAxis.format Function Customize the Y-axis copy display

opts.yAxis.min Number Y-axis starting value

opts.yAxis.max Number Y-axis ending value

opts.yAxis.title String Y-axis title

opts.yAxis.disabled Boolean default false Do not draw the Y axis

opts.series Array required Data list

Data list structure definition for each item

dataItem Object

dataItem.data Array required (Number for pie chart and donut chart) data

dataItem.color String For example, #7cb5ec If not passed in, the system default color scheme will be used

dataItem.name String Data name

dateItem.format Function Customized display data content

Example

pie chart

var wxCharts = require('wxcharts.js');
new wxCharts({
 canvasId: 'pieCanvas',
 type: 'pie',
 series: [{
  name: 'cat1',
  data: 50,
 }, {
  name: 'cat2',
  data: 30,
 }, {
  name: 'cat3',
  data: 1,
 }, {
  name: 'cat4',
  data: 1,
 }, {
  name: 'cat5',
  data: 46,
 }],
 width: 360,
 height: 300,
 dataLabel: true
});

Introduction to WeChat applet chart plug-in (wx-charts)

Introduction to WeChat applet chart plug-in (wx-charts)

##ring chart

new wxCharts({
 canvasId: 'ringCanvas',
 type: 'ring',
 series: [{
  name: '成交量1',
  data: 15,
 }, {
  name: '成交量2',
  data: 35,
 }, {
  name: '成交量3',
  data: 78,
 }, {
  name: '成交量4',
  data: 63,
 }],
 width: 320,
 height: 200,
 dataLabel: false
});

Introduction to WeChat applet chart plug-in (wx-charts)

Introduction to WeChat applet chart plug-in (wx-charts)

##line chart

new wxCharts({
 canvasId: 'lineCanvas',
 type: 'line',
 categories: ['2012', '2013', '2014', '2015', '2016', '2017'],
 series: [{
  name: '成交量1',
  data: [0.15, 0.2, 0.45, 0.37, 0.4, 0.8],
  format: function (val) {
   return val.toFixed(2) + '万';
  }
 }, {
  name: '成交量2',
  data: [0.30, 0.37, 0.65, 0.78, 0.69, 0.94],
  format: function (val) {
   return val.toFixed(2) + '万';
  }
 }],
 yAxis: {
  title: '成交金额 (万元)',
  format: function (val) {
   return val.toFixed(2);
  },
  min: 0
 },
 width: 320,
 height: 200
});

Introduction to WeChat applet chart plug-in (wx-charts)

Introduction to WeChat applet chart plug-in (wx-charts)##Introduction to WeChat applet chart plug-in (wx-charts)

new wxCharts({
 canvasId: 'columnCanvas',
 type: 'column',
 categories: ['2012', '2013', '2014', '2015', '2016', '2017'],
 series: [{
  name: '成交量1',
  data: [15, 20, 45, 37, 4, 80]
 }, {
  name: '成交量2',
  data: [70, 40, 65, 100, 34, 18]
 }],
 yAxis: {
  format: function (val) {
   return val + '万';
  }
 },
 width: 320,
 height: 200
});

Introduction to WeChat applet chart plug-in (wx-charts)

##Introduction to WeChat applet chart plug-in (wx-charts)Introduction to WeChat applet chart plug-in (wx-charts)

new wxCharts({
 canvasId: 'areaCanvas',
 type: 'area',
 categories: ['2016-08', '2016-09', '2016-10', '2016-11', '2016-12', '2017'],
 series: [{
  name: '成交量1',
  data: [70, 40, 65, 100, 34, 18],
  format: function (val) {
   return val.toFixed(2) + '万';
  }
 }, {
  name: '成交量2',
  data: [15, 20, 45, 37, 4, 80],
  format: function (val) {
   return val.toFixed(2) + '万';
  }
 }],
 yAxis: {
  format: function (val) {
   return val + '万';
  }
 },
 width: 320,
 height: 200
});

Introduction to WeChat applet chart plug-in (wx-charts)

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Introduction to WeChat applet chart plug-in (wx-charts)Related recommendations:

WeChat mini program form verification error prompt effect

Introduction to the bottom navigation of tabBar in WeChat mini program


The above is the detailed content of Introduction to WeChat applet chart plug-in (wx-charts). For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.