主题用于配置信息图的全局样式与风格。如需概念回顾,请先阅读核心概念-主题。
配置主题
对于简单的主题配置,可以直接在创建信息图时传入配置项:
JS
const infographic = new Infographic({ // 其他配置项... }); infographic.render(` theme colorPrimary #FF356A colorBg #FFFFFF # 其他主题配置项... `);
完整配置项参考核心概念-主题。
注册主题
对于一些比较通用的主题,可以注册之后便于复用,通过 registerTheme 来注册主题:
JS
import {registerTheme} from '@antv/infographic'; registerTheme('my-theme', { // 主题配置项 });
注册后即可在语法中通过 theme my-theme 引用,配合 theme 进一步调整:
SYNTAX
infographic list-row-simple-horizontal-arrow theme my-theme colorPrimary #FF356A # 其他覆盖配置项...