Talasan Nicholson
Talasan Nicholson

Reputation: 23

How do ya add a custom tooltip to Dojox charts?

Say I have this:

        var chart1 = new dojox.charting.Chart2D("traffic");
    chart1.addPlot("default", {type: "Columns", gap: "15"});
    chart1.addAxis("x", {minorTicks: false, font: "normal normal bold 9pt Arial",
    labels: [{value: 1, text: 'Monday'},{value: 2, text: 'Tuesday'},{value: 3, text: 'Wednesday'},{value: 4, text: 'Thursday'},{value: 5, text: 'Friday'},{value: 6, text: 'Saturday'},{value: 7, text: 'Sunday'}]});
    chart1.addAxis("y", {vertical: true, minorTicks: false, min: 0, font: "normal normal bold 12pt Arial"});
    chart1.addSeries("Series 1", [<?php echo $trafficseries; ?>]);
    chart1.setTheme(dojox.charting.themes.PlotKit.blue);
    chart1.addPlot("Grid", {
        type: "Grid",
        hAxis: "x",
        vAxis: "y",
        hMajorLines: true,
        hMinorLines: false,
        vMajorLines: false,
        vMinorLines: false
    });
    var anim_t = new dojox.charting.action2d.Tooltip(chart1, "default");
    chart1.render();

How would I change that tooltip to say what I need it to say? I need to put X data there.

Upvotes: 0

Views: 2723

Answers (2)

Guangming Dong
Guangming Dong

Reputation: 1

You can,new Tooltip(chart1,"default",{text: function(o){return o.y + "M/s";}});,custom text value set a function.

Upvotes: 0

djboss
djboss

Reputation: 205

This can be done by adding a tooltip value to the series data:

chart1.addSeries("Series 1", [{x:1,y:4,tooltip:"Value is 1"},{x:2,y:6,tooltip:"Value is 2"}]);

Upvotes: 2

Related Questions