Orka
Orka

Reputation: 1105

Kendo UI chart tooltip and redraw

My problem is as follows:

I want to have a scatterLine chart in Kendo UI where I can both show a tooltip and have a seriesHover effect.

Demo: http://jsfiddle.net/9Lvzu9qh/2/

Comment out line 44: chart.redraw(); to see my issue. If the chart is redrawn, the tooltip is cleared. If the chart is not redrawn, I don't get my highlight effect.

How can I get both the highlight and tooltip? Alternate approaches to solve either problem are also accepted.

Upvotes: 0

Views: 1172

Answers (1)

Juan Marcos Armella
Juan Marcos Armella

Reputation: 737

I made it work saving the previous id and changing color only when i change the serie:

var previousId = 0;
$("#chart").kendoChart({
    title: {
        text: "Line demo (Kendo UI v2014.3.1119)"
    },
    legend: {
        position: "bottom"
    },
    seriesDefaults: {
        type: "scatterLine",
        width: 2,

    },
    series: [{
            name: "A",
            data: [[0,1], [1,2], [2,3]]
        },
        {
            name: "B",
            data: [[0,2], [1,3], [2,5]]
        },
        {
            name: "C",
            data: [[0,3], [1,5], [2,2]]
        }
    ],
    seriesHover : function(e) {

        var chart = e.sender;
        var idx = _.findIndex(chart.options.series, function (s) {
            return s === e.series;
        });
        if(previousId != idx)
            previousId = idx;
        else
            return;
        if (idx >= 0) {
            var thisSeries = chart.options.series[idx];
            // attach event to hovering over a series
            // On hover, set opacity to full and increase width
            // Decrease opacity and width on all other series
            _.each(chart.options.series, function (s) {
                s.width = 2;
                s.opacity = 0.4;
            });

            thisSeries.width = 4;
            thisSeries.opacity = 1;
             $("#chart").data("kendoChart").redraw();




        }
    },
    tooltip: {
        visible: true,
        format: "X: {0} Y: {1}"
    },
    transitions: false
});

Hope it helps.

Fiddle: http://jsfiddle.net/9Lvzu9qh/4/

Upvotes: 3

Related Questions