OrbCharts Docs
Docs
Home
Github
  • English
  • 繁體中文
Docs
Home
Github
  • English
  • 繁體中文
  • Guide
  • Basic Concepts

    • 6 Data Formats
    • Core Technologies
  • Get Started !

    • Installation
    • Examples
  • Basic Usage

    • Creating Charts
    • Using Presets
    • Drawing Charts
    • Data Labels
  • Chart API

    • plugins$
    • data$
    • chartParams$
    • dataFormatter$
    • event$
    • destroy()
  • Plugins

    • Create Plugin
    • Series

      • Bubbles
      • Pie
      • PieEventTexts
      • PieLabels
      • Rose
      • RoseLabels
      • SeriesLegend
      • SeriesTooltip
    • Grid

      • Bars
      • BarsPN
      • BarsTriangle
      • Dots
      • GridLegend
      • GridTooltip
      • GroupAux
      • GroupAxis
      • GroupZoom
      • Lines
      • LineAreas
      • StackedBars
      • StackedValueAxis
      • ValueAxis
    • MultiGrid

      • MultiBars
      • MultiBarsTriangle
      • MultiDots
      • MultiGridLegend
      • MultiGridTooltip
      • MultiGroupAxis
      • MultiStackedBars
      • MultiStackedValueAxis
      • MultiValueAxis
      • OverlappingValueAxes
      • OverlappingStackedValueAxes
    • MultiValue

      • MultiValueLegend
      • MultiValueTooltip
      • OrdinalAux
      • OrdinalAxis
      • OrdinalBubbles
      • OrdinalZoom
      • RacingBars
      • RacingCounterTexts
      • RacingValueAxis
      • Scatter
      • ScatterBubbles
      • XYAux
      • XYAxes
      • XYZoom
    • Relationship

      • ForceDirected
      • ForceDirectedBubbles
      • RelationshipLegend
      • RelationshipTooltip
    • Tree

      • TreeLegend
      • TreeMap
      • TreeTooltip

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: ChartParamsPartial

  • Fields:

    NameDescriptionType
    paddingPadding between the root element and Plugin elementsPadding
    highlightTargetThe range of elements selected when a Highlight event occurs'series' | 'group' | 'category' | 'datum' | 'none'
    highlightDefaultThe default Highlight target when no event occurs (id, seriesLabel, groupLabel, or categoryLabel), which will select elements based on the range set by highlightTarget.string | null
    colorSchemeSelect color scheme, which will switch the settings under the colors field'dark' | 'light'
    colorsSet colors (separately for each color scheme){
    light: ColorScheme
    dark: ColorScheme
    }
    stylesSet stylesStyles
    transitionDurationDuration of animations (milliseconds)number
    transitionEaseType of animation (d3.js d3-ease names)string
  • chartParams.padding

    NameDescriptionType
    topPadding between the chart content and the top edgenumber
    rightPadding between the chart content and the right edgenumber
    bottomPadding between the chart content and the bottom edgenumber
    leftPadding between the chart content and the left edgenumber
  • chartParams.colors.light and chartParams.colors.dark

    NameDescriptionType
    labelArray index corresponding to data labelsstring[]
    labelContrastContrast color for label, mainly used for text overlaying graphical elements:
    [0] => Color when label is dark
    [1] => Color when label is light
    string
    primaryPrimary color, usually defined for labels, text, or auxiliary linesstring
    secondarySecondary color, usually defined for axes or background auxiliary linesstring
    backgroundBackground color, usually defined for blocks of color under information text such as tooltips (to maintain consistent color scheme)string
  • chartParams.styles

    NameDescriptionType
    textSizeText size. Two formats: (1) number unit is px, e.g., 14 (2) string can define custom units, e.g., 0.875remstring | number
    unhighlightedOpacityOpacity of other graphical elements when Highlight (mouse over) occursnumber
  • Default 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 seriesLabel of the data of the triggered element and select all elements with the same seriesLabel.
  • group: In the "Grid" and "MultiGrid" data types, get the groupLabel of the data of the triggered element and select all elements with the same groupLabel.
  • category: In the "MultiValue", "Relationship", and "Tree" data types, get the categoryLabel of the data of the triggered element and select all elements with the same categoryLabel.
  • datum: In all data types, only select the triggered element when a highlight event occurs.
  • none: No highlight event.