chartParams$
The API
chartParams$is a shared chart parameter setting for all Plugins, and the parameters on the chart objects of each data type are the same. It is mainly used to set common chart styles and behaviors.All parameters are optional. If this API is not used, all parameter settings will be default values.
Syntax
The syntax for creating chartParams data is chart.chartParams$.next()
Example:
chart.chartParams$.next({
// Optional chartParams parameters
padding: {
bottom: 100
}
})
Parameters
Type:
ChartParamsPartialFields:
Name Description Type padding Padding between the root element and Plugin elements PaddinghighlightTarget The range of elements selected when a Highlight event occurs 'series' | 'group' | 'category' | 'datum' | 'none'highlightDefault The default Highlight target when no event occurs ( id,seriesLabel,groupLabel, orcategoryLabel), which will select elements based on the range set byhighlightTarget.string | nullcolorScheme Select color scheme, which will switch the settings under the colorsfield'dark' | 'light'colors Set colors (separately for each color scheme) {
light:ColorScheme
dark:ColorScheme
}styles Set styles StylestransitionDuration Duration of animations (milliseconds) numbertransitionEase Type of animation (d3.js d3-easenames)stringchartParams.paddingName Description Type top Padding between the chart content and the top edge numberright Padding between the chart content and the right edge numberbottom Padding between the chart content and the bottom edge numberleft Padding between the chart content and the left edge numberchartParams.colors.lightandchartParams.colors.darkName Description Type label Array index corresponding to data labels string[]labelContrast Contrast color for label, mainly used for text overlaying graphical elements:
[0] => Color whenlabelis dark
[1] => Color whenlabelis lightstringprimary Primary color, usually defined for labels, text, or auxiliary lines stringsecondary Secondary color, usually defined for axes or background auxiliary lines stringbackground Background color, usually defined for blocks of color under information text such as tooltips (to maintain consistent color scheme) stringchartParams.stylesName Description Type textSize Text size. Two formats: (1) numberunit is px, e.g.,14(2)stringcan define custom units, e.g.,0.875remstring | numberunhighlightedOpacity Opacity of other graphical elements when Highlight (mouse over) occurs numberDefault values:
{ padding: { top: 60, right: 60, bottom: 60, left: 60 }, highlightTarget: 'datum', highlightDefault: null, colorScheme: 'light', colors: { light: { label: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'], labelContrast: ['#ffffff', '#1b1e23'], primary: '#1b1e23', secondary: '#e1e1e1', background: '#ffffff' }, dark: { label: ['#67B7DC', '#6794DC', '#6771DC', '#8067DC', '#A367DC', '#C767DC', '#DC67CE', '#DC67AB', '#DC6788', '#DC6967', '#DC8C67', '#DCAF67'], labelContrast: ['#ffffff', '#1b1e23'], primary: '#f0f0f0', secondary: '#e1e1e1', background: '#000000' } }, styles: { textSize: '0.875rem', unhighlightedOpacity: 0.3 }, transitionDuration: 800, transitionEase: 'easeCubic' }
Chart Padding Settings - chartParams.padding
padding is the padding between the root element and Plugin elements, with four fields: top, right, bottom, and left.
However, the actual effect may vary depending on the design of each Plugin. For example:
Example 1: The Pie class (pie chart) draws the chart aligned to the center of the screen, and the padding between the pie chart and the scene is set by padding. The larger the padding, the smaller the area of the pie chart.
Example 2: The Bars class (bar chart) has x and y axes, with the origin at the bottom left by default. The x-axis aligns to the bottom of the root element plus the bottom padding, and the y-axis aligns to the left of the root element plus the left padding.
Highlight Target - chartParams.highlightTarget
Set the target data for highlight events. Generally, it is triggered when the mouse passes over specific graphical elements, which can be mapped to corresponding data by id or label. The mapping methods are 'series', 'group', 'category', 'datum', and 'none', described as follows:
- series: In the "Series", "Grid", and "MultiGrid" data types, get the
seriesLabelof the data of the triggered element and select all elements with the sameseriesLabel. - group: In the "Grid" and "MultiGrid" data types, get the
groupLabelof the data of the triggered element and select all elements with the samegroupLabel. - category: In the "MultiValue", "Relationship", and "Tree" data types, get the
categoryLabelof the data of the triggered element and select all elements with the samecategoryLabel. - datum: In all data types, only select the triggered element when a highlight event occurs.
- none: No highlight event.