VSeed, an elegant data composer, transforming complexity into simplicity.
!!!###!!!title=Getting Started——VisActor/VRender tutorial documents!!!###!!!!!!###!!!description=In this tutorial, we will show you how to use VRender to draw a circle. VRender is a simple-to-use, cross-platform, high-performance front-end visualization rendering library.!!!###!!!
Quick Start
In this tutorial, we will show you how to use VRender to draw a circle. VRender is a simple-to-use, cross-platform, high-performance front-end visualization rendering library.
Get VRender
You can obtain VRender in several ways.
Using NPM Package
First, you need to install VRender in the project root directory using the following command:
# Install with npmnpm install @visactor/vrender
# Install with yarnyarn add @visactor/vrender
Using CDN
You can also get the built VRender file through the CDN. Add the following code to the <head> tag of the HTML file:
Before we draw, we can prepare a DOM container with width and height for VRender.
<body><!-- Prepare a DOM with size (width and height) for vchart, or you can specify it in the spec configuration --><divid="main"style="width: 600px;height:400px;"></div></body>
Next, let's create a Stage instance based on this Canvas, create a circle and add it to the Stage:
// Create a stageconst stage = createStage({
canvas: 'main',
autoRender: true// Enable automaticrendering});
// Create a circle elementconst circle = createCircle({
radius: 60,
x: 200,
y: 200,
fill: 'red',
});
// Add it to the stagestage.defaultLayer.add(circle);
At this point, you have successfully drawn a red circle!
// Create a stageconst stage = createStage({
canvas: 'main',
autoRender: true// Enable automatic rendering});
// Create a circle elementconst circle = createCircle({
radius: 60,
x: 200,
y: 200,
fill: 'red',
});
// Listen to click events, then change fill color to greencircle.addEventListener('click', () => {
circle.setAttribute('fill', 'green');
});
// Add it to the stagestage.defaultLayer.add(circle);
We hope this tutorial helps you learn how to use VChart. Now you can try drawing different types of charts and customize more diverse chart effects by understanding in depth the various configuration options of VChart. Embark on your VChart journey bravely!