|
@ -100,7 +100,7 @@ function LineGraph(body, options) { |
|
|
this.hammer = null; |
|
|
this.hammer = null; |
|
|
this.groups = {}; |
|
|
this.groups = {}; |
|
|
this.abortedGraphUpdate = false; |
|
|
this.abortedGraphUpdate = false; |
|
|
this.autoSizeSVG = false; |
|
|
|
|
|
|
|
|
this.updateSVGheight = false; |
|
|
|
|
|
|
|
|
var me = this; |
|
|
var me = this; |
|
|
this.itemsData = null; // DataSet
|
|
|
this.itemsData = null; // DataSet
|
|
@ -194,11 +194,11 @@ LineGraph.prototype.setOptions = function(options) { |
|
|
if (options) { |
|
|
if (options) { |
|
|
var fields = ['sampling','defaultGroup','height','graphHeight','yAxisOrientation','style','barChart','dataAxis','sort','groups']; |
|
|
var fields = ['sampling','defaultGroup','height','graphHeight','yAxisOrientation','style','barChart','dataAxis','sort','groups']; |
|
|
if (options.graphHeight === undefined && options.height !== undefined && this.body.domProps.centerContainer.height !== undefined) { |
|
|
if (options.graphHeight === undefined && options.height !== undefined && this.body.domProps.centerContainer.height !== undefined) { |
|
|
this.autoSizeSVG = true; |
|
|
|
|
|
|
|
|
this.updateSVGheight = true; |
|
|
} |
|
|
} |
|
|
else if (this.body.domProps.centerContainer.height !== undefined && options.graphHeight !== undefined) { |
|
|
else if (this.body.domProps.centerContainer.height !== undefined && options.graphHeight !== undefined) { |
|
|
if (parseInt((options.graphHeight + '').replace("px",'')) < this.body.domProps.centerContainer.height) { |
|
|
if (parseInt((options.graphHeight + '').replace("px",'')) < this.body.domProps.centerContainer.height) { |
|
|
this.autoSizeSVG = true; |
|
|
|
|
|
|
|
|
this.updateSVGheight = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
util.selectiveDeepExtend(fields, this.options, options); |
|
|
util.selectiveDeepExtend(fields, this.options, options); |
|
@ -566,18 +566,20 @@ LineGraph.prototype.redraw = function(forceGraphUpdate) { |
|
|
if (resized == true) { |
|
|
if (resized == true) { |
|
|
this.svg.style.width = util.option.asSize(3*this.props.width); |
|
|
this.svg.style.width = util.option.asSize(3*this.props.width); |
|
|
this.svg.style.left = util.option.asSize(-this.props.width); |
|
|
this.svg.style.left = util.option.asSize(-this.props.width); |
|
|
|
|
|
|
|
|
|
|
|
// if the height of the graph is set as proportional, change the height of the svg
|
|
|
if ((this.options.height + '').indexOf("%") != -1) { |
|
|
if ((this.options.height + '').indexOf("%") != -1) { |
|
|
this.autoSizeSVG = true; |
|
|
|
|
|
|
|
|
this.updateSVGheight = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// update the height of the graph on each redraw of the graph.
|
|
|
// update the height of the graph on each redraw of the graph.
|
|
|
if (this.autoSizeSVG == true) { |
|
|
|
|
|
|
|
|
if (this.updateSVGheight == true) { |
|
|
if (this.options.graphHeight != this.body.domProps.centerContainer.height + 'px') { |
|
|
if (this.options.graphHeight != this.body.domProps.centerContainer.height + 'px') { |
|
|
this.options.graphHeight = this.body.domProps.centerContainer.height + 'px'; |
|
|
this.options.graphHeight = this.body.domProps.centerContainer.height + 'px'; |
|
|
this.svg.style.height = this.body.domProps.centerContainer.height + 'px'; |
|
|
this.svg.style.height = this.body.domProps.centerContainer.height + 'px'; |
|
|
} |
|
|
} |
|
|
this.autoSizeSVG = false; |
|
|
|
|
|
|
|
|
this.updateSVGheight = false; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
this.svg.style.height = ('' + this.options.graphHeight).replace('px','') + 'px'; |
|
|
this.svg.style.height = ('' + this.options.graphHeight).replace('px','') + 'px'; |
|
@ -602,7 +604,6 @@ LineGraph.prototype.redraw = function(forceGraphUpdate) { |
|
|
|
|
|
|
|
|
this.legendLeft.redraw(); |
|
|
this.legendLeft.redraw(); |
|
|
this.legendRight.redraw(); |
|
|
this.legendRight.redraw(); |
|
|
|
|
|
|
|
|
return resized; |
|
|
return resized; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -823,7 +824,7 @@ LineGraph.prototype._getYRanges = function (groupIds, groupsData, groupRanges) { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) { |
|
|
LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) { |
|
|
var changeCalled = false; |
|
|
|
|
|
|
|
|
var resized = false; |
|
|
var yAxisLeftUsed = false; |
|
|
var yAxisLeftUsed = false; |
|
|
var yAxisRightUsed = false; |
|
|
var yAxisRightUsed = false; |
|
|
var minLeft = 1e9, minRight = 1e9, maxLeft = -1e9, maxRight = -1e9, minVal, maxVal; |
|
|
var minLeft = 1e9, minRight = 1e9, maxLeft = -1e9, maxRight = -1e9, minVal, maxVal; |
|
@ -872,8 +873,8 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) { |
|
|
this.yAxisRight.setRange(minRight, maxRight); |
|
|
this.yAxisRight.setRange(minRight, maxRight); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
changeCalled = this._toggleAxisVisiblity(yAxisLeftUsed , this.yAxisLeft) || changeCalled; |
|
|
|
|
|
changeCalled = this._toggleAxisVisiblity(yAxisRightUsed, this.yAxisRight) || changeCalled; |
|
|
|
|
|
|
|
|
resized = this._toggleAxisVisiblity(yAxisLeftUsed , this.yAxisLeft) || resized; |
|
|
|
|
|
resized = this._toggleAxisVisiblity(yAxisRightUsed, this.yAxisRight) || resized; |
|
|
if (yAxisRightUsed == true && yAxisLeftUsed == true) { |
|
|
if (yAxisRightUsed == true && yAxisLeftUsed == true) { |
|
|
this.yAxisLeft.drawIcons = true; |
|
|
this.yAxisLeft.drawIcons = true; |
|
|
this.yAxisRight.drawIcons = true; |
|
|
this.yAxisRight.drawIcons = true; |
|
@ -888,13 +889,13 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) { |
|
|
if (yAxisRightUsed == true) {this.yAxisLeft.lineOffset = this.yAxisRight.width;} |
|
|
if (yAxisRightUsed == true) {this.yAxisLeft.lineOffset = this.yAxisRight.width;} |
|
|
else {this.yAxisLeft.lineOffset = 0;} |
|
|
else {this.yAxisLeft.lineOffset = 0;} |
|
|
|
|
|
|
|
|
changeCalled = this.yAxisLeft.redraw() || changeCalled; |
|
|
|
|
|
|
|
|
resized = this.yAxisLeft.redraw() || resized; |
|
|
this.yAxisRight.stepPixelsForced = this.yAxisLeft.stepPixels; |
|
|
this.yAxisRight.stepPixelsForced = this.yAxisLeft.stepPixels; |
|
|
this.yAxisRight.zeroCrossing = this.yAxisLeft.zeroCrossing; |
|
|
this.yAxisRight.zeroCrossing = this.yAxisLeft.zeroCrossing; |
|
|
changeCalled = this.yAxisRight.redraw() || changeCalled; |
|
|
|
|
|
|
|
|
resized = this.yAxisRight.redraw() || resized; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
changeCalled = this.yAxisRight.redraw() || changeCalled; |
|
|
|
|
|
|
|
|
resized = this.yAxisRight.redraw() || resized; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// clean the accumulated lists
|
|
|
// clean the accumulated lists
|
|
@ -905,7 +906,7 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) { |
|
|
groupIds.splice(groupIds.indexOf('__barchartRight'),1); |
|
|
groupIds.splice(groupIds.indexOf('__barchartRight'),1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return changeCalled; |
|
|
|
|
|
|
|
|
return resized; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|