Require on demand

F2 is designed for mobile visualization, therefore the package size is very important. F2 has modular structure provides package size optimization.

How to require on demand

  • STEP 1: Install F2

  • STEP 2: Require core library of F2(must be done)

  • STEP 3: Require modules what you want

Install F2

$ npm install @antv/f2

Import core library of F2

const Core = require('@antv/f2/lib/core');

This library contains the core processing logic of grammar of graphics, which contains the following:

  • Chart: Chart Class

  • Geom: The parent class of geometry, only contains the core processing of data, without any implementation of specific geometries such as line, area, bar i.e.

  • Attr: Attributes classes of charts, such as position, color, shape and size.

  • Scale: Only container the Linear, Cat and Identity these three basic types.

  • Coord: Only includes Cartesian coordinate.

  • Axis: Only contains the axes of Cartesian coordinate.

  • G: Rendering engine.

Require the demanded modules

The dynamically loadable modules are the following:

Geometry

Geometry module, used for drawing a specific chart:

  • require all of the geometries

  • require specific geometry

Coordinate

Axis

Adjust

  • require all types of adjust

  • require specific adjust type

Scale

Animation

The animation module serves as a plugin for chart, therefore you need to register the module on chart after it is loaded.

Guide

Guide also serves as an plugin for chart. When using Guide, users can dynamically select the specific guide component to use, and then register the corresponding plug-in to the chart.

Tooltip

Tooltip also serves as an plugin for chart.

Legend

Legend also serves as an plugin for chart.

Interaction

  • require all of the interactions

  • require the specific interaction

ScrollBar

ScrollBar also serves as an plugin for chart.

Example

If you only need to draw a pie chart without animation:

Visulization tool

For convenience, we provide UI-based require-on-demand packaging tool to help developers download the required charts and components. The usage is as follows:

In the interface that appears, check the required module, and finally package and download it.

Last updated