Chart LEGEND JSON settings not working

0
I’ve recently been tweaking my charts in Mendix  to better handle my axis ranges and padding. However the legend data I send seems to do NOTHING. I tried copying some basics from the examples in the docs, but no matter how much I change any of these values, the legend in my bar graph stays in the top right, same color, same font, same everything. No matter what options I change in here, it stays exactly the same. Does anyone know what would cause this, while other layout options such as yaxis, xaxis, seem to work just fine?   {   "legend": {     "showlegend": true,     "legend": {       "bgcolor": "#fff",       "bordercolor": "#444",       "borderwidth": 0,       "font":{         "family": "Open Sans, verdana, arial, sans-serif",         "size": 12,         "color": "black"       },       "orientation": "v",       "traceorder": "normal",       "tracegroupgap": 10,       "x": -0.1,       "xanchor": "right"     }   } }
asked
3 answers
1

Hi Brian,

Perhaps you forgot to remove the bracket?
I tried the snippet below and that works:

{
  "showlegend": true,
  "legend": {
    "bgcolor": "#fff",
    "bordercolor": "#444",
    "borderwidth": 0,
    "font": {
      "family": "Open Sans, verdana, arial, sans-serif",
      "size": 12,
      "color": "black"
    },
    "orientation": "v",
    "traceorder": "normal",
    "tracegroupgap": 10,
    "x": -0.1,
    "xanchor": "right"
  }
}

If you want to legend to be horizontal, you need to change the orientation to ‘h’ and xanchor to ‘center’. To finetune the position of the legend, use the ‘x’ and ‘y’ properties (you can use decimals here, f.i. 1.1)

If you put the widget mode to development (within the widget settings), you can test these kind of configuration using the ‘toggle editor’ that comes visible on the chart, so you don’t have to deploy every time.

 

answered
0

You have 2 legend objects in your json snippet. Try to remove the first one. To move the legend to the center top, use:

{
"orientation“:"h",
"xanchor": "center"
} 

Goodluck! 

answered
0

The folllwing JSON

 

{
    "showlegend": true,
    "legend": { "orientation“:"h", "xanchor": "center" }
}

gives me this error:

Configuration error in widget Charts.Home.columnChart3:

Invalid layout JSON: Invalid character

… Any ideas?

answered