Javascript 理解百度的“treemap.data.label.formatter”;埃切特酒店

Javascript 理解百度的“treemap.data.label.formatter”;埃切特酒店,javascript,charts,echarts,Javascript,Charts,Echarts,在ECharts for的文档中,其解释如下: {@xxx}: the value of a dimension named'xxx', for example,{@product}refers the value of'product'` dimension。 data: [ { name: 'Region1', children: [ {

在ECharts for的文档中,其解释如下:

{@xxx}: the value of a dimension named'xxx', for example,{@product}refers the value of'product'` dimension。
    data: [
            { 
                name: 'Region1',
                children: [
                    {
                         name: 'Region1-Country1',
                         // Option 1; I can make this work by using `formatter: '{b} brand count => {@[1]}'`

                         value: [800, 8], //here, '1000' is $ spend and '8' is brand count
                         // Option 2
                         value: {'brand':8, 'value':800},

                         // Option 3
                         brand: 8,
                         label: {
                                 show: true,
                                 formatter: '{b} brand count => {@??}' // WHAT should I use after '@'?
                        },
                         children: [
                            { name: 'Region1-Country1-Brand1', value: 200 },
                            { name: 'Region1-Country1-Brand2', value: 500 },
                         ]
                    },
                    {
                         name: 'Region1-Country2', 
                         value: 500, 
                         children: [
                            { name: 'Region1-Country2-Brand1', value: 100 },
                            { name: 'Region1-Country2-Brand2', value: 200 },
                            { name: 'Region1-Country2-Brand3', value: 200 },
                         ]
                    },
                ]
            },
       ]
假设我有如下数据:

{@xxx}: the value of a dimension named'xxx', for example,{@product}refers the value of'product'` dimension。
    data: [
            { 
                name: 'Region1',
                children: [
                    {
                         name: 'Region1-Country1',
                         // Option 1; I can make this work by using `formatter: '{b} brand count => {@[1]}'`

                         value: [800, 8], //here, '1000' is $ spend and '8' is brand count
                         // Option 2
                         value: {'brand':8, 'value':800},

                         // Option 3
                         brand: 8,
                         label: {
                                 show: true,
                                 formatter: '{b} brand count => {@??}' // WHAT should I use after '@'?
                        },
                         children: [
                            { name: 'Region1-Country1-Brand1', value: 200 },
                            { name: 'Region1-Country1-Brand2', value: 500 },
                         ]
                    },
                    {
                         name: 'Region1-Country2', 
                         value: 500, 
                         children: [
                            { name: 'Region1-Country2-Brand1', value: 100 },
                            { name: 'Region1-Country2-Brand2', value: 200 },
                            { name: 'Region1-Country2-Brand3', value: 200 },
                         ]
                    },
                ]
            },
       ]

基于上述文档中的解释,我如何准备
数据
数组,以便使用
格式化程序:{b}品牌计数=>{@brand}'
并在绘制的地图中显示
Region1-Country1品牌计数=>8

我想我找到了答案。张贴在这里与社区共享

我们需要在
series
中设置
维度,而不是
series.data
。换句话说,如果我们这样做:

    series: [{
        name: 'Root',
        type: 'treemap',
        dimensions: ['value','brand'],
        visibleMin: 300,
        leafDepth: 2, 
        levels: [...] // skipped the details for `levels` here
        data: [
                { 
                    name: 'Region1',
                    brand: 9,
                    children: [
                        {
                             name: 'Region1-Country1',
                             value: [1000,8], // we can define dimensions like here: https://ecomfe.github.io/echarts-doc/public/en/option.html#dataset.dimensions
                            label: {
                            show: true,
                                formatter: '{b} brand count => {@brand}',
                            },
                             children: [
                                { name: 'Region1-Country1-Brand1', value: 200 },
                                { name: 'Region1-Country1-Brand2', value: 500 },
                             ]
                        },
                    ]
                },
              ]
            }]
那就行了(我已经测试过了)。我通过阅读ECharts文档的另一部分得出了这个答案