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

Line chart - hide labels

6 Answers 198 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
JT
Top achievements
Rank 1
JT asked on 19 Apr 2011, 01:50 PM
Hi,
I am putting together a line chart to display data from a MSSQL database but cannot stop the numerical score labels from displaying. I have gone through all of the examples but need a little assistance. Please take a look at what I have and add what I need to stop the scores from rendering on the lines. I have attached images of existing render and table.
I appreciate your time.

<asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:IPdataConnectionString %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT top 7 Date = CONVERT(char(10), Date, 101), score, IPaddress, Partner FROM IPhistory WHERE Partner = 'NEAstates' ORDER BY Date ASC;" runat="server">
</asp:SqlDataSource>
            <telerik:radchart id="RadChart4" runat="server" width="800px" datasourceid="SqlDataSource1"
                defaulttype="Line" autolayout="true" charttitle-visible="false">
                <Appearance TextQuality="AntiAlias">
                </Appearance>
                <PlotArea>
                <Appearance Dimensions-Margins="18%, 24%, 12%, 16%"></Appearance>
                    <YAxis Step="10" AxisMode="Extended">
                        <Appearance MajorGridLines-Visible="true" MinorGridLines-Visible="false">
                        </Appearance>
                    </YAxis>
                    <XAxis DataLabelsColumn="Date" LayoutMode="Between">
                        <Appearance ValueFormat="ShortDate" MajorGridLines-Visible="true">
                            <LabelAppearance RotationAngle="10" Position-AlignedPosition="Top">
                            </LabelAppearance>
                        </Appearance>
                    </XAxis>
                </PlotArea>
            </telerik:radchart>

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        // Manually setting the series groups and Y values columns
        RadChart4.DataGroupColumn = "IPaddress";
        RadChart4.DataManager.ValuesYColumns = new string[1] { "score" };
        RadChart4.Skin = "LightBlue";
        ChartSeries chartSeries = new ChartSeries();
        chartSeries.Type = ChartSeriesType.Line;
        chartSeries.Appearance.LabelAppearance.Visible = false;
    }
}


6 Answers, 1 is accepted

Sort by
0
Dean
Top achievements
Rank 2
answered on 20 Apr 2011, 08:24 PM
Hi JT,

Have you tried chartSeries.Appearance.ShowLabels = False;
0
JT
Top achievements
Rank 1
answered on 20 Apr 2011, 09:04 PM
Hi Dean,
Yes, I have tried every Label tag available. I am thinking it has something to do with RadChart rewriting the chartSeries but I do not think I have the new chartSeries setup to initialize properly.

Thanks,
_ JT
0
Dean
Top achievements
Rank 2
answered on 21 Apr 2011, 06:22 AM
Hi JT,

Before the chart gets rendered and automatically generates the series for you, you will have to set the labels visibility for each series in your code-behind. Here is how you can achieve this,

private void RadChart1_PreRender(object sender, System.EventArgs e)
{
    Telerik.Web.UI.RadChart oChart = (Telerik.Web.UI.RadChart)sender;
    for (i = 0; i <= oChart.Series.Count - 1; i++) {
        oChart.Series.Item(i).Appearance.ShowLabels = false;
    }
}
0
JT
Top achievements
Rank 1
answered on 21 Apr 2011, 04:15 PM
Thanks Dean,
I see where you are going with the series setting but I am falling short on pluging it into my C# code-behind. I do not have any Items defined in the code I provided and am having difficulty getting it recognized. Is it possible to get my code enhanced with any additional modifications needed to get the PreRender to function. I appreciate your time.
0
Dean
Top achievements
Rank 2
answered on 21 Apr 2011, 07:46 PM
Hi JT,

I've created a sample project with the same data you are using as well as the code you are using which I've modified allow the labels visibility to be false, please look at the sample project. I've uploaded it to a public area so you should be able to download it.

Please notice the property in the ASP.NET Markup for the Chart_PreRender OnPreRender="RadChart4_PreRender"

Excuse my c# code, I'm a vb developer.

http://www.mediafire.com/?z2910uihx6lpwvf

Hope this helps.
0
JT
Top achievements
Rank 1
answered on 22 Apr 2011, 04:56 PM
Hi Dean,
That did the trick! I just had not cleaned out the old ChartSeries references when I added your PreRender script the other day.
Good to go!

Thanks,
_ JT
Tags
Chart (Obsolete)
Asked by
JT
Top achievements
Rank 1
Answers by
Dean
Top achievements
Rank 2
JT
Top achievements
Rank 1
Share this question
or