-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow pass the color of points in 'dot-color' mode of Graph3D explicitly #2489
Conversation
…tly - clear the source code and finalize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thank you for this addition =)
|
Thanks, I will be glad to contribute to the library also in the future :) |
…mer user-defined information for single data point
|
Please, pay an attention to a new feature - onclick callback |
| var y = pow(random(), 2); | ||
| var z = pow(random(), 2); | ||
| var dist = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2)); | ||
| var style; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is better written as:
var style = (i%2==0) ? sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2)) : "#00ffff";There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/graph3d/Graph3d.js
Outdated
| this.emit('cameraPositionChange', parameters); | ||
|
|
||
| util.preventDefault(event); | ||
| //event.stopPropagation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we better do not include unused code
lib/graph3d/Graph3d.js
Outdated
| * @param {event} event The event | ||
| */ | ||
| Graph3d.prototype._onMouseUp = function (event) { | ||
| //this.moving = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we better do not include unused code
| var mouseY = getMouseY(event) - boundingRect.top; | ||
| var dataPoint = this._dataPointFromXY(mouseX, mouseY); | ||
| this.onclick_callback(dataPoint.point.data); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the curly braces.
lib/graph3d/Graph3d.js
Outdated
| borderColor = point.point.value; | ||
| } | ||
| else { | ||
| var hue = (1 - (point.point.value - this.valueRange.min) * this.scale.value) * 240; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like the ident is not correct here.
lib/graph3d/Graph3d.js
Outdated
| var ontouchstart = function (event) {me._onTouchStart(event);}; | ||
| var onmousewheel = function (event) {me._onWheel(event);}; | ||
| var ontooltip = function (event) {me._onTooltip(event);}; | ||
| var onclick = function(event) {me._onClick(event);} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing semicolon at the end of the line.
| var graph = null; | ||
|
|
||
| function onclick(point) { | ||
| console.log(point); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sometimes point is null is you click outside the chart. This should be handled in the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, it locates the closest point and returns it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed this issue - sorry for not noticing that case before
| var graph = null; | ||
|
|
||
| function onclick(point) { | ||
| console.log(point); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@mojoaxel Can you review this again? The error has been solved |
|
|
||
|
|
||
| /** | ||
| * Get legend width |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment for the next time: Please do not change code-style of other people. This messes up the "git blame".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, it was done automatically by my WebStorm, sorry for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely no problem! I actually had the same problem with my last commit. :-)
| var boundingRect = this.frame.getBoundingClientRect(); | ||
| var mouseX = getMouseX(event) - boundingRect.left; | ||
| var mouseY = getMouseY(event) - boundingRect.top; | ||
| var dataPoint = this._dataPointFromXY(mouseX, mouseY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said before. Please use curly brackets next time to improve readability and security.
In Graph3D 'dot-color' mode, an addition option has been added - to explicitly set the data point color:
Now the color may be set as a string representation of HTML color, like #ff00ff,
or calculated from a number, for example, distance from this point
The first option is useful when we have some pre-given legend, to which we have to adjust ourselves
The second option is useful when we are interested in automatically setting the color, from some value,
using some color scale