Link to home
Start Free TrialLog in
Avatar of j789
j789Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Vis.js graph3d onclick event

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

Avatar of bugada
bugada
Flag of Italy image

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

Avatar of j789

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of bugada
bugada
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j789

ASKER

Thanks for your help Bugada.
Avatar of j789

ASKER

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
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.