VSeed, an elegant data composer, transforming complexity into simplicity.
!!!###!!!title=VChart Plugin Feature Source Code Analysis——VisActor/VChart Contributing Documents!!!###!!!!!!###!!!description=---title: 12.2 VChart Plugin Functionality Source Code Explanation key words: VisActor,VChart,VTable,VStrory,VMind,VGrammar,VRender,Visualization,Chart,Data,Table,Graph,Gis,LLM---In the previous section (#12.1 VChart Plugin Mechanism), the basic usage of plugins in VChart was introduced. In this section, I will delve into the source code to explore the implementation logic of various plugins in depth; !!!###!!!
In the previous section (#12.1 VChart Plugin Mechanism), the basic usage of plugins in VChart was introduced. In this section, I will delve into the source code to explore the implementation logic of various plugins in depth;
Relevant Source Code Locations
packages/vchart/src/plugin/chart/formatter/ : Core implementation of the formatting plugin
packages/vchart/src/plugin/chart/media-query/ : Core implementation of the media query plugin
Formatting Plugin
Numerical Text Formatting
protected _formatSingleText(text: string | number, formatter: string): string | number {
const isNumeric = numberSpecifierReg.test(formatter);
if (isNumeric && this._numericFormatter) {
// 内置的 formatter 逻辑,可以进行缓存性能优化
let numericFormat;
if (this._numericFormatterCache && this._numericSpecifier) {
if (this._numericFormatterCache.get(formatter)) {
numericFormat = this._numericFormatterCache.get(formatter);
} else {
numericFormat = this._numericSpecifier(formatter) as any;
this._numericFormatterCache.set(formatter, numericFormat);
}
return numericFormat(Number(text));
}
return this._numericFormatter(formatter, Number(text));
} else if (formatter.includes('%') && this._timeFormatter) {
return this._timeFormatter(formatter, text);
}
return text;
}