Vis.js graph3d onclick event

j789
j789 used Ask the Experts™
on
Hi, has anyone used the vis.js graph3d library? If so do you know how to capture the z value when clicking a bar? Tried the code below in the graph options but doesn't work? Thanks

tooltip: function onclick(point) {
          alert(point.z);
        }

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
In drawVisualization() function you can specify the tooltip option and do what you want inside.

Example

function drawVisualization() {
   var options = {

        // Option tooltip can be true, false, or a function returning a string with HTML contents
        tooltip: function (point) {
             // parameter point contains properties x, y, z, and data
             // data is the original object passed to the point constructor
            alert(point.z);
            return 'value: <b>' + point.z + '</b><br>';
        }
}

Open in new window

Author

Commented:
Thanks for the response Bugada.

Do you know how to make the alert(point.z) trigger when the bar is clicked instead of it being triggered onmouseover?

Thanks
Commented:
oh yes sorry, the correct option is:

function drawVisualization() {
   var options = {

        onclick: function (point) {
            alert(point.z);
        }
}

Open in new window

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Thanks for your help Bugada.

Author

Commented:
Do you know how to control the colour of the bars? For example I would like to show the bars for warehouse a in blue and the bars for warehouse b in red (where the warehouses are on the y axis). Then is possible use a different shade of blue and red to indicate the values. Do you know if this can be done? Thanks

Commented:
Try adding data to dataSet assigning different fieldId depending on the wharehouse. Then using those ids, you can customize the css to give the color you want to bars.

Just my 2 cents, cause I've never done it before.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial