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

Series Item Label in a Spline Chart

7 Answers 164 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jaymie
Top achievements
Rank 1
Jaymie asked on 07 Apr 2010, 03:34 PM
Good afternoon,
I hope you can help me (should be easy really). I have built a spline chart which is bound to an ever changing datasource.
What I need to do is remove the Series items label values, because they are obstructing the chart itself.
I have this code:

But for some reason the labels stay, which is really annoying. Could someone tell me what I am doing wrong?

 
Private Sub Chart1_NeedDataSource(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Chart1.NeedDataSource
        Dim myImpersonate As New AliasAccount("administrator", "", "")
        myImpersonate.BeginImpersonation()

        DirectCast(sender, Telerik.Reporting.Processing.Chart).DataSource = myDataSource
        ClearLabels()

        myImpersonate.EndImpersonation()
    End Sub

    Private Sub ClearLabels()
        For Each c As ChartSeries In Chart1.Series
            For Each item As ChartSeriesItem In c.Items
                item.Label.TextBlock.Text = ""
            Next
        Next
    End Sub
End Class

7 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 12 Apr 2010, 11:30 AM
Hello Jaymie,

In order to hide the ChartSeries items' labels you have to modify your ClearLabels() method as shown in the following code snippet:

Private Sub ClearLabels()
        For Each c As ChartSeries In Chart1.Series
          c.DefaultLabelValue = String.Empty
        Next
    End Sub


Best wishes,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jaymie
Top achievements
Rank 1
answered on 13 Apr 2010, 12:26 PM
That didnt work for me, this is my code:

 
 
    Private Sub Chart1_NeedDataSource(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Chart1.NeedDataSource 
        Dim myImpersonate As New AliasAccount("administrator""amdb9p911""thorntonross"
        myImpersonate.BeginImpersonation() 
 
        DirectCast(sender, Telerik.Reporting.Processing.Chart).DataSource = myDataSource 
        ClearLabels() 
 
        myImpersonate.EndImpersonation() 
    End Sub 
 
    Private Sub ClearLabels() 
        For Each c As ChartSeries In Chart1.Series 
            c.DefaultLabelValue = String.Empty 
        Next 
    End Sub 

and I have attached an image so you can see what is happening.
While we are on the topic, how do I change the spline colors and is there a way to remove the Weeks spline off the legend and the graph? I wanted to use Weeks for the X-Axis, but not to appear on the graph.


0
Peter
Telerik team
answered on 16 Apr 2010, 03:08 PM
Hello Jaymie,

There isn't out of the box solution for customizing the Chart item when it's automatically bound. You would need to create the chart programmatically in order to have full control over it.

Check out the following help articles:
Creating Chart Programmatically
Creating Chart Programmatically - more complex example 
Styling Chart Elements
How Do I add Axis Labels Programmatically?

Greetings,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jaymie
Top achievements
Rank 1
answered on 19 Apr 2010, 11:38 AM
OK so now I am trying to create the graph programatically and it isn't working.
I have some code (which you can see below) but the chart just says "There is no or empty series".
I have stepped through my code and their are definately values being passed and the series are being created.
If I do a messagebox.show(pChart.Series.Count) I get more than 0, so there is a series collection.
Can you tell me what I am missing for the code below please.

I really wish your documentation was better as I always find it difficult to do things that should be simple...

    Public Shared Sub ReturnSalesTrendChart(ByVal pDatasource As DataTable, ByVal pChart As Telerik.Reporting.Chart) 
        For Each pColumn As DataColumn In pDatasource.Columns 
            ' Add the column 
            Dim chartSeries As New ChartSeries() 
            chartSeries.Appearance.LabelAppearance.Visible = False 
            chartSeries.Name = pColumn.ColumnName 
            chartSeries.Type = ChartSeriesType.Line 
            chartSeries.Appearance.LineSeriesAppearance.Color = System.Drawing.Color.BlueViolet 
            For Each pRow As DataRow In pDatasource.Rows 
                ' Add the Value 
                Try 
                    Dim pValue As Integer = pRow(pColumn.ColumnName).ToString 
                    chartSeries.AddItem(pValue) 
                Catch ex As Exception 
                    chartSeries.AddItem(0) 
                End Try 
            Next 
            pChart.Series.Add(chartSeries) 
        Next 
        pChart.PlotArea.XAxis.AutoScale = False 
        pChart.PlotArea.XAxis.AddRange(1, 5, 1) 
        pChart.PlotArea.XAxis(0).TextBlock.Text = "Week 1" 
        pChart.PlotArea.XAxis(1).TextBlock.Text = "Week 2" 
        pChart.PlotArea.XAxis(2).TextBlock.Text = "Week 3" 
        pChart.PlotArea.XAxis(3).TextBlock.Text = "Week 4" 
        pChart.PlotArea.XAxis(4).TextBlock.Text = "Week 5" 
    End Sub 

0
Jaymie
Top achievements
Rank 1
answered on 20 Apr 2010, 04:32 PM
just so people on the forums know, I submitted a ticket and have been told that this is a bug that has been fixed with the new version, which I am currently installing now :)
0
Tim Estrada
Top achievements
Rank 1
answered on 24 Sep 2010, 04:13 PM
Hello Peter,

I am trying to eliminate the labels on a spline area chart.  I am using 2010 Q1and I just cnnot get the labels to disappear.  I would appreciate it if you could provide me the similar/equivalent code in c# to eliminate the labels on the chart.

Sincerely,
Tim
0
Peter
Telerik team
answered on 27 Sep 2010, 04:18 PM
Hi Tim Estrada,

This is the method from my previous post. Give it a try and let us know how it goes.

private void ClearLabels()
{
    foreach (ChartSeries c in Chart1.Series)
  {
        c.DefaultLabelValue = string.Empty;
    }
}

Additionally we maintain a free Code Converter, which you can always use to convert code if you have found examples in VB. I have converted the example to C# for your convenience and verified it works with no exceptions.


Kind regards,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Jaymie
Top achievements
Rank 1
Answers by
Peter
Telerik team
Jaymie
Top achievements
Rank 1
Tim Estrada
Top achievements
Rank 1
Share this question
or