VSeed, an elegant data composer, transforming complexity into simplicity.
!!!###!!!title=WX Mini Program——VisActor/VChart tutorial documents!!!###!!!
WeChat Mini Program
Prerequisites must read
WeChat Mini Program limits the code package of the Mini Program to not exceed 2MB due to the consideration of the Mini Program startup speed. The vchart product of the WeChat Mini Program rendering environment we currently built already has 1.82M, so to ensure the package size, we recommend that users Manually introduce vchart to build products for use on WeChat mini programs. We will explain the usage in detail below.
We will still retain the @visactor/wx-vchart package, and we will continue to optimize the package size in the future. At the same time, we will provide online customization tools to allow users to build products on demand to better control the package size.
Manually introduce vchart build product
Starting from version 1.7.0, we have provided a simple version of the vchart build product by default for WeChat mini programs. The chart types and components it contains are as follows:
Chart types: line chart, area chart, column chart, pie chart and column-line combination chart
Component types: axis, discrete legend, tooltip, crosshair and label
If the simple version of the vchart build product we currently provide by default can meet your needs, then you can quote the script first, and we will provide online customization tools later to allow users to build products on demand.
The following is a detailed introduction to how to use it.
how to use
In addition to reading the instructions below, you can also directly move to the demo wx-example.
Used by encapsulating custom components
This step can directly copy the chart in wx-example folder, then replace chart/vchart/index.js with your vchart build product. This code is consistent with the component encapsulation code in @visactor/wx-vchart. Please see the source code for specific packaging logic.
Use custom components
Reference components
Just configure the following content in index.json, and use chart to customize the component.
This component library only encapsulates the environment. The configuration items and API are exactly the same as VChart. For the corresponding documentation, see VChart.
canvas-id is the chart id, which is consistent with the id of the dom. Please ensure that the id does not repeat.
spec is the core concept of VChart. The spec of cross-end components is consistent with the PC side. For chart configuration examples, please see VChart Chart Example. For users who are not familiar with VChart, you can refer to the Quickly Start VChart tutorial.
styles is the chart container style, which can be used to control the chart width and height.
events is an object array used to register a series of events, which is defined as follows. For details on the specific event name, event filtering configuration and callback function parameters, see VChart Event API
interfaceIEvent {
/**
*The name of the event
*/ type: string;
/**
* Event filtering configuration in event API
*/ query?: object;
handler: (event) => void;
}
bind:chartinit is a callback function called after the chart initialization is completed.
bind:chartready is a callback function that is called after the chart has finished rendering.
how to use
In addition to reading the instructions below, you can also go directly to wx-vchart-example.
Prerequisite
Before using the VChart WeChat applet component library, please make sure you have understood the relevant documentation of the WeChat open platform.