Custom ChartTooltipBehaviour

Thread is closed for posting
2 posts, 0 answers
  1. Elton
    Elton avatar
    3 posts
    Member since:
    Jul 2014

    Posted 21 Jul 2014 Link to this post


    I can set the default tooltip as following, but I need to have a custom one consisting of data from both X-axis (DateTimeContinuousAxis)  and Y-axis (LinearAxis). Can you please provide with an example?

    ChartTooltipBehavior tooltipBehavior = new ChartTooltipBehavior(this);

  2. Antony Jekov
    Antony Jekov avatar
    88 posts

    Posted 23 Jul 2014 Link to this post

    Hi Elton,

    Thanks for writing.

    The default behavior of the tooltip is to display both the category and the value of the selected data point. You don't need to customize it to achieve that.

    The problem you are facing, I assume, is that you cannot see the tooltip at all, which might be a result of having a Calendar for category. If you are using some sort of date time axis you will be in this scenario.

    You need to provide a way for the Calendar to be translated to String, so that the tooltip knows what to do with it, since the Calendar is a bit more specific that the other value types.

    You can use something like this:
    ChartTooltipBehavior tooltipBehavior = new ChartTooltipBehavior(this);
            tooltipBehavior.contentAdapter().setCategoryToStringConverter(new Function<Object, String>() {
                SimpleDateFormat format = new SimpleDateFormat("MMM dd");
                public String apply(Object argument) {
                    return format.format(((Calendar) argument).getTime());
    You can set whatever format you want this way.

    Please let me know if this works for you. I hope it answers your question, but please feel free to add to this ticket should you need any further assistance.

    Thank you for your time and all best!

    Antony Jekov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top