DEV Community

FlyingAndFly
FlyingAndFly

Posted on

What are the methods for formatting VChart chart labels?

Description

In the VChart bar chart, the default display is the label of the corresponding value of the bar. I want to display something like 'x-axis name: y value' . What are the ways to customize the label display?

Solution

There are two recommended configuration methods:

  1. Configure the formatting function through label.formatMethod.
    1. The function parameter is (text: string | string [], data?: any) ,text is the default displayed text, and data is the related data.
    2. The return value of the function can be a string or a string array. Among them, the string array will be displayed as a newline by default.
    3. If you want to configure it as rich text, the return value is the rich text configuration object.
label: {
    formatMethod:(value, data) => `${data.name}: ${value}`
}
Enter fullscreen mode Exit fullscreen mode

Image description

  1. Configure the template string through label.formatter.
label: {
   formatter: `{name} : {value}`
}
Enter fullscreen mode Exit fullscreen mode

Image description

Related Documents

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay