Graph format

Hello everyone,

Is it possible to format number precision in column graphs using integrated graphic dialog functions? I want to show the average number but with zero or 1.0 precision.

I tried to configure the precision of the data via transformation :
image

In this case I also using the JSON confing:
{
legend: {
color: {
itemLabelFontSize: 20,
layout: ‘grid’,
},
},
axis: {
x: {
labelFontSize: 20,
},
y: {
labelFontSize: 20,
},
},
scale: {
color: {
palette: ‘dark2’,
},
},
label: {
position: ‘inside’,
fontSize: 15,
},
}

But the result looks like this:

Could anyone help me with the right configuration of the graph?

Thanks,

Zdeněk

Hi,

In Data Transformation within Block Chart, you can set the precision, maybe it is an option.

https://docs.nocobase.com/handbook/data-visualization/user/configure#data-transformation

Example:

Hi, as data transformation does not currently apply to custom JSON configurations. You can try

{
  label: {
    position: 'inside',
    text: '{{ ({ fieldname }) => fieldname.toFixed(0) }}',
  },
}

Replace fieldname with your actual field name. Note: it should be the name, not the title.

1 Like

Hello,

Thanks for your feedback.

I tried your suggestion and the result was that the text were hidden.

This was the config:
{
legend: {
color: {
itemLabelFontSize: 20,
layout: ‘grid’,
},
},
axis: {
x: {
labelFontSize: 20,
},
y: {
labelFontSize: 20,
},
},
scale: {
color: {
palette: ‘dark2’,
},
},
label: {
position: ‘inside’,
text: ‘{{ ({ Evidence_date }) => Evidence_date.toFixed(0) }}’,
fontSize: 20,
},
}

This is the result:

Zdeněk

Hello,

The transformation does not help, as I describe in the topic. When the data transformation is made, the format of the column description remains the same.

e.g. data input looks like 40.1254485 beacouse it is average after transformation to precision 1 the output data after transformation looks like 40 but if I tried to insert “same data” into column description the transformation were lost and the result is still 40.1254485.

Zdeněk

Is Evidence_date your field name, or did you set an alias? Could you check the field name in the API response using the browser devtools.

1 Like

You know what? I made an mistake. I used different column name (nearly the same). Thanks for help.
Current result :slight_smile:

1 Like