RangeSelectorTestCase.prototype.testSelectedCombinedSeries = function() {
var opts = {
showRangeSelector: true,
- rangeSelectorCombinedSeries: [1, 3], // first and third series averaged, second skipped
- labels: ['X', 'Y1', 'Y2', 'Y3', 'Y4']
+ labels: ['X', 'Y1', 'Y2', 'Y3', 'Y4'],
+ series: {
+ 'Y1': { showInRangeSelector: true },
+ 'Y3': { showInRangeSelector: true }
+ }
};
var data = [
[0, 5, 8, 13, 21], // average (first and third) = 9
"type": "string",
"description": "The range selector mini plot fill color. This can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"yellow\". You can also specify null or \"\" to turn off fill."
},
- "rangeSelectorCombinedSeries": {
+ "showInRangeSelector": {
"default": "null",
"labels": ["Interactive Elements"],
- "type": "array<integer>",
- "description": "Array of series indexes (1 being the first serie) to combine for drawing the mini plot. The mini plot curve will be an average of these series. If \"null\", all series are combined."
+ "type": "boolean",
+ "description": "Mark this series for inclusion in the range selector. The mini plot curve will be an average of all such series. If this is not specified for any series, the default behavior is to average all the series. Setting it for one series will result in that series being charted alone in the range selector."
},
"animatedZooms": {
"default": "false",
// Private methods
//------------------------------------------------------------------
-rangeSelector.prototype.getOption_ = function(name) {
- return this.dygraph_.getOption(name);
+rangeSelector.prototype.getOption_ = function(name, opt_series) {
+ return this.dygraph_.getOption(name, opt_series);
};
rangeSelector.prototype.setDefaultOption_ = function(name, value) {
rangeSelector.prototype.computeCombinedSeriesAndLimits_ = function() {
var g = this.dygraph_;
var logscale = this.getOption_('logscale');
-
- // Create a combined series (average of selected series values).
var i;
- // Select series to combine
- var selectedSeries = this.getOption_('rangeSelectorCombinedSeries');
-
- // Default: select all series
- if (selectedSeries === null) {
- var numColumns = g.numColumns();
- selectedSeries = new Array(numColumns - 1);
-
- for (i = 1; i < numColumns; i++) {
- selectedSeries[i - 1] = i;
- }
+ // Select series to combine. By default, all series are combined.
+ var numColumns = g.numColumns();
+ var labels = g.getLabels();
+ var includeSeries = new Array(numColumns);
+ var anySet = false;
+ for (i = 1; i < numColumns; i++) {
+ var include = this.getOption_('showInRangeSelector', labels[i]);
+ includeSeries[i] = include;
+ if (include !== null) anySet = true; // it's set explicitly for this series
+ }
+ if (!anySet) {
+ for (i = 0; i < includeSeries.length; i++) includeSeries[i] = true;
}
+ // Create a combined series (average of selected series values).
// TODO(danvk): short-circuit if there's only one series.
var rolledSeries = [];
var dataHandler = g.dataHandler_;
var options = g.attributes_;
- for (i = 0; i < selectedSeries.length; i++) {
- var seriesIndex = selectedSeries[i];
- var series = dataHandler.extractSeries(g.rawData_, seriesIndex, options);
+ for (i = 1; i < g.numColumns(); i++) {
+ if (!includeSeries[i]) continue;
+ var series = dataHandler.extractSeries(g.rawData_, i, options);
if (g.rollPeriod() > 1) {
series = dataHandler.rollingAverage(series, g.rollPeriod(), options);
}
</p>
<div id="roll14" style="width:800px; height:320px;"></div>
<p>
- Use the average of a specific subset of series to draw the mini plot (only the first serie is used in this test).
+ Use the average of a specific subset of series to draw the mini plot (only the first series is used in this test).
The default behaviour is to compute the average of <em>all</em> series.
</p>
<div id="selectcombined" style="width:800px; height:320px;"></div>
title: 'Daily Temperatures in New York vs. San Francisco',
ylabel: 'Temperature (F)',
showRangeSelector: true,
- rangeSelectorCombinedSeries: [1]
+ labels: ['X', 'Y1', 'Y2', 'Y3'],
+ series: {
+ 'Y1': { showInRangeSelector: true }
+ }
}
);
g4 = new Dygraph(