2016-11-08 93 views
1

添加百分號的最佳方式是什麼?ECharts顯示百分號的所有值

這可以通過使用是可行的:

tooltip : { 
    trigger: 'item', 
    formatter: "{a} <br/>{b} : {c} ({d}%)" 
} 

但是,這是當有多個類別和值,或當數變化很煩人。

回答

1

tooltip.formatter也可以是一個功能。 使用這個,你可以完全控制什麼以及是否應該顯示。

例子:

function __handleTooltip(seriesConfiguration) { 
    // Your code here  
    // return undefined, if you don't want to show a tooltip 
    // return a string, if you want to show a tooltip 
} 

seriesConfiguration頗像是:

// This is a SCATTER-Entry 
// But line/bar is just similar, it just has different "data" and "value". 
{ 
    "componentType": "series", 
    "componentSubType": "scatter", 
    "seriesType": "scatter", 
    "seriesIndex": 0, 
    "seriesName": "Daten", 
    "name": "", 
    "dataIndex": 9, 
    "data": [ 
    748, 
    2206, 
    2954, 
    "999999999", 
    "Some other Value", 
    "" 
    ], 
    "value": [ 
    748, 
    2206, 
    2954, 
    "999999999", 
    "Some other Value", 
    "" 
    ], 
    "color": "rgba(79,142,206,1)", 
    "$vars": [ 
    "seriesName", 
    "name", 
    "value" 
    ] 
} 

只需使用的console.log打印的對象,剩下的應該直截了當。