Missing Label formatter control of the single variables format
See original GitHub issueWhat problem does this feature solve?
The current interface to control labels within the charts is giving the user the possibility to define what content to display and in which order to print, however it is missing the possibility (or it’s not that clear) to set a specific format for the variables.
So imagine the chart displays a series of labels (e.g. AVG, MIN, MAX) see the screenshot:
the markPoint set up has a custom formatter which is:
markPoint: {
label: {
formatter: '{b}\n{c}',
}
However I would like to be able to control the value {c}
in order to display consistent decimal places (e.g. 0.00)
Ref. from documentation.
String template
Model variation includes:
{a}: series name.
{b}: the name of a data item.
{c}: the value of a data item.
{@xxx}: the value of a dimension named'xxx', for example,{@product}refers the value of'product'` dimension.
{@[n]}: the value of a dimension at the index ofn, for example,{@[3]}` refers the value at dimensions[3].
What does the proposed API look like?
I would imagine something within the brackets to control the single value. e.g. {c:0.0}
where 0.0 could be a series of supported format code, perhaps using the Excel format code convention (https://support.microsoft.com/en-gb/office/number-format-codes-5026bbd6-04bc-48cd-bf33-80f18b4eae68?ui=en-us&rs=en-gb&ad=gb) so the developer is able to control numbers and dates
e.g. {c:0.00}
where 0.00 is the number format (a number with 2 decimal places).
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
@Ovilia I found a third different the argument type in the main tooltip attribute, just to let you know (https://echarts.apache.org/en/option.html#series-line.tooltip)
In this case the formatter comes out as an array with an object and you cant use
\n
but you can plug html tags in it.We are considering providing pipes like
formatter: "{b}\n{c | fixed(2)}"
and provide some utility functions. But we haven’t reached solid conclusions.