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

Displaying data in my line serie on mousehover

3 Answers 51 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
EssMus
Top achievements
Rank 1
EssMus asked on 28 Apr 2015, 04:33 PM

hi,
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();
con.Open();
if (DS.Tables.Contains("TRChart"))
{
DS.Tables.Remove("TRChart");
}
SqlDataAdapter da = new SqlDataAdapter(req, con);
da.Fill(DS, "TRChart");
con.Close();

RadHtmlChart chart = new RadHtmlChart();

chart.DataSource = DS.Tables["TRChart"];
chart.DataBind();

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";
chart.PlotArea.Series.Add(LS);

PlaceHolder3.Controls.Add(chart);


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


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

3 Answers, 1 is accepted

Sort by
0
Accepted
Danail Vasilev
Telerik team
answered on 30 Apr 2015, 01:06 PM
Hello Essoufi,

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

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

C#:
protected void Page_Load(object sender, EventArgs e)
{
    RadHtmlChart1.DataSource = GetData();
    RadHtmlChart1.DataBind();
}
 
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;
}



Regards,
Danail Vasilev
Telerik
 

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

 
0
EssMus
Top achievements
Rank 1
answered on 30 Apr 2015, 01:19 PM

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

0
EssMus
Top achievements
Rank 1
answered on 30 Apr 2015, 01:47 PM

hi Danail Vasilev,

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

Tags
Chart (HTML5)
Asked by
EssMus
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
EssMus
Top achievements
Rank 1
Share this question
or