diff --git a/docs/graph2d/index.html b/docs/graph2d/index.html
index 18e8ad67..94131646 100644
--- a/docs/graph2d/index.html
+++ b/docs/graph2d/index.html
@@ -741,7 +741,7 @@ onRender: function(item, group, graph2d) {
stack |
Boolean |
true |
- If stack is enabled, the graphs will be stacked upon eachother when applicable. This currently only works with bar graphs but linegraph support is being worked on. |
+ If stack is enabled, the graphs will be stacked upon each-other when applicable. A group can opt-out of stacking through the "excludeFromStacking" option. |
shaded |
@@ -794,7 +794,13 @@ onRender: function(item, group, graph2d) {
excludeFromLegend |
Boolean |
false |
- Group option only. Excludes the the group from beeing listed in the legend. |
+ Group option only. Excludes the group from being listed in the legend. |
+
+
+ excludeFromStacking |
+ Boolean |
+ false |
+ Group option only. Excludes the group from being included in the stacking. |
diff --git a/lib/timeline/Graph2d.js b/lib/timeline/Graph2d.js
index b94b9522..cae83d24 100644
--- a/lib/timeline/Graph2d.js
+++ b/lib/timeline/Graph2d.js
@@ -217,7 +217,7 @@ Graph2d.prototype.getLegend = function(groupId, width, height) {
return this.linegraph.groups[groupId].getLegend(width,height);
}
else {
- return "cannot find group:" + groupId;
+ return "cannot find group:'" + groupId + "'";
}
};
diff --git a/lib/timeline/component/GraphGroup.js b/lib/timeline/component/GraphGroup.js
index 910ccb16..b8c2b08f 100644
--- a/lib/timeline/component/GraphGroup.js
+++ b/lib/timeline/component/GraphGroup.js
@@ -73,7 +73,7 @@ GraphGroup.prototype.setZeroPosition = function (pos) {
*/
GraphGroup.prototype.setOptions = function (options) {
if (options !== undefined) {
- var fields = ['sampling', 'style', 'sort', 'yAxisOrientation', 'barChart', 'excludeFromLegend'];
+ var fields = ['sampling', 'style', 'sort', 'yAxisOrientation', 'barChart', 'excludeFromLegend', 'excludeFromStacking'];
util.selectiveDeepExtend(fields, this.options, options);
// if the group's drawPoints is a function delegate the callback to the onRender property
diff --git a/lib/timeline/component/LineGraph.js b/lib/timeline/component/LineGraph.js
index 557c76c4..3fda715f 100644
--- a/lib/timeline/component/LineGraph.js
+++ b/lib/timeline/component/LineGraph.js
@@ -89,7 +89,7 @@ function LineGraph(body, options) {
}
};
- // options is shared by this ItemSet and all its items
+ // options is shared by this lineGraph and all its items
this.options = util.extend({}, this.defaultOptions);
this.dom = {};
this.props = {};
@@ -643,10 +643,25 @@ LineGraph.prototype._updateGraph = function () {
this.abortedGraphUpdate = false;
// With the yAxis scaled correctly, use this to get the Y values of the points.
+ var below = undefined;
for (i = 0; i < groupIds.length; i++) {
group = this.groups[groupIds[i]];
- if (this.options.stack === true && this.options.style === 'line' && i > 0) {
- this._stack(groupsData[groupIds[i]], groupsData[groupIds[i - 1]]);
+ if (this.options.stack === true && this.options.style === 'line') {
+ if (group.options.excludeFromStacking == undefined || !group.options.excludeFromStacking) {
+ if (below != undefined) {
+ this._stack(groupsData[group.id], groupsData[below.id]);
+ if (group.options.shaded.enabled == true && group.options.shaded.orientation !== "group"){
+ if (group.options.shaded.orientation == "top" && below.options.shaded.orientation !== "group"){
+ below.options.shaded.orientation="group";
+ below.options.shaded.groupId=group.id;
+ } else {
+ group.options.shaded.orientation="group";
+ group.options.shaded.groupId=below.id;
+ }
+ }
+ }
+ below = group;
+ }
}
this._convertYcoordinates(groupsData[groupIds[i]], group);
}
@@ -780,8 +795,8 @@ LineGraph.prototype._getRelevantData = function (groupIds, groupsData, minDate,
// optimization for sorted data
if (group.options.sort == true) {
var first = Math.max(0, util.binarySearchValue(itemsData, minDate, 'x', 'before'));
- var last = Math.min(itemsData.length, util.binarySearchValue(itemsData, maxDate, 'x', 'after'));
- if (last < 0) {
+ var last = Math.min(itemsData.length, util.binarySearchValue(itemsData, maxDate, 'x', 'after')+1);
+ if (last <= 0) {
last = itemsData.length;
}
var dataContainer = new Array(last-first);
diff --git a/lib/timeline/component/graph2d_types/line.js b/lib/timeline/component/graph2d_types/line.js
index 4091f237..638e1a6c 100644
--- a/lib/timeline/component/graph2d_types/line.js
+++ b/lib/timeline/component/graph2d_types/line.js
@@ -85,7 +85,7 @@ Line.draw = function (pathArray, group, framework) {
};
Line.serializePath = function(pathArray,type,inverse){
- if (pathArray.length <= 2){
+ if (pathArray.length < 2){
//Too little data to create a path.
return "";
}