Chart legend: assign property values from XML data

When I create a chart I can use ‘#SuccessColor#’ to set a property value, for example the color of the bar.
But when I create the legend I can’t use this variable anymore to set the color of the marker in the legend.
Is there a way to use this variable ‘#SuccessColor#’ in a legend?

See my code example below.

Thanks in advance.

[code]var barChart = new dhtmlXChart({
view: ‘stackedBar’,
container: ‘chart_backup_reliability’,
value: ‘#Success#’,
color: ‘#SuccessColor#’,
width: 10,
xAxis: {
title: ‘month’,
template: ‘#month#’
},
yAxis: {
title: ‘Amount’,
start: 0,
end: 100,
step: 1
},
legend:{
width: 100,
align: “center”,
valign: “bottom”,
values: [{text: ‘Success’, color: ‘#SuccessColor#’}, {text: ‘Fail’, color: ‘#8C7D94’} , {text: ‘Fail (manual)’, color: ‘#424242’}, {text: ‘NotChecked’, color: ‘#6A626F’} ],
layout: ‘x’,
marker:{
type: “point”,
width: 5,
height: 15
},
}
});

barChart.load(“url”, “xml”);
[/code]

Currently it is not possible.
The color of column is defined as template which will be used for any data record.
The legend is defined once for all chart, so it can’t read data from records.

We plan to add the template based legend to the next version

Hello,

If you do not use custom values definition for a legend (values array), the legend is created automatically:

  • one legend item for each bar (data item)
  • marker has the same color as corresponding bar (uses the same template)

All you need is to define template for titles in legend. Please see the sample for a pie chart. The same approach can be used for bar:

dhtmlxChart/samples/04_pie_chart/04_legend.html ( dhtmlx.com/docs/products/dht … egend.html )