ChartAdvisor

2 min read
Class ChartAdvisor(config?: Partial<Pick<ChartAdvisor, 'ckbCfg' | 'ruleCfg'>> = {})
  • ChartAdvisor: is a tool class that contains both chart recommendation and chart optimization abilities.

ChartAdvisor contains both an Advisor and a Linter object, and provides advise() function, compared to Advisor, it provides an additional Lint object as output for providing chart suggestions.

Parameters

  • config * Chart Knowledge Base (CKB) & Rule Config

    • optional
    • Parameter type: CKBConfig | RuleConfig object
PropertiesTypeDescriptionDefault
ckbCfgCKBConfigCKB configuration.@antv/ckb
ruleCfgRuleConfigRule configuration.Built-in rules ruler
  • CKBConfig CKB configuration.
PropertiesTypeDescriptionDefault
excludestring[]Specify to exclude charts in @antv/ckb.None Optional
includestring[]Specify to include charts, with lower priority than exclude.None Optional
customRecord<string, CustomizedCKBJSON>Customized charts.None Optional
  • CustomizedCKBJSON @antv/ckb Customized charts, see ChartKnowledgeJSON API for details.
  • RuleConfig Chart rule configuration.
PropertiesTypeDescriptionDefault
excludestring[]Specify to exclude rules in ruler.None Optional
includestring[]Specify to include rules, with lower priority than exclude.None Optional
customRecord<string, RuleModule>Customized rules.None Optional
optionsChartRuleConfigMapRule configuration.None Optional
  • RuleModule ruler Custom rules, see Ruler for details.
type RuleModule = ChartRuleModule | DesignRuleModule;

type ChartRuleModule = DefaultRuleModule & {
  type: 'HARD' | 'SOFT';
  validator: Validator;
};

type DesignRuleModule = DefaultRuleModule & {
  type: 'DESIGN';
  optimizer: Optimizer;
};
  • ChartRuleConfigMap ruler Rule configuration, see Ruler for details.
type ChartRuleConfigMap = Record<string, ChartRuleConfig>;

interface ChartRuleConfig {
  weight?: number;
  off?: boolean;
}

Function

ChartAdvisor.advise

Get the ChartAdvisorList[] of chart recommendation results as detailed in ChartAdvisor.advise.

ChartAdvisor.advise(params: AdviseParams): ChartAdvisorList[];

Parameter:

type AdviseParams = ChartAdviseParams | GraphAdviseParams;

Return value:

type ChartAdvisorList = {
  type: ChartType;
  spec: AntVSpec;
  lint: Lint;
  score: number;
};