Displaying data in my line serie on mousehover

4 posts, 1 answers
  1. EssMus
    EssMus avatar
    18 posts
    Member since:
    Jan 2015

    Posted 28 Apr 2015 Link to this post

    im using control rahhtml chart telerik in my project this is my code 

    SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=DB_WEB_Q_TEL;Integrated Security=True");
    string req = "select time_tag,[ain_sebou|Niveau] as AIN_SEBOU_NIVEAU from QTSW_DATA1 where time_tag between ('01/01/2015') AND ('10/01/2015')";
    DataSet DS = new DataSet();
    if (DS.Tables.Contains("TRChart"))
    SqlDataAdapter da = new SqlDataAdapter(req, con);
    da.Fill(DS, "TRChart");

    RadHtmlChart chart = new RadHtmlChart();

    chart.DataSource = DS.Tables["TRChart"];

    LineSeries LS = new LineSeries();
    LS.DataFieldY = "AIN_SEBOU_NIVEAU";
    LS.TooltipsAppearance.DataFormatString = "{0} at {1}";

    chart.PlotArea.XAxis.LabelsAppearance.DataFormatString = "{0:dd-MM-yyyy HH:mm}";
    chart.PlotArea.XAxis.LabelsAppearance.RotationAngle = 90;

    chart.PlotArea.XAxis.BaseUnit = Telerik.Web.UI.HtmlChart.DateTimeBaseUnit.Days;
    chart.PlotArea.XAxis.DataLabelsField = "time_tag";


    <asp:PlaceHolder ID="PlaceHolder3" runat="server">

    i want to display for example ( 230 at 01/01/2015 00:00 ) 
    plzz i need help

  2. Answer
    Danail Vasilev
    Danail Vasilev avatar
    1476 posts

    Posted 30 Apr 2015 Link to this post

    Hello Essoufi,

    You can show the value and the category in the label/tooltip either through template or through the DataFormatString. For example:

    <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="640px" Height="480px">
                        <telerik:LineSeries DataFieldY="SellQuantity">
                            <LabelsAppearance DataFormatString="{1} cars sold on {0:m}">
                            <TooltipsAppearance Color="White" DataFormatString="{1} cars sold on<br/>{0:D}" />
                    <XAxis BaseUnit="days" DataLabelsField="SellDate">
                        <TitleAppearance Text="Sell Date">
                        <LabelsAppearance DataFormatString="d">
                        <MajorGridLines Color="#EFEFEF" Width="1"></MajorGridLines>
                        <MinorGridLines Color="#F7F7F7" Width="1"></MinorGridLines>
                        <TitleAppearance Text="Quantity">
                        <MajorGridLines Color="#EFEFEF" Width="1"></MajorGridLines>
                        <MinorGridLines Color="#F7F7F7" Width="1"></MinorGridLines>
                <ChartTitle Text="Sold Cars per Date">

    protected void Page_Load(object sender, EventArgs e)
        RadHtmlChart1.DataSource = GetData();
    protected DataTable GetData()
        DataTable dt = new DataTable();
        dt.Columns.Add("ID", typeof(int));
        dt.Columns.Add("SellQuantity", typeof(int));
        dt.Columns.Add("SellDate", typeof(DateTime));
        dt.Rows.Add(1, 2, new DateTime(2014, 11, 12));
        dt.Rows.Add(2, 5, new DateTime(2014, 11, 13));
        dt.Rows.Add(3, 6, new DateTime(2014, 11, 17));
        dt.Rows.Add(4, 4, new DateTime(2014, 11, 18));
        dt.Rows.Add(5, 7, new DateTime(2014, 11, 19));
        return dt;

    Danail Vasilev

    See What's Next in App Development. Register for TelerikNEXT.

  3. DevCraft R3 2016 release webinar banner
  4. EssMus
    EssMus avatar
    18 posts
    Member since:
    Jan 2015

    Posted 30 Apr 2015 in reply to Danail Vasilev Link to this post

    hello Danail Vasilev,

    thank you for answering me i want to ask you question if possible to add DataFormatString for any type of chart !!!

    and thank you

  5. EssMus
    EssMus avatar
    18 posts
    Member since:
    Jan 2015

    Posted 30 Apr 2015 Link to this post

    hi Danail Vasilev,

    i execute code wich you have post it and it's not work !!!

Back to Top