updateLegendHighlightMode();
The updateLegendHighlightMode method updates selection mode in the legend on toggling chart editing.
To execute the example, the HTML page must contain the Chart component named chart (see Example of Creating a Histogram). Get color of the brush for legend items highlighting:
// Get chart legend
var legend = chart.getLegend();
// Get brush to highlight legend items
var brush = legend.getHighlightBrush();
// Check if the brush for legend items highlighting is set
if (brush === null) {
console.log("Brush for legend items highlighting is not set");
// Create edit mode
editMode = new PP.Ui.ChartEditMode({
Parent: chart,
// Set edit mode
Mode: "Point"
});
// Set edit mode object for the chart
chart.getEditMode().setSettings(editMode.getSettings());
// Get edit mode
var chartEditMode = chart.getEditMode();
// Activate the edit mode
chartEditMode.setEnabled(true);
// Refresh selection mode in the legend on enabling the editing
chart.updateLegendHighlightMode();
// In the browser console show message on updating selection mode in the legend
console.log("Update selection mode in the legend when enabling edit mode");
// Get brush for items highlighting
brush = legend.getHighlightBrush();
// Show color of the brush for items highlighting in the browser console
var color = brush.getColor();
console.log("Color of the brush for legend items highlighting: " + color);
}
After executing the example legend selection mode is updated on enabling the edit mode. The browser console shows color value of the brush used for legend items highlighting, set after updating selection mode in the legend:
Brush for legend items highlighting is not set
Update selection mode in the legend when enabling edit mode
Color of the brush for legend items highlighting: #0000FF
See also: