Browse Source

graph3d: added custom ticks label support for z axis

v3_develop
fabriziofortino 10 years ago
parent
commit
47e3d25dce
2 changed files with 11 additions and 4 deletions
  1. +5
    -1
      examples/graph3d/example12_ticks.html
  2. +6
    -3
      lib/graph3d/Graph3d.js

+ 5
- 1
examples/graph3d/example12_ticks.html View File

@ -14,7 +14,7 @@
var graph = null;
function custom(x, y) {
return (-Math.sin(x/Math.PI) * Math.cos(y/Math.PI) * 10 + 10);
return (-Math.sin(x/Math.PI) * Math.cos(y/Math.PI) * 10 + 10) * 1000;
}
// Called when the Visualization API is loaded.
@ -66,6 +66,10 @@
return value * 10 + '%';
},
zValueLabel: function(value) {
return value / 1000 + 'K';
},
keepAspectRatio: true,
verticalRatio: 0.5
};

+ 6
- 3
lib/graph3d/Graph3d.js View File

@ -37,8 +37,10 @@ function Graph3d(container, data, options) {
this.yLabel = 'y';
this.zLabel = 'z';
this.xValueLabel = function(v) { return v; };
this.yValueLabel = function(v) { return v; };
var passValueFn = function(v) { return v; };
this.xValueLabel = passValueFn;
this.yValueLabel = passValueFn;
this.zValueLabel = passValueFn;
this.filterLabel = 'time';
this.legendLabel = 'value';
@ -835,6 +837,7 @@ Graph3d.prototype.setOptions = function (options) {
if (options.xValueLabel !== undefined) this.xValueLabel = options.xValueLabel;
if (options.yValueLabel !== undefined) this.yValueLabel = options.yValueLabel;
if (options.zValueLabel !== undefined) this.zValueLabel = options.zValueLabel;
if (options.style !== undefined) {
var styleNumber = this._getStyleNumber(options.style);
@ -1270,7 +1273,7 @@ Graph3d.prototype._redrawAxis = function() {
ctx.textAlign = 'right';
ctx.textBaseline = 'middle';
ctx.fillStyle = this.colorAxis;
ctx.fillText(step.getCurrent() + ' ', from.x - 5, from.y);
ctx.fillText(this.zValueLabel(step.getCurrent()) + ' ', from.x - 5, from.y);
step.next();
}

Loading…
Cancel
Save