|
@ -27,6 +27,7 @@ function DataAxis (body, options, svg, linegraphOptions) { |
|
|
iconWidth: 20, |
|
|
iconWidth: 20, |
|
|
width: '40px', |
|
|
width: '40px', |
|
|
visible: true, |
|
|
visible: true, |
|
|
|
|
|
alignZeros: true, |
|
|
customRange: { |
|
|
customRange: { |
|
|
left: {min:undefined, max:undefined}, |
|
|
left: {min:undefined, max:undefined}, |
|
|
right: {min:undefined, max:undefined} |
|
|
right: {min:undefined, max:undefined} |
|
@ -64,6 +65,8 @@ function DataAxis (body, options, svg, linegraphOptions) { |
|
|
|
|
|
|
|
|
this.stepPixels = 25; |
|
|
this.stepPixels = 25; |
|
|
this.stepPixelsForced = 25; |
|
|
this.stepPixelsForced = 25; |
|
|
|
|
|
this.zeroCrossing = -1; |
|
|
|
|
|
|
|
|
this.lineOffset = 0; |
|
|
this.lineOffset = 0; |
|
|
this.master = true; |
|
|
this.master = true; |
|
|
this.svgElements = {}; |
|
|
this.svgElements = {}; |
|
@ -125,7 +128,8 @@ DataAxis.prototype.setOptions = function (options) { |
|
|
'visible', |
|
|
'visible', |
|
|
'customRange', |
|
|
'customRange', |
|
|
'title', |
|
|
'title', |
|
|
'format' |
|
|
|
|
|
|
|
|
'format', |
|
|
|
|
|
'alignZeros' |
|
|
]; |
|
|
]; |
|
|
util.selectiveExtend(fields, this.options, options); |
|
|
util.selectiveExtend(fields, this.options, options); |
|
|
|
|
|
|
|
@ -237,6 +241,11 @@ DataAxis.prototype.hide = function() { |
|
|
* @param end |
|
|
* @param end |
|
|
*/ |
|
|
*/ |
|
|
DataAxis.prototype.setRange = function (start, end) { |
|
|
DataAxis.prototype.setRange = function (start, end) { |
|
|
|
|
|
if (this.master == false && this.options.alignZeros == true && this.zeroCrossing != -1) { |
|
|
|
|
|
if (start > 0) { |
|
|
|
|
|
start = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
this.range.start = start; |
|
|
this.range.start = start; |
|
|
this.range.end = end; |
|
|
this.range.end = end; |
|
|
}; |
|
|
}; |
|
@ -334,16 +343,26 @@ DataAxis.prototype._redrawLabels = function () { |
|
|
// calculate range and step (step such that we have space for 7 characters per label)
|
|
|
// calculate range and step (step such that we have space for 7 characters per label)
|
|
|
var minimumStep = this.master ? this.props.majorCharHeight || 10 : this.stepPixelsForced; |
|
|
var minimumStep = this.master ? this.props.majorCharHeight || 10 : this.stepPixelsForced; |
|
|
|
|
|
|
|
|
var step = new DataStep(this.range.start, this.range.end, minimumStep, this.dom.frame.offsetHeight, this.options.customRange[this.options.orientation]); |
|
|
|
|
|
|
|
|
var step = new DataStep( |
|
|
|
|
|
this.range.start, |
|
|
|
|
|
this.range.end, |
|
|
|
|
|
minimumStep, |
|
|
|
|
|
this.dom.frame.offsetHeight, |
|
|
|
|
|
this.options.customRange[this.options.orientation], |
|
|
|
|
|
this.master == false && this.options.alignZeros // doess the step have to align zeros? only if not master and the options is on
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
this.step = step; |
|
|
this.step = step; |
|
|
// get the distance in pixels for a step
|
|
|
// get the distance in pixels for a step
|
|
|
// dead space is space that is "left over" after a step
|
|
|
// dead space is space that is "left over" after a step
|
|
|
var stepPixels = (this.dom.frame.offsetHeight - (step.deadSpace * (this.dom.frame.offsetHeight / step.marginRange))) / (((step.marginRange - step.deadSpace) / step.step)); |
|
|
var stepPixels = (this.dom.frame.offsetHeight - (step.deadSpace * (this.dom.frame.offsetHeight / step.marginRange))) / (((step.marginRange - step.deadSpace) / step.step)); |
|
|
|
|
|
|
|
|
this.stepPixels = stepPixels; |
|
|
this.stepPixels = stepPixels; |
|
|
|
|
|
|
|
|
var amountOfSteps = this.height / stepPixels; |
|
|
var amountOfSteps = this.height / stepPixels; |
|
|
var stepDifference = 0; |
|
|
var stepDifference = 0; |
|
|
|
|
|
|
|
|
|
|
|
// the slave axis needs to use the same horizontal lines as the master axis.
|
|
|
if (this.master == false) { |
|
|
if (this.master == false) { |
|
|
stepPixels = this.stepPixelsForced; |
|
|
stepPixels = this.stepPixelsForced; |
|
|
stepDifference = Math.round((this.dom.frame.offsetHeight / stepPixels) - amountOfSteps); |
|
|
stepDifference = Math.round((this.dom.frame.offsetHeight / stepPixels) - amountOfSteps); |
|
@ -351,6 +370,16 @@ DataAxis.prototype._redrawLabels = function () { |
|
|
step.previous(); |
|
|
step.previous(); |
|
|
} |
|
|
} |
|
|
amountOfSteps = this.height / stepPixels; |
|
|
amountOfSteps = this.height / stepPixels; |
|
|
|
|
|
|
|
|
|
|
|
if (this.zeroCrossing != -1 && this.options.alignZeros == true) { |
|
|
|
|
|
var zeroStepDifference = (step.marginEnd / step.step) - this.zeroCrossing; |
|
|
|
|
|
if (zeroStepDifference > 0) { |
|
|
|
|
|
for (var i = 0; i < zeroStepDifference; i++) {step.next();} |
|
|
|
|
|
} |
|
|
|
|
|
else if (zeroStepDifference < 0) { |
|
|
|
|
|
for (var i = 0; i < -zeroStepDifference; i++) {step.previous();} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
amountOfSteps += 0.25; |
|
|
amountOfSteps += 0.25; |
|
@ -392,6 +421,10 @@ DataAxis.prototype._redrawLabels = function () { |
|
|
this._redrawLine(y, orientation, 'grid horizontal minor', this.options.minorLinesOffset, this.props.minorLineWidth); |
|
|
this._redrawLine(y, orientation, 'grid horizontal minor', this.options.minorLinesOffset, this.props.minorLineWidth); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.master == true && step.current == 0) { |
|
|
|
|
|
this.zeroCrossing = max; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
max++; |
|
|
max++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -544,7 +577,7 @@ DataAxis.prototype._calculateCharSize = function () { |
|
|
// determine the char width and height on the minor axis
|
|
|
// determine the char width and height on the minor axis
|
|
|
if (!('minorCharHeight' in this.props)) { |
|
|
if (!('minorCharHeight' in this.props)) { |
|
|
var textMinor = document.createTextNode('0'); |
|
|
var textMinor = document.createTextNode('0'); |
|
|
var measureCharMinor = document.createElement('DIV'); |
|
|
|
|
|
|
|
|
var measureCharMinor = document.createElement('div'); |
|
|
measureCharMinor.className = 'yAxis minor measure'; |
|
|
measureCharMinor.className = 'yAxis minor measure'; |
|
|
measureCharMinor.appendChild(textMinor); |
|
|
measureCharMinor.appendChild(textMinor); |
|
|
this.dom.frame.appendChild(measureCharMinor); |
|
|
this.dom.frame.appendChild(measureCharMinor); |
|
@ -557,7 +590,7 @@ DataAxis.prototype._calculateCharSize = function () { |
|
|
|
|
|
|
|
|
if (!('majorCharHeight' in this.props)) { |
|
|
if (!('majorCharHeight' in this.props)) { |
|
|
var textMajor = document.createTextNode('0'); |
|
|
var textMajor = document.createTextNode('0'); |
|
|
var measureCharMajor = document.createElement('DIV'); |
|
|
|
|
|
|
|
|
var measureCharMajor = document.createElement('div'); |
|
|
measureCharMajor.className = 'yAxis major measure'; |
|
|
measureCharMajor.className = 'yAxis major measure'; |
|
|
measureCharMajor.appendChild(textMajor); |
|
|
measureCharMajor.appendChild(textMajor); |
|
|
this.dom.frame.appendChild(measureCharMajor); |
|
|
this.dom.frame.appendChild(measureCharMajor); |
|
@ -570,7 +603,7 @@ DataAxis.prototype._calculateCharSize = function () { |
|
|
|
|
|
|
|
|
if (!('titleCharHeight' in this.props)) { |
|
|
if (!('titleCharHeight' in this.props)) { |
|
|
var textTitle = document.createTextNode('0'); |
|
|
var textTitle = document.createTextNode('0'); |
|
|
var measureCharTitle = document.createElement('DIV'); |
|
|
|
|
|
|
|
|
var measureCharTitle = document.createElement('div'); |
|
|
measureCharTitle.className = 'yAxis title measure'; |
|
|
measureCharTitle.className = 'yAxis title measure'; |
|
|
measureCharTitle.appendChild(textTitle); |
|
|
measureCharTitle.appendChild(textTitle); |
|
|
this.dom.frame.appendChild(measureCharTitle); |
|
|
this.dom.frame.appendChild(measureCharTitle); |
|
|