This is a migrated thread and some comments may be shown as answers.

Tooltip Position

15 Answers 596 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James
Top achievements
Rank 1
James asked on 11 Jan 2012, 08:37 PM
My column chart is positioned near the edge of the screen.  Tooltips will display partially off the screen creating a horizontal scrollbar.

I'd like to be able to set the tooltips to display to the left of the bar (rather than to the right) to prevent this.

15 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 12 Jan 2012, 05:49 PM
Hi,

The Tooltip does not provide much control over its position. We'll fix this in future releases, but for the moment you can move it a fixed amount of pixels to the left by using:

.k-chart > div {
    margin-left: -30px;
}

I hope this helps.

Kind regards,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
iConect Developer - Mike
Top achievements
Rank 1
answered on 01 Feb 2012, 10:25 PM
Is it possible to just shorten the distance of the tooltips to be 'on the piece' instead of outside of it?
0
T. Tsonev
Telerik team
answered on 02 Feb 2012, 04:38 PM
Hi,

Do you mean the center of the data point - bar, line point, etc.? This is not possible right now and I'm not sure it'll work well.

In some scenarios the tooltip will open directly below the mouse and you'll need to move outside of the tooltip in order to select another point. This can get tedious when the points are close nearby.

Or do you have something else in mind?

Regards,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Paul
Top achievements
Rank 1
answered on 23 Oct 2012, 02:52 PM
Has this been fixed in the Kendo Dataviz pie chart?

The solution you presented will move all of the tooltips to the right. I am looking for a solution to move all of the tooltips inward towards the middle of the pie.

A potential solution for me would be to attach to the hover event and then reset the tooltip's position. Is there any way to attach to the hover event of a pie slice?

Any other solutions to this problem? Thanks for your time.
See the attached image.
0
Paul
Top achievements
Rank 1
answered on 23 Oct 2012, 08:27 PM
Here's my temporary solution, if anyone is interested:

            // Reset Labels on Hover!
            $(chartId + " path").bind("mouseover", function (e) {

                setTimeout(function () {    // Need a Delay
                    $(".k-chart > div").each(function (i, id) {

                        var topMax = 150, topMin = 30;
                        var leftMax = 150, leftMin = -30;

                        var useId = $(id);
                        var top = useId.position().top;
                        var left = useId.position().left;

                        //console.log("top:" + top + " left:" + left);
                        var goTop = "";
                        var goLeft = "";
                        if (top > topMax)
                            goTop = topMax + "px";
                        else if (top < topMin)
                            goTop = topMin +"px";

                        if (left > leftMax)
                            goLeft = leftMax + "px";
                        else if (left < leftMin)
                            goLeft = leftMin +"px";

                        if (goTop != "") {
                            useId.animate({
                                top: goTop
                            }, 200, function () {
                                useId.css({ top: goTop });
                            });
                        }

                        if (goLeft != "") {
                            useId.animate({
                                left: goLeft
                            }, 200, function () {
                                useId.css({ left: goLeft });
                            });
                        }

                    });

                }, 350);
            });
0
Iliana Dyankova
Telerik team
answered on 25 Oct 2012, 08:54 AM
Hello Paul,

I am glad to inform you that the tooltip issue is already removed - please test your application using the latest version of Kendo UI and let me know if you still observe any problems.
 
Regards,
Iliana Nikolova
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Ane
Top achievements
Rank 1
answered on 06 Nov 2012, 05:57 PM
Hi Iliana,

do you know if this is fixed for Kendo UI Chart? I'm not able to find a fix for this in UI.

Thanks,
0
Iliana Dyankova
Telerik team
answered on 07 Nov 2012, 04:28 PM
Hello Ane,

As I pointed in my previous post, the tooltip issue is already addressed (in the latest version of Kendo UI). Do you observe the same problem? If yes, could you please specify which version of Kendo UI do you use? 
 
Regards,
Iliana Nikolova
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Ane
Top achievements
Rank 1
answered on 07 Nov 2012, 04:33 PM
I'm using Kendo UI Web v2012.2.710 (http://kendoui.com).

Thanks,
0
Iliana Dyankova
Telerik team
answered on 08 Nov 2012, 03:05 PM
Hi Ane,

The fix for the tooltip issue is available in Kendo UI v2012.2.913, which is later than the version you use.
 
Regards,
Iliana Nikolova
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Ane
Top achievements
Rank 1
answered on 08 Nov 2012, 06:20 PM
Hi Iliana,

I've just updated my kendo UI version to 2012.2.913 and, I notice that the issue it seems to be fixed for stacked bar charts, but not for column charts or unstacked bar charts.

Attached you can find some screenshots. As you can see all these files are the ones you can get from the examples folder. The only update that I did is set the template for the tooltip (template: "This is a looooooooooong tooltip").

Also I'd like to mention that I tried this in IE8, IE9 and Chrome, with the same luck.

Please let me know if I'm doing something wrong, or if is just not fixed for these scenarios.

Thanks,
0
Iliana Dyankova
Telerik team
answered on 09 Nov 2012, 05:44 PM
Hi Ane,

Thank you for the provided screenshots. Actually the issue I and Paul were discussing is different and is related to the pie chart. The behavior you have observed with the bar chart is expected. I am afraid at this point there is no built-in option in Kendo UI Chart for modifying the tooltip position. As a possible workaround I can suggest to set margin to the tooltip: 
.k-tooltip {
  margin-left: -200px;
}​

Another option is to set the tooltip visibility to false. Then in the seriesHover event call a function and make the tooltip visible with a custom position:
<script>
$("#chart").kendoChart({
  //....
  tooltip: {
     visible: false
  },
  seriesHover: showTheTooltip
});
  
function showTheTooltip(e) {
    $("#chart .k-tooltip").html(kendo.format(e.series.tooltip.format, e.value) + " - " + e.category).show();
}
</script>
 
<style>
.k-tooltip{
  //custom position
}
</style>
   
Regards,
Iliana Nikolova
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Ane
Top achievements
Rank 1
answered on 16 Nov 2012, 12:23 AM
Hello Iliana,

thanks for you reply. I tried your solutions but didn't like it, because in the first case the problem is now moved to the left (and is even worse because you don't have a scrollbar there) :)

So I created a generic solution :)

The issue is fixed adding these lines to the kendo.dataviz.js file (line 15448):

anchor = point.tooltipAnchor(element.outerWidth(), element.outerHeight());
top = round(anchor.y + chartPadding.top) + "px";
  
// ---------------------------------------------------------
// Added by ANE to fix the tooltip issue out of screen X
var leftValue = round(anchor.x + chartPadding.left);
  
var chartElement = element[0].parentElement;
// maxX: max value for X point to be inside the chart
var maxX = chartElement.offsetLeft + chartElement.offsetWidth;
// maxXTooltip: max value for X point for the tooltip element
var maxXTooltip = leftValue + tooltip.element[0].clientWidth;
// if is out of the chart
if (maxXTooltip > maxX) {
    // move it to the left to keep it inside (10 is for padding, margin...)
    leftValue = maxX - 10 - tooltip.element[0].clientWidth;
}
  
left = leftValue + "px";
// ---------------------------------------------------------
  
if (!tooltip.visible) {
    tooltip.element.css({ top: top, left: left });
}

I tested in columns and lines charts and it is working great. See attachments.

I hope you like it, and looking forward to be added in next relesease :)

Thanks!

NOTE: The value 10 I put it fixed because I know how many pixels I need in my case, but it can be calculated.

 

0
Iliana Dyankova
Telerik team
answered on 20 Nov 2012, 12:58 PM
Hi Ane,

Thank you for shared your solution with us and the community - we will consider it and will do our best to implement the described functionality as soon as possible.  

Regards,
Iliana Nikolova
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Bil
Top achievements
Rank 1
answered on 17 Jan 2013, 08:56 AM
Thanks Ane!
Tags
Chart
Asked by
James
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
iConect Developer - Mike
Top achievements
Rank 1
Paul
Top achievements
Rank 1
Iliana Dyankova
Telerik team
Ane
Top achievements
Rank 1
Bil
Top achievements
Rank 1
Share this question
or