@ -24,6 +24,11 @@
// Create and populate a data table.
// Create and populate a data table.
data = new vis.DataSet();
data = new vis.DataSet();
var extra_content = [
'Arbitrary information',
'You can access data from the point source object',
'Tooltip example content',
];
// create some nice looking data with sin/cos
// create some nice looking data with sin/cos
var steps = 5; // number of datapoints will be steps*steps
var steps = 5; // number of datapoints will be steps*steps
@ -34,10 +39,10 @@
var z = custom(x,y);
var z = custom(x,y);
if (withValue) {
if (withValue) {
var value = (y - x);
var value = (y - x);
data.add({x:x, y:y, z: z, style:value});
data.add({x:x, y:y, z: z, style:value, extra: extra_content[(x*y) % extra_content.length] });
}
}
else {
else {
data.add({x:x, y:y, z: z});
data.add({x:x, y:y, z: z, extra: extra_content[(x*y) % extra_content.length] });
}
}
}
}
}
}
@ -55,8 +60,9 @@
// Option tooltip can be true, false, or a function returning a string with HTML contents
// Option tooltip can be true, false, or a function returning a string with HTML contents
//tooltip: true,
//tooltip: true,
tooltip: function (point) {
tooltip: function (point) {
// parameter point contains properties x, y, z
return 'value: < b > ' + point.z + '< / b > ';
// parameter point contains properties x, y, z, and data
// data is the original object passed to the point constructor
return 'value: < b > ' + point.z + '< / b > < br > ' + point.data.extra;
},
},
keepAspectRatio: true,
keepAspectRatio: true,