Skip to content

Wrong token parse in rich text #14889

@100pah

Description

@100pah

Version

5.1.1

Steps to reproduce

option = {
    legend: {
        formatter: '{a|{name}}',
        textStyle: {
            rich: {
                a: {
                    width: 200
                }
            }
        }
    },
    series: [
        {
            name: '访问来源',
            type: 'pie',
            data: [
                {value: 1048, name: '搜索引擎{}'},
                {value: 300, name: '视频广告'}
            ]
        }
    ]
};

What is expected?

No space in the '{}'

What is actually happening?

Screen Shot 2021-05-08 at 11 51 45 AM

And I have not found a work around yet.

Discuss

  1. Should the rich text delimiters ({a|xxx}) only available in formatter field or also enabled in data?
    I think we probably can not restrict the delimiters only available in formatter (consider formatter can be a function).
    That is, if data contains '{a|xxx}', it also should be recognized as rich text delimiters.
  2. Should we provide escaping for rich text delimiters?
    I think it should. And we should better provide a util method to escape delimiters in data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenThis issue is in English

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions