|
@ -30,6 +30,14 @@ function DataAxis (body, options, svg, linegraphOptions) { |
|
|
customRange: { |
|
|
customRange: { |
|
|
left: {min:undefined, max:undefined}, |
|
|
left: {min:undefined, max:undefined}, |
|
|
right: {min:undefined, max:undefined} |
|
|
right: {min:undefined, max:undefined} |
|
|
|
|
|
}, |
|
|
|
|
|
title: { |
|
|
|
|
|
left: {text:undefined}, |
|
|
|
|
|
right: {text:undefined} |
|
|
|
|
|
}, |
|
|
|
|
|
format: { |
|
|
|
|
|
left: {decimals: undefined}, |
|
|
|
|
|
right: {decimals: undefined} |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -38,7 +46,8 @@ function DataAxis (body, options, svg, linegraphOptions) { |
|
|
this.props = {}; |
|
|
this.props = {}; |
|
|
this.DOMelements = { // dynamic elements
|
|
|
this.DOMelements = { // dynamic elements
|
|
|
lines: {}, |
|
|
lines: {}, |
|
|
labels: {} |
|
|
|
|
|
|
|
|
labels: {}, |
|
|
|
|
|
title: {} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
this.dom = {}; |
|
|
this.dom = {}; |
|
@ -113,7 +122,9 @@ DataAxis.prototype.setOptions = function (options) { |
|
|
'iconWidth', |
|
|
'iconWidth', |
|
|
'width', |
|
|
'width', |
|
|
'visible', |
|
|
'visible', |
|
|
'customRange' |
|
|
|
|
|
|
|
|
'customRange', |
|
|
|
|
|
'title', |
|
|
|
|
|
'format' |
|
|
]; |
|
|
]; |
|
|
util.selectiveExtend(fields, this.options, options); |
|
|
util.selectiveExtend(fields, this.options, options); |
|
|
|
|
|
|
|
@ -227,7 +238,8 @@ DataAxis.prototype.setRange = function (start, end) { |
|
|
DataAxis.prototype.redraw = function () { |
|
|
DataAxis.prototype.redraw = function () { |
|
|
var changeCalled = false; |
|
|
var changeCalled = false; |
|
|
var activeGroups = 0; |
|
|
var activeGroups = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure the line container adheres to the vertical scrolling.
|
|
|
this.dom.lineContainer.style.top = this.body.domProps.scrollTop + 'px'; |
|
|
this.dom.lineContainer.style.top = this.body.domProps.scrollTop + 'px'; |
|
|
|
|
|
|
|
|
for (var groupId in this.groups) { |
|
|
for (var groupId in this.groups) { |
|
@ -261,7 +273,7 @@ DataAxis.prototype.redraw = function () { |
|
|
var showMinorLabels = this.options.showMinorLabels; |
|
|
var showMinorLabels = this.options.showMinorLabels; |
|
|
var showMajorLabels = this.options.showMajorLabels; |
|
|
var showMajorLabels = this.options.showMajorLabels; |
|
|
|
|
|
|
|
|
// determine the width and height of the elemens for the axis
|
|
|
|
|
|
|
|
|
// determine the width and height of the elements for the axis
|
|
|
props.minorLabelHeight = showMinorLabels ? props.minorCharHeight : 0; |
|
|
props.minorLabelHeight = showMinorLabels ? props.minorCharHeight : 0; |
|
|
props.majorLabelHeight = showMajorLabels ? props.majorCharHeight : 0; |
|
|
props.majorLabelHeight = showMajorLabels ? props.majorCharHeight : 0; |
|
|
|
|
|
|
|
@ -289,6 +301,8 @@ DataAxis.prototype.redraw = function () { |
|
|
if (this.options.icons == true) { |
|
|
if (this.options.icons == true) { |
|
|
this._redrawGroupIcons(); |
|
|
this._redrawGroupIcons(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this._redrawTitle(orientation); |
|
|
} |
|
|
} |
|
|
return changeCalled; |
|
|
return changeCalled; |
|
|
}; |
|
|
}; |
|
@ -335,23 +349,28 @@ DataAxis.prototype._redrawLabels = function () { |
|
|
// do not draw the first label
|
|
|
// do not draw the first label
|
|
|
var max = 1; |
|
|
var max = 1; |
|
|
|
|
|
|
|
|
|
|
|
// Get the number of decimal places
|
|
|
|
|
|
var decimals; |
|
|
|
|
|
if(this.options.format[orientation] !== undefined) { |
|
|
|
|
|
decimals = this.options.format[orientation].decimals; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.maxLabelSize = 0; |
|
|
this.maxLabelSize = 0; |
|
|
var y = 0; |
|
|
var y = 0; |
|
|
while (max < Math.round(amountOfSteps)) { |
|
|
while (max < Math.round(amountOfSteps)) { |
|
|
|
|
|
|
|
|
step.next(); |
|
|
step.next(); |
|
|
y = Math.round(max * stepPixels); |
|
|
y = Math.round(max * stepPixels); |
|
|
marginStartPos = max * stepPixels; |
|
|
marginStartPos = max * stepPixels; |
|
|
var isMajor = step.isMajor(); |
|
|
var isMajor = step.isMajor(); |
|
|
|
|
|
|
|
|
if (this.options['showMinorLabels'] && isMajor == false || this.master == false && this.options['showMinorLabels'] == true) { |
|
|
if (this.options['showMinorLabels'] && isMajor == false || this.master == false && this.options['showMinorLabels'] == true) { |
|
|
this._redrawLabel(y - 2, step.getCurrent(), orientation, 'yAxis minor', this.props.minorCharHeight); |
|
|
|
|
|
|
|
|
this._redrawLabel(y - 2, step.getCurrent(decimals), orientation, 'yAxis minor', this.props.minorCharHeight); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isMajor && this.options['showMajorLabels'] && this.master == true || |
|
|
if (isMajor && this.options['showMajorLabels'] && this.master == true || |
|
|
this.options['showMinorLabels'] == false && this.master == false && isMajor == true) { |
|
|
this.options['showMinorLabels'] == false && this.master == false && isMajor == true) { |
|
|
if (y >= 0) { |
|
|
if (y >= 0) { |
|
|
this._redrawLabel(y - 2, step.getCurrent(), orientation, 'yAxis major', this.props.majorCharHeight); |
|
|
|
|
|
|
|
|
this._redrawLabel(y - 2, step.getCurrent(decimals), orientation, 'yAxis major', this.props.majorCharHeight); |
|
|
} |
|
|
} |
|
|
this._redrawLine(y, orientation, 'grid horizontal major', this.options.majorLinesOffset, this.props.majorLineWidth); |
|
|
this._redrawLine(y, orientation, 'grid horizontal major', this.options.majorLinesOffset, this.props.majorLineWidth); |
|
|
} |
|
|
} |
|
@ -369,9 +388,14 @@ DataAxis.prototype._redrawLabels = function () { |
|
|
this.conversionFactor = this.dom.frame.offsetHeight / step.marginRange; |
|
|
this.conversionFactor = this.dom.frame.offsetHeight / step.marginRange; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var offset = this.options.icons == true ? this.options.iconWidth + this.options.labelOffsetX + 15 : this.options.labelOffsetX + 15; |
|
|
|
|
|
|
|
|
// Note that title is rotated, so we're using the height, not width!
|
|
|
|
|
|
var titleWidth = 0; |
|
|
|
|
|
if(this.options.title[orientation] !== undefined) { |
|
|
|
|
|
titleWidth = this.props.titleCharHeight; |
|
|
|
|
|
} |
|
|
|
|
|
var offset = this.options.icons == true ? Math.max(this.options.iconWidth, titleWidth) + this.options.labelOffsetX + 15 : titleWidth + this.options.labelOffsetX + 15; |
|
|
|
|
|
|
|
|
// this will resize the yAxis to accomodate the labels.
|
|
|
|
|
|
|
|
|
// this will resize the yAxis to accommodate the labels.
|
|
|
if (this.maxLabelSize > (this.width - offset) && this.options.visible == true) { |
|
|
if (this.maxLabelSize > (this.width - offset) && this.options.visible == true) { |
|
|
this.width = this.maxLabelSize + offset; |
|
|
this.width = this.maxLabelSize + offset; |
|
|
this.options.width = this.width + "px"; |
|
|
this.options.width = this.width + "px"; |
|
@ -461,6 +485,36 @@ DataAxis.prototype._redrawLine = function (y, orientation, className, offset, wi |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Create a title for the axis |
|
|
|
|
|
* @private |
|
|
|
|
|
* @param orientation |
|
|
|
|
|
*/ |
|
|
|
|
|
DataAxis.prototype._redrawTitle = function (orientation) { |
|
|
|
|
|
DOMutil.prepareElements(this.DOMelements.title); |
|
|
|
|
|
|
|
|
|
|
|
// Check if the title is defined for this axes
|
|
|
|
|
|
if(this.options.title[orientation] == undefined || this.options.title[orientation].text === undefined) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
var title = DOMutil.getDOMElement('div',this.DOMelements.title, this.dom.frame); |
|
|
|
|
|
title.className = 'yAxis title ' + orientation; |
|
|
|
|
|
title.innerHTML = this.options.title[orientation].text; |
|
|
|
|
|
|
|
|
|
|
|
// Add style - if provided
|
|
|
|
|
|
if(this.options.title[orientation].style !== undefined) { |
|
|
|
|
|
util.addCssText(title, this.options.title[orientation].style); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (orientation == 'left') { |
|
|
|
|
|
title.style.left = this.props.titleCharHeight + 'px'; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
title.style.right = this.props.titleCharHeight + 'px'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
title.style.width = this.height + 'px'; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -497,6 +551,19 @@ DataAxis.prototype._calculateCharSize = function () { |
|
|
|
|
|
|
|
|
this.dom.frame.removeChild(measureCharMajor); |
|
|
this.dom.frame.removeChild(measureCharMajor); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!('titleCharHeight' in this.props)) { |
|
|
|
|
|
var textTitle = document.createTextNode('0'); |
|
|
|
|
|
var measureCharTitle = document.createElement('DIV'); |
|
|
|
|
|
measureCharTitle.className = 'yAxis title measure'; |
|
|
|
|
|
measureCharTitle.appendChild(textTitle); |
|
|
|
|
|
this.dom.frame.appendChild(measureCharTitle); |
|
|
|
|
|
|
|
|
|
|
|
this.props.titleCharHeight = measureCharTitle.clientHeight; |
|
|
|
|
|
this.props.titleCharWidth = measureCharTitle.clientWidth; |
|
|
|
|
|
|
|
|
|
|
|
this.dom.frame.removeChild(measureCharTitle); |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|