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

Hide labels on databound chart

4 Answers 79 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 26 Nov 2011, 03:27 PM
We have a chart in a report that uses datagroupcolumn to break the data into different series.

Is it possible to remove the series labels? How?

4 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 28 Nov 2011, 06:21 PM
Hi Derek,

Using the DataGroupColumn creates dynamic series and you do not have access to their appearance properties. If you wish to customize the series appearance you should create them with code.

Best wishes,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Derek
Top achievements
Rank 1
answered on 11 Dec 2011, 11:55 PM
Creating the graph in codebehind really isn't a viable option. This is a dynamic chart, so I don't know how many combinations of row/column values I will have.

Is there any way to read the chart items after generation, and turn off or format the labels? Is there any way to apply a 'global' default format to data labels, that would be used for all items regardless of series?

The chart functionality is *almost* there, but this is a showstopper.
0
Elian
Telerik team
answered on 13 Dec 2011, 01:03 PM
Hello Derek,

There is no reason why you can't create the series dynamically. Here's a sample code that groups data and creates chart:
void CreateChartSeries()
        {
            var data = new[]{
                        new {Name = "Item 0", Value = 2, Group = 1},
                        new {Name = "Item 1", Value = 1, Group = 1},
                        new {Name = "Item 2", Value = 3, Group = 1},
                        new {Name = "Item 3", Value = 4, Group = 2},
                        new {Name = "Item 4", Value = 8, Group = 2},
                        new {Name = "Item 5", Value = 5, Group = 2},
                        new {Name = "Item 6", Value = 9, Group = 3},
                        new {Name = "Item 7", Value = 4, Group = 3},
                        new {Name = "Item 8", Value = 9, Group = 3},
                        new {Name = "Item 9", Value = 3, Group = 1},
//we assume that we don't know the structure of the data
                       };
 
            //we already have created chart with styles
            //and properties set as we like
            //just adding the data here
            foreach (var dataItem in data)
            {
                var series = myChart.Series.GetByName(dataItem.Group.ToString());
                if (series == null)
                {
                    series = new ChartSeries(dataItem.Group.ToString());
                    series.Type = ChartSeriesType.Line;
                    series.Appearance.LabelAppearance.Visible = false;
 
                    myChart.Series.Add(series);
                }
                var newItem = new ChartSeriesItem(dataItem.Value, dataItem.Name);
                series.Items.Add(newItem);
            }
        }

See attached image for result. This is a simple approach to grouping (can be done in different ways, other than using the series name as key).

Kind regards,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Derek
Top achievements
Rank 1
answered on 15 Nov 2012, 08:01 PM
Could this approach be used on a chart contained in a report?
Tags
General Discussions
Asked by
Derek
Top achievements
Rank 1
Answers by
Elian
Telerik team
Derek
Top achievements
Rank 1
Share this question
or