Browse Source

fixed bug where slave right axis was not always scaling correctly, re-added forcing to date, appearently this was cached

css_transitions
Alex de Mulder 10 years ago
parent
commit
c9aa4741e6
7 changed files with 43 additions and 45 deletions
  1. +4
    -8
      dist/vis.css
  2. +12
    -9
      dist/vis.js
  3. +11
    -11
      dist/vis.min.js
  4. +1
    -1
      src/timeline/component/DataAxis.js
  5. +5
    -0
      src/timeline/component/GraphGroup.js
  6. +6
    -8
      src/timeline/component/Linegraph.js
  7. +4
    -8
      src/timeline/component/css/dataaxis.css

+ 4
- 8
dist/vis.css View File

@ -365,10 +365,8 @@
}
.vis.timeline .dataaxis .yAxis.major.measure{
padding-left: 0;
padding-right: 0;
margin-left: 0;
margin-right: 0;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
visibility: hidden;
width: auto;
}
@ -382,10 +380,8 @@
}
.vis.timeline .dataaxis .yAxis.minor.measure{
padding-left: 0;
padding-right: 0;
margin-left: 0;
margin-right: 0;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
visibility: hidden;
width: auto;
}

+ 12
- 9
dist/vis.js View File

@ -2896,6 +2896,7 @@ function GraphGroup (group, groupId, options, groupsUsingDefaultStyles) {
this.options = util.selectiveDeepExtend(fields,{},options);
this.usingDefaultStyle = group.className === undefined;
this.groupsUsingDefaultStyles = groupsUsingDefaultStyles;
this.zeroPosition = 0;
this.update(group);
if (this.usingDefaultStyle == true) {
this.groupsUsingDefaultStyles[0] += 1;
@ -2915,6 +2916,10 @@ GraphGroup.prototype.setItems = function(items) {
}
}
GraphGroup.prototype.setZeroPosition = function(pos) {
this.zeroPosition = pos;
}
GraphGroup.prototype.setOptions = function(options) {
if (options !== undefined) {
var fields = ['yAxisOrientation','style','barChart','sort'];
@ -3443,7 +3448,7 @@ DataAxis.prototype._redrawLabels = function () {
var orientation = this.options['orientation'];
// calculate range and step (step such that we have space for 7 characters per label)
var minimumStep = (this.props.majorCharHeight || 10); //in pixels
var minimumStep = this.master ? this.props.majorCharHeight || 10 : this.stepPixelsForced;
var step = new DataStep(this.yRange.start, this.yRange.end, minimumStep, this.dom.frame.offsetHeight);
this.step = step;
step.first();
@ -4052,7 +4057,7 @@ Linegraph.prototype._updateAllGroupData = function () {
for (var itemId in this.itemsData._data) {
if (this.itemsData._data.hasOwnProperty(itemId)) {
var item = this.itemsData._data[itemId];
// item.x = util.convert(item.x,"Date");
item.x = util.convert(item.x,"Date");
groupsContent[item.group].push(item);
}
}
@ -4257,11 +4262,10 @@ Linegraph.prototype._updateGraph = function () {
return;
}
// with the yAxis scaled correctly, use this to get the Y values of the points.
for (i = 0; i < groupIds.length; i++) {
group = this.groups[groupIds[i]];
processedGroupData.push(this._convertYvalues(preprocessedGroupData[i],group.options))
processedGroupData.push(this._convertYvalues(preprocessedGroupData[i],group))
}
// draw the groups
@ -4396,7 +4400,7 @@ Linegraph.prototype._drawBarGraph = function (dataset, group) {
if (i > 0) {coreDistance = Math.min(coreDistance,Math.abs(dataset[i-1].x - dataset[i].x));}
if (coreDistance < width) {width = coreDistance < minWidth ? minWidth : coreDistance;}
DOMutil.drawBar(dataset[i].x, dataset[i].y, width, this.zeroPosition - dataset[i].y, group.className + ' bar', this.svgElements, this.svg);
DOMutil.drawBar(dataset[i].x, dataset[i].y, width, group.zeroPosition - dataset[i].y, group.className + ' bar', this.svgElements, this.svg);
}
// draw points
@ -4522,14 +4526,13 @@ Linegraph.prototype._preprocessData = function (datapoints, group) {
* @returns {Array}
* @private
*/
Linegraph.prototype._convertYvalues = function (datapoints, options) {
Linegraph.prototype._convertYvalues = function (datapoints, group) {
var extractedData = [];
var xValue, yValue;
var axis = this.yAxisLeft;
var svgHeight = Number(this.svg.style.height.replace("px",""));
this.zeroPosition = 0;
if (options.yAxisOrientation == 'right') {
if (group.options.yAxisOrientation == 'right') {
axis = this.yAxisRight;
}
@ -4539,7 +4542,7 @@ Linegraph.prototype._convertYvalues = function (datapoints, options) {
extractedData.push({x: xValue, y: yValue});
}
this.zeroPosition = Math.min(svgHeight, axis.convertValue(0));
group.setZeroPosition(Math.min(svgHeight, axis.convertValue(0)));
// extractedData.sort(function (a,b) {return a.x - b.x;});
return extractedData;

+ 11
- 11
dist/vis.min.js
File diff suppressed because it is too large
View File


+ 1
- 1
src/timeline/component/DataAxis.js View File

@ -268,7 +268,7 @@ DataAxis.prototype._redrawLabels = function () {
var orientation = this.options['orientation'];
// calculate range and step (step such that we have space for 7 characters per label)
var minimumStep = (this.props.majorCharHeight || 10); //in pixels
var minimumStep = this.master ? this.props.majorCharHeight || 10 : this.stepPixelsForced;
var step = new DataStep(this.yRange.start, this.yRange.end, minimumStep, this.dom.frame.offsetHeight);
this.step = step;
step.first();

+ 5
- 0
src/timeline/component/GraphGroup.js View File

@ -10,6 +10,7 @@ function GraphGroup (group, groupId, options, groupsUsingDefaultStyles) {
this.options = util.selectiveDeepExtend(fields,{},options);
this.usingDefaultStyle = group.className === undefined;
this.groupsUsingDefaultStyles = groupsUsingDefaultStyles;
this.zeroPosition = 0;
this.update(group);
if (this.usingDefaultStyle == true) {
this.groupsUsingDefaultStyles[0] += 1;
@ -29,6 +30,10 @@ GraphGroup.prototype.setItems = function(items) {
}
}
GraphGroup.prototype.setZeroPosition = function(pos) {
this.zeroPosition = pos;
}
GraphGroup.prototype.setOptions = function(options) {
if (options !== undefined) {
var fields = ['yAxisOrientation','style','barChart','sort'];

+ 6
- 8
src/timeline/component/Linegraph.js View File

@ -412,7 +412,7 @@ Linegraph.prototype._updateAllGroupData = function () {
for (var itemId in this.itemsData._data) {
if (this.itemsData._data.hasOwnProperty(itemId)) {
var item = this.itemsData._data[itemId];
// item.x = util.convert(item.x,"Date");
item.x = util.convert(item.x,"Date");
groupsContent[item.group].push(item);
}
}
@ -617,11 +617,10 @@ Linegraph.prototype._updateGraph = function () {
return;
}
// with the yAxis scaled correctly, use this to get the Y values of the points.
for (i = 0; i < groupIds.length; i++) {
group = this.groups[groupIds[i]];
processedGroupData.push(this._convertYvalues(preprocessedGroupData[i],group.options))
processedGroupData.push(this._convertYvalues(preprocessedGroupData[i],group))
}
// draw the groups
@ -756,7 +755,7 @@ Linegraph.prototype._drawBarGraph = function (dataset, group) {
if (i > 0) {coreDistance = Math.min(coreDistance,Math.abs(dataset[i-1].x - dataset[i].x));}
if (coreDistance < width) {width = coreDistance < minWidth ? minWidth : coreDistance;}
DOMutil.drawBar(dataset[i].x, dataset[i].y, width, this.zeroPosition - dataset[i].y, group.className + ' bar', this.svgElements, this.svg);
DOMutil.drawBar(dataset[i].x, dataset[i].y, width, group.zeroPosition - dataset[i].y, group.className + ' bar', this.svgElements, this.svg);
}
// draw points
@ -882,14 +881,13 @@ Linegraph.prototype._preprocessData = function (datapoints, group) {
* @returns {Array}
* @private
*/
Linegraph.prototype._convertYvalues = function (datapoints, options) {
Linegraph.prototype._convertYvalues = function (datapoints, group) {
var extractedData = [];
var xValue, yValue;
var axis = this.yAxisLeft;
var svgHeight = Number(this.svg.style.height.replace("px",""));
this.zeroPosition = 0;
if (options.yAxisOrientation == 'right') {
if (group.options.yAxisOrientation == 'right') {
axis = this.yAxisRight;
}
@ -899,7 +897,7 @@ Linegraph.prototype._convertYvalues = function (datapoints, options) {
extractedData.push({x: xValue, y: yValue});
}
this.zeroPosition = Math.min(svgHeight, axis.convertValue(0));
group.setZeroPosition(Math.min(svgHeight, axis.convertValue(0)));
// extractedData.sort(function (a,b) {return a.x - b.x;});
return extractedData;

+ 4
- 8
src/timeline/component/css/dataaxis.css View File

@ -23,10 +23,8 @@
}
.vis.timeline .dataaxis .yAxis.major.measure{
padding-left: 0;
padding-right: 0;
margin-left: 0;
margin-right: 0;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
visibility: hidden;
width: auto;
}
@ -40,10 +38,8 @@
}
.vis.timeline .dataaxis .yAxis.minor.measure{
padding-left: 0;
padding-right: 0;
margin-left: 0;
margin-right: 0;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
visibility: hidden;
width: auto;
}

Loading…
Cancel
Save