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.

Synchronize the Y-Axis scale's minimum and maximum values

Hide navigation
Modified on Wed, 19 Mar 2014 11:06 AM Categorized as Level-Advanced, Level-Intermediate, Script Library, Scripting
Dundas Dashboard Script LibraryPrevious


This sample shows how to synchronize the minimum and maximum Y-Axis scale values to multiple charts by script. By default, the minimum and maximum scale values are set to Automatic, which is based on the metric's minimum and maximum values. The script will loop through all the bar charts in the dashboard and get the lowest and highest metric values across all data points. These values will then be set as the Y-axis scale's minimum and maximum values respectively for all charts.

For example, the dashboard below has 4 bar charts different minimum and maximum Y-axis scale values:
Original Dashboard.

Original Dashboard.

Note: To replicate the Original Dashboard as seen above, refer to the article on how to Create a Bar Chart using a Dataset.

Add the Load Interaction script

  1. Edit the dashboard.
  2. Click on an empty space on the dashboard to open the Properties Pane.
  3. Locate the Load Interaction and click on Add.
  4. On the Script Editor, paste the script below:

double maxyvalue; double minyvalue; double curyvalue; foreach(object chart in services.CurrentDashboard.VisualObjects){ string type = chart.GetType(); if(type.Contains("BarChart")) { DashboardBarChart chart1 = chart; curyvalue = 0; foreach(var series in chart1.Series) { foreach(var point in series.Points) { curyvalue = point.YValues0; maxyvalue = Math.Max(maxyvalue, curyvalue); minyvalue = Math.Min(minyvalue, curyvalue); } } } } foreach(object chart in services.CurrentDashboard.VisualObjects) { string type = chart.GetType(); if(type.Contains("BarChart")) { chart.YAxes0.Scales0.Maximum = maxyvalue; chart.YAxes0.Scales0.Minimum = minyvalue; } }

View the resulting dashboard

Dashboard Preview after applying the script.

Dashboard Preview after applying the script.

Related Topics

Click to return to: Documentation

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

Copyright © 2009-2014 Dundas Data Visualization, Inc.