How to use a parameter for a label in a Chart JSON?

0
Hello everyone,I have a Line Chart with multiple y axes and I would like to set labels (using parameters) with JSON.Is there a way to insert a parameter there with this widget? I'm asking because I've tried many syntax combinations and all are interpreted as plain strings.
asked
1 answers
0

Hi Horea,


The Custom Layout field in the Mendix Charts widget is a static JSON text area, not an expression editor.

It is evaluated at design time, not runtime, so you can't change the labels dynamically.

I don't think so it'a a syntax problem, it's an architectural limitation of the widget.


But there is a workaround that I just found in plotly documentation.


You can add a html snippet on the page which will be triigger a js snippet funtion after the rendering completion of your chart .


there you can trigger a plotly.reloyout function like this.

// update only values within nested objects
var update = {
    title: {text: 'some new title'}, // updates the title
    'xaxis.range': [0, 5],   // updates the xaxis range
    'yaxis.range[1]': 15     // updates the end of the yaxis range
};
Plotly.relayout(graphDiv, update)


For more info read this doc: https://plotly.com/javascript/plotlyjs-events/

Please try this
Maybe this works for you 😊


answered