Apache ECharts Documentation

repository·asf-site·Indexed 41 days ago

https://github.com/apache/echarts-website

Documentation for Apache ECharts and its ecosystem of extensions, including ECharts-GL for 3D plots and WebGL acceleration, echarts-graph-modularity for community detection, ecStat for statistical transforms and clustering, echarts-simple-transform for data aggregation, and the ecSimpleOptionPlayer for managing chart option transitions.

Tokens
534.6K
Snippets
1.6K
Records
2K
Agent score
47%

What's inside Apache ECharts

  1. Overview of jQuery-autoComplete

    asf-site

    jQuery-autoComplete is an extremely lightweight completion suggester plugin for jQuery. It is designed to provide suggestions as a user types in an input field.

    Key Features:

    • Lightweight: Approximately 3.4 kB of JavaScript (< 1.4 kB gzipped).
    • Flexible Data Sources: Supports various ways to provide completion data.
    • Performance Controls: Includes smart caching, input delay, and minimum character settings to optimize user experience.
    • Extensibility: Supports callbacks and custom rendering via the renderItem option.

    Compatibility:

    • Requires jQuery 1.7.0+.
    • Supported browsers: Firefox, Safari, Chrome, Opera, and Internet Explorer 7+.
  2. Configuration and limitations of Handsontable v0.10.5.1

    asf-site

    This specific vendor version of Handsontable (0.10.5.1) has been modified for use within this repository with the following characteristics:

    • Manual Feature Implementation: The trimWhitespace feature is not natively available in this version (it was introduced in Handsontable 1.12.6). It has been manually added and can be configured via the trimWhitespace option.
    • Exclusions: This build does not contain numeral.js code or jquery.mousewheel code; these are expected to be referenced externally.
    • Compatibility Note: This version is used to maintain support for older environments (like Windows XP/IE8/IE9) that were dropped in Handsontable v1.12.0.
    // Example of using the manually added feature
    const hot = new Handsontable(container, {
      // ... other options
      trimWhitespace: true
    });
  3. Use echarts-simple-transform for data transformations

    asf-site

    The echarts-simple-transform library provides non-official data transformers for Apache ECharts 5. These allow you to manipulate datasets directly within the ECharts dataset component using the transform property. To use these transforms, you must first register them using echarts.registerTransform().

    echarts.registerTransform(ecSimpleTransform.aggregate);
    // or
    echarts.registerTransform(ecSimpleTransform.id);
  4. What is tslib and how does it work?

    asf-site

    tslib is a runtime library for TypeScript that contains helper functions (such as __extends and __assign) used by the TypeScript compiler.

    By default, TypeScript may emit these helper functions into every file that needs them, leading to code duplication. When you use the --importHelpers flag, TypeScript instead emits a require or import statement to pull these helpers from the tslib module. This results in smaller bundle sizes and reduced runtime overhead.

    // Without tslib (duplicated in every file):
    var __assign = (this && this.__assign) || Object.assign || function(t) { ... };
    
    // With tslib (imported from module):
    var tslib_1 = require("tslib");
    exports.y = tslib_1.__assign({}, exports.x);
  5. Configure sector styling with itemStyle in Sunburst charts

    asf-site

    The itemStyle object is used to specify the visual style of the sectors in a sunburst chart. You can apply styles at three different levels of granularity, with the following priority (highest overrides lowest):

    1. series.data.itemStyle: Specific style for an individual sector.
    2. series.levels.itemStyle: Style for all sectors at a specific level.
    3. series.itemStyle: Global style for all sectors in the series.

    Common properties include color, borderColor, borderWidth, opacity, and borderRadius.

    {
      "series": {
        "type": "sunburst",
        "itemStyle": {
          "color": '#ccc',
          "borderColor": '#fff',
          "borderWidth": 1
        },
        "data": [
          {
            "name": "Specific Sector",
            "itemStyle": {
              "color": 'red'
            }
          }
        ]
      }
    }
  6. Set sector styles in Sunburst charts

    asf-site

    You can specify the visual style of sunburst sectors using itemStyle. Styles can be applied at three levels of granularity with the following priority (highest to lowest):

    1. series.data.itemStyle: Specific style for an individual data sector.
    2. series.levels.itemStyle: Style applied to all sectors at a specific level of the sunburst.
    3. series.itemStyle: Default style for all sectors in the series.

    Use levels.blur.itemStyle.color to define the color for sectors at a specific level. If not specified, colors are taken from the option.color palette by default.

  7. Style Treemap selection labels using `select.label.rich`

    asf-site

    The select.label.rich property allows you to define

    label: {
        // Styles defined in 'rich' can be applied to some fragments
        // of text by adding some markers to those fragment, like
        // `{styleName|text content text content}`.
        formatter: [ 
            '{a|Style "a" is applied to this snippet}'
            '{b|Style "b" is applied to this snippet}This snippet use default style{x|use style "x"}'
        ].join('\n'),
        rich: {
            a: {
                color: 'red'
            },
            x: {
                fontWeight: 'bold'
            }
        }
    }
  8. Compare Immutable collections using value equality

    asf-site

    Immutable collections should be treated as values rather than objects. To check if two collections contain the same data, use Immutable.is(val1, val2) or the .equals() method. Do not use the === operator for value equality, as === checks for object reference identity.

    var map1 = Immutable.Map({a:1, b:2, c:3});
    var map2 = map1.set('b', 2);
    assert(map1.equals(map2) === true);
    
    var map3 = map1.set('b', 50);
    assert(map1.equals(map3) === false);
  9. Use universalTransition for morphing animations between series

    asf-site

    universalTransition (available since v5.2.0) allows Boxplot series to morph between different series types. When enabled, transitions between series with the same id are automatically associated. You can also achieve one-to-many or many-to-one animations (like drill-downs) by specifying groupId and childGroupId in the data items.

    universalTransition.enabled

    • Type: boolean
    • Default: false

    universalTransition.seriesKey

    Determines how series are associated for animation. Defaults to the series id.

    • Type: string|Array
    • Example: seriesKey: ['male', 'female'] merges series with those IDs into the current one during animation.

    universalTransition.divideShape

    Determines how elements split during one-to-many/many-to-one animations.

    • Type: string
    • Options:
      • 'split': Splits the shape into multiple shapes.
      • 'clone': Creates multiple clones of the current element.

    universalTransition.delay

    Configures the animation delay for each shape in a one-to-many or many-to-one animation.

    • Type: Function ((index: number, count: number) => number)
    // Example: Enable universal transition with a random staggered delay
    {
      universalTransition: {
        enabled: true,
        delay: function (index, count) {
          return Math.random() * 1000;
        }
      }
    }
  10. Use label formatters with callback functions

    asf-site

    The data.label.formatter can be a callback function receiving a params object. This is useful for complex data mapping.

    Callback params Object

    Key fields include:

    • name: Data or category name.
    • value: The value of the data (can be number, Array, or Object).
    • encode: Encoding info for the coordinate system (e.g., params.encode.y[0] provides the dimension index for the y-axis).
    • dimensionNames: Array of dimension names (useful when using dataset).

    Accessing Data via encode and dimensionNames

    If using a dataset with dimensions, you can access specific axis values using the encode and dimensionNames properties:

    With array source:

    // Accessing y-axis value
    params.value[params.encode.y[0]]

    With object source (dimensions defined):

    // Accessing y-axis value via dimension name
    params.value[params.dimensionNames[params.encode.y[0]]]
    // Example callback formatter
    formatter: (params) => {
        return params.name + ': ' + params.value;
    }
  11. How coordinateSystem and coordinateSystemUsage work in series-parallel

    asf-site

    In series-parallel, you can control how the series is positioned relative to a coordinate system using two properties:

    1. coordinateSystem: Specifies which component the series is laid out on. The default is 'parallel'.

    2. coordinateSystemUsage: Defines the layout logic (available since v6.0.0).

      • 'data' (default): Each individual data item (series.data[i]) is laid out separately based on the coordinate system. This is the standard mode for most series like series-line or series-bar.
      • 'box': The entire series is treated as a single unit (a bounding box or anchor point) relative to the coordinate system. This is used for components like grid inside a matrix or pie series inside a geo system.

    Note: series-parallel specifically uses the 'parallel' coordinate system. If you want to use a series-parallel on a different system, it must be supported via the coordinateSystem property.

  12. Use Rich Text in labels

    asf-site

    You can define custom styles for specific fragments of text within a label using the rich property. This is achieved by adding markers to the text in the formatter string in the format {styleName|text content}.

    Supported properties within a rich style object include:

    • Text Styling: color, fontStyle ('normal', 'italic', 'oblique'), fontWeight ('normal', 'bold', etc., or numeric values), fontFamily, fontSize, lineHeight.
    • Alignment: align ('left', 'center', 'right') and verticalAlign ('top', 'middle', 'bottom'). These inherit from the parent level if not explicitly set.
    • Background: backgroundColor (string or object with image), padding (number or [top, right, bottom, left]), width, and height.
    • Border: borderColor, borderWidth, borderType ('solid', 'dashed', 'dotted', or dash array), borderDashOffset, and borderRadius.
    • Shadows: shadowColor, shadowBlur, shadowOffsetX, shadowOffsetY (for the text block) and textShadowColor, textShadowBlur, textShadowOffsetX, textShadowOffsetY (for the text itself).
    • Text Stroke: textBorderColor, textBorderWidth, textBorderType, and textBorderDashOffset.
    label: {
        // Styles defined in 'rich' can be applied to some fragments by adding markers
        formatter: [
            '{a|Style "a" is applied to this snippet}'
            '{b|Style "b" is applied to this snippet}This snippet use default style{x|use style "x"}'
        ].join('\n'),
    
        rich: {
            a: {
                color: 'red',
                lineHeight: 10
            },
            b: {
                backgroundColor: {
                    image: 'xxx/xxx.jpg'
                },
                height: 40
            },
            x: {
                fontSize: 18,
                fontFamily: 'Microsoft YaHei',
                borderColor: '#449933',
                borderRadius: 4
            }
        }
    }