416.467.9100 | Dundas Data Visualization | Login
Welcome Guest
This is the support page for the legacy Dundas Dashboard application. For assistance with the current Dundas BI application please click here.
Dashboard v5.0

This site makes extensive use of JavaScript.

Please enable JavaScript in your web browser and reload the page before proceeding.

Highlight a series when clicking a legend item

Hide navigation
RSS
Modified on Thu, 16 Jan 2014 05:01 PM Categorized as Legend, Script Library
&dw; Script LibraryPrevious

Use this script to highlight a series when the user clicks on the legend item that corresponds to that series.

  1. In your dashboard, you need to have a Chart and a Legend, with the Legend property of the Chart set to the Name of the Legend.
  2. In Dashboard Designer, select the Legend.
  3. In the properties list, click Show Advanced Properties.
  4. In the properties list, click to open the Item Click Interaction list. This will bring up the code dialog.
  5. Add a new script (like the one below) in the dialog.

Script

// Assumption: exactly one bar chart is linked to this legend. // When a legend item is clicked, exactly one item exists in the // ParentControlElements collection. if (e.ParentControlElements.Count > 0) { // Compare the series inside ParentControlElements against // each one in the bar chart. foreach (DashboardDataSeries series in e.ParentControls[0].Series) { if (e.ParentControlElements[0].Points.Count > 0) { DashboardSolidColorBrush brush = new DashboardSolidColorBrush(((DashboardSolidColorBrush)series.Points[0].Fill).Color);

// Lower the opacity for those that do not match, and set // the matching one to opaque. In order to set the colour of the // bars, we need to set the colour of the points individually. if (series == e.ParentControlElements[0]) brush.Opacity = 1; else brush.Opacity = 0.3;

foreach (DashboardDataPoint point in series.Points) point.Fill = brush;

// To update the colour of the legend item, we also need to set // the colour of the series itself. series.Fill = brush; } } }


Result

The series

The series "Sales Amount" is highlighted after a mouse click.


Related topics

About Dundas | Contact Us Follow us on Twitter! | Privacy Statement | Report Site Issues

Copyright © 2009-2014 Dundas Data Visualization, Inc.