Lynx
Lynx is a high-performance cross-end framework for quickly building Native views using the Web technology stack in Bytes. VChart also provides support for the chart rendering capabilities of this framework.
How to get VChart
npm package
You can install the vchart dependency package directly in the lynx project: @visactor/vchart
.
Manually import script
You can also manually reference VChart's umd packaged product, which you can obtain through the following channels:
- Obtain [packages/block-vchart/block/vchart/index.js](https://github.com/VisActor/VChart/blob/main/packages/block-vchart/block/vchart/index. js), we will update it every time we send a package
- Get it from the following free CDN
how to use
Below we will introduce how to use VChart on Feishu widgets from three parts: js
, ttml
, and ttss
.
index.ttml
Three canvases need to be declared, and pay attention to the order of declaration.
bar_hidden_canvas
hidden canvas, declared in the first, is used for some internal picking logicbar_draw_canvas
draws canvas, the second statementbar_tooltip_canvas
is used to draw the canvas of the tooltip. The tooltip of the cross-end environment is drawn using the canvas.
index.js
Create a VChart instance in this file. Because VChart is internally compatible with the lynx environment, its use is basically the same as on the PC. You only need to pay attention to two points:
- Necessary environment parameters need to be declared in the constructor of VChart
- Regarding events, users need to bind events to the canvas (canvas used for drawing) element themselves, and then manually dispatch events in the event listening function to trigger events inside VChart.
The following is the completed code related to index.js:
On-Demand Loading
Lynx-VChart inherently supports on-demand loading. There are two ways to achieve on-demand loading with VChart:
- Use the
<VChartSimple />
tag to implement custom on-demand loading.
The <VChartSimple />
component and the <VChart />
component are almost identical in usage. The only difference is that users need to import the VChart
constructor class from @viasctor/vchart/esm/core
, register the required charts and components as described in this document, and pass them to <VChartSimple />
.
- Use semantic tags, all of which support on-demand loading by default. The default registered components for each type of semantic tag are as follows:
Supported from version 0.0.12
Chart | Category | Additional Registered Components |
---|---|---|
<LineChart/> | Cartesian Charts | registerLabel |
<AreaChart/> | Cartesian Charts | registerLabel , registerTotalLabel |
<BarChart/> | Cartesian Charts | registerLabel , registerTotalLabel |
<Bar3dChart/> | Cartesian Charts | registerLabel , registerTotalLabel |
<BoxPlotChart/> | Cartesian Charts | registerLabel , |
<HeatmapChart/> | Cartesian Charts | registerLabel |
<Histogram3dChart/> | Cartesian Charts | registerLabel |
<HistogramChart/> | Cartesian Charts | registerLabel |
<LinearProgressChart/> | Cartesian Charts | registerLabel |
<RangeColumnChart/> | Cartesian Charts | registerLabel |
<RangeColumn3dChart/> | Cartesian Charts | registerLabel |
<ScatterChart/> | Cartesian Charts | registerLabel |
<SequenceChart/> | Cartesian Charts | registerLabel |
<WaterfallChart/> | Cartesian Charts | registerLabel , registerTotalLabel |
<RadarChart/> | Polar Charts | registerLabel |
<RoseChart/> | Polar Charts | registerLabel |
<CircularProgressChart/> | Polar Charts | registerLabel , registerIndicator |
<Pie3dChart/> | General Charts | registerLabel , registerIndicator |
<PieChart/> | General Charts | registerLabel , registerIndicator |
<CirclePackingChart/> | General Charts | None |
<FunnelChart/> | General Charts | registerLabel |
<Funnel3dChart/> | General Charts | registerLabel |
<GaugeChart/> | General Charts | None |
<MapChart/> | General Charts | registerLabel |
<SankeyChart/> | General Charts | None |
<SunburstChart/> | General Charts | None |
<TreemapChart/> | General Charts | None |
<VennChart/> | General Charts | None |
<WordCloud3dChart/> | General Charts | None |
<WordCloudChart/> | General Charts | None |
<LiquidChart/> | General Charts | registerIndicator |
For Cartesian charts, the default registered components are as follows:
registerCartesianLinearAxis
registerCartesianBandAxis
registerCartesianTimeAxis
registerCartesianLogAxis
registerCartesianCrossHair
registerBrush
registerContinuousLegend
registerDataZoom
registerDiscreteLegend
registerCustomMark
registerAllMarks
registerMarkArea
registerMarkLine
registerMarkPoint
registerScrollBar
registerTitle
registerTooltip
registerCanvasTooltipHandler
For Polar charts, the default registered components are as follows:
registerPolarLinearAxis
registerPolarBandAxis
registerPolarCrossHair
registerBrush
registerContinuous Legend
registerDataZoom
registerDiscreteLegend
registerCustomMark
registerAllMarks
registerScrollBar
registerTitle
registerTooltip
registerCanvasTooltipHandler
For General charts, the default registered components are as follows:
registerDiscreteLegend
registerContinuousLegend
registerCustomMark
registerAllMarks
registerTitle
registerTooltip
registerCanvasTooltipHandler
When using semantic tags, if you need components that are not loaded by default, you only need to register the missing components.
For reference on on-demand loading of VChart, see related documentation.