Welcome Guest Search | Active Topics |

Custom Tooltips
Derek
#1 Posted : Friday, October 5, 2012 4:34:55 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 10/5/2012(UTC)
Posts: 2

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

First I want to say that jqChart for ASP.NET Web Forms is fantastic!!! We really enjoy the ability to create HTML5 chart application with ASP.NET.

The thing I want to ask you is what is the ability to customize the chart tooltips?


Derek
Dragan
#2 Posted : Saturday, October 6, 2012 1:09:53 PM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

Thank you for your kind and supportive words.

The tooltips can be fully customized with "tooltipFormat" client-side event. You can check these samples:

http://www.jqchart.com/SamplesAspNet
http://www.jqchart.com/SamplesAspNet/ChartFeatures/Tooltips
Best Regards,
Dragan Matek
jqChart Inc.
yelkereb
#3 Posted : Thursday, November 15, 2012 7:19:47 PM(UTC)
Rank: Newbie

Groups: MvcChart, Registered, WebFormsChart
Joined: 11/15/2012(UTC)
Posts: 4

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I'm able to customize the tooltip but it's showing up behind the columns in the column chart. I've tried wrapping it in a div and pushing the z-index up but no luck. Ideas?
Dragan
#4 Posted : Friday, November 16, 2012 2:18:46 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

You need to include the "jquery.jqChart.css" file, which comes with the jqChart package. It sets the tooltip z-index.
Best Regards,
Dragan Matek
jqChart Inc.
yelkereb
#5 Posted : Friday, November 16, 2012 11:10:27 AM(UTC)
Rank: Newbie

Groups: MvcChart, Registered, WebFormsChart
Joined: 11/15/2012(UTC)
Posts: 4

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
It is included, but I still see the issue. I've included the CSS I tried to inject as well inline. Here's my code:

Code:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SimpleAppForTesting._Default" %>

<%@ Register assembly="JQChart.Web" namespace="JQChart.Web.UI.WebControls" tagprefix="jqChart" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <link rel="stylesheet" type="text/css" href="~/Styles/jquery.jqChart.css" />
    <link rel="stylesheet" type="text/css" href="~/Styles/jquery.jqRangeSlider.css" />
    <link rel="stylesheet" type="text/css" href="~/Styles/themes/base/jquery.ui.theme.css" />

    <script src="<% = ResolveUrl("~/Scripts/jquery-1.6.3.js") %>" type="text/javascript"></script>
    <script src="<% = ResolveUrl("~/Scripts/jquery.jqRangeSlider.min.js") %>" type="text/javascript"></script>
    <script src="<% = ResolveUrl("~/Scripts/jquery.jqChart.min.js") %>" type="text/javascript"></script>
    <!--[if IE]><script lang="javascript" type="text/javascript" src="<% = ResolveUrl("~/Scripts/excanvas.js") %>"></script><![endif]-->

    <style type="text/css">
    .ToolTip
    {
        padding: 3px;
        background:white;
        color: Black;
        z-index: 1000;
        border: 1px solid;
    }
    </style>

</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        var chartName = '#<%= MonthlyChart.ClientID %>';

        $(chartName).bind('tooltipFormat', function (e, data) {
            return "<div class='ToolTip'>Billing Date: " + data.x + "<br/>" +
                   "kWh Usage: " + data.y + "<br/></div>";
        });
    });
</script>


        <jqChart:Chart ID="MonthlyChart" runat="server" Width="750px" Height="400px">
        <Title Text="My Electricity Use by Billing Period"></Title>
        <Border StrokeStyle="emboss" />
        <Background FillStyleType="LinearGradient" X1="0">
            <ColorStops>
                <jqChart:ColorStop Color="#F2DCBB" />
                <jqChart:ColorStop Color="white" Offset="1" />
            </ColorStops>
        </Background>
        <ChartAreaBackground Color="#FEF7EA">
        </ChartAreaBackground>
        <Legend Location="Bottom" Border-Visible="false" Margin="15">
        <CustomItems>
            <jqChart:LegendItem>
                <Text Text="Off Peak Usage"></Text>
                <Marker>
                    <FillStyle Color="#F4C065"></FillStyle>
                </Marker>
            </jqChart:LegendItem>
            <jqChart:LegendItem>
                <Text Text="Pre-Smart Meter data"></Text>
                <Marker>
                    <FillStyle Color="#B9DEEA"></FillStyle>
                </Marker>
            </jqChart:LegendItem>
        </CustomItems>
        </Legend>
        <Axes>
            <jqChart:LinearAxis Location="left" ExtendRangeToOrigin="true">
                <Title Text="KWh - Kilowatt Hours"></Title>
            </jqChart:LinearAxis>
            <jqChart:CategoryAxis CategoriesField="BillPeriodEndDate" Location="Bottom">
                <Labels Angle="-45"></Labels>
            </jqChart:CategoryAxis>
        </Axes>

        <Series>
            <jqChart:ColumnSeries YValuesField="TotalUse" Title="Monthly Total Usage">
                <FillStyle Color="#F4C065"></FillStyle>
                <%-- <Markers LineWidth="1" StrokeStyle="Black" MarkerType="Rectangle"></Markers> --%>
            </jqChart:ColumnSeries>
            <jqChart:ColumnSeries YValuesField="OffPeakUse">
                <%-- <Markers LineWidth="1" StrokeStyle="Black" MarkerType="Rectangle"></Markers> --%>
            </jqChart:ColumnSeries>
        </Series>
    </jqChart:Chart>
</asp:Content>
Dragan
#6 Posted : Friday, November 16, 2012 11:54:37 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Is it possible to send us your whole sample via email ( support@jqchart.com ), so we can investigate it?
Best Regards,
Dragan Matek
jqChart Inc.
yelkereb
#7 Posted : Friday, November 16, 2012 1:35:25 PM(UTC)
Rank: Newbie

Groups: MvcChart, Registered, WebFormsChart
Joined: 11/15/2012(UTC)
Posts: 4

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I figured out the issue was that I wasn't using ResolveUrl() and so the CSS wasn't actually loading. I do have another tool tip question now though. If you wanted to add other data to the tool tip that is in the model but not graphed is there a method for that?

The easiest thing I could come up with was to iterate through the data set and look for a matching value to find the index, then pass in an array from the code behind and use that index. I was able to get that working but if I ever had a duplicate value then I would get a mismatched index and so that isn't really a solution. I know I could also build a web service that would accept my Y value, which in my case would be unique, and return the context values but that seems cumbersome. I was hoping I was just missing something.
Dragan
#8 Posted : Monday, November 19, 2012 7:46:19 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
We’re adding a standard way to pass custom values to the jqChart, which can be used in the client-side events (tooltipFormat, dataPointMouseDown, …). This will be available in next version.

I’ve sent you a working version, which supports this functionality via email.
Best Regards,
Dragan Matek
jqChart Inc.
Users browsing this topic
Guest (4)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.139 seconds.