option property

String option
final

The ECharts chart configuration option, represented as a string.

This controls the entire chart setup:

  • When rawOption is false (default), this string must be valid JSON. Functions such as formatters are NOT allowed and should be represented as strings or static values.

    Example:

    EChartsWebView(
      option: '''
      {
        "tooltip": {
          "formatter": "{b}: {c}"
        },
        "xAxis": {
          "type": "category",
          "data": ["A", "B", "C"]
        },
        "yAxis": {},
        "series": [{
          "type": "bar",
          "data":[5]
        }]
      }
      ''',
    )
    
  • When rawOption is true, the entire string is treated as a JavaScript object literal and can include inline JS functions (e.g., formatters). Be cautious and only use trusted input as this enables code execution.

    Example:

    EChartsWebView(
      rawOption: true,
      option: '''
      {
        tooltip: {
          formatter: function(params) {
            return params.name + ': ' + params.value;
          }
        },
        xAxis: {
          type: 'category',
          data: ['A', 'B', 'C']
        },
        yAxis: {},
        series: [{
          type: 'bar',
          data:[5]
        }]
      }
      ''',
    )
    

Implementation

final String option;