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

Numeric labels in charts

6 Answers 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
MatFindlay
Top achievements
Rank 1
MatFindlay asked on 04 Jan 2008, 02:52 PM
Hey, there. I'm working on a report which incorporates charts, and binding the data to the charts with the following method:

private void ByDateChart_NeedDataSource(object sender, System.EventArgs e)
        {
            Telerik.Reporting.Processing.Chart chart = sender as Telerik.Reporting.Processing.Chart;
           
            DataRowView dataItem = (DataRowView)chart.DataItem;
            sqlDataAdapter1.Fill(dataSet);
            DataView view = dataSet.Tables[0].DefaultView;
            chart.DataSource = view;           
           
            ByDateChart.PlotArea.XAxis.MaxItemsCount = view.Count;
            ByDateChart.PlotArea.XAxis.MaxValue = view.Count;
            ByDateChart.PlotArea.XAxis.MinValue = 0;
            ByDateChart.PlotArea.XAxis.AutoScale = false;
            ByDateChart.PlotArea.XAxis.AutoShrink = false;
            ByDateChart.PlotArea.XAxis.Clear();   
       
            bool stepLabels = view.Count > 20;
            int stepSize = view.Count /20;
            int index = 0;
            foreach (DataRowView rowView in view)
            {
                if (stepLabels && (index % stepSize != 0))
                {
                    ByDateChart.PlotArea.XAxis.AddItem(" ");
                }
                else
                {
                    ByDateChart.PlotArea.XAxis.AddItem(((DateTime)(rowView["DateStamp"])).ToShortDateString());
                }

                index++;
            }
        }

My problem is that I want to get rid of the numeric label shown at the top of each bar item (it's a bar chart), but I can't seem to. Is there something obvious I'm just missing here?

6 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 04 Jan 2008, 05:46 PM
Hi MatFindlay,

To modify the label which appears above the bars you should use the DefaultLabelValue property of the Series object. In your case it should be:

    chart.Series[0].DefaultLabelValue = string.Empty;


More information about this property you can find here.


Greetings,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
MatFindlay
Top achievements
Rank 1
answered on 04 Jan 2008, 06:49 PM
the object chart doesn't actually have a Series collection, as it's a Telerik.Reporting.Processing.Chart object, and not a Telerik.Reporting.Chart object. I'm also unable to cast chart to that type from the sender object.
0
Chavdar
Telerik team
answered on 07 Jan 2008, 08:40 AM
Hi MatFindlay,

I am sorry for not posting the whole implementation of the event handler. Here it is:

        private void chart1_NeedDataSource(object sender, System.EventArgs e)
     {
         Telerik.Reporting.Processing.Chart chartItem = (Telerik.Reporting.Processing.Chart)sender;
         Telerik.Reporting.Chart chart = (Telerik.Reporting.Chart)chartItem.ItemDefinition;
         chart.Series[0].DefaultLabelValue = string.Empty;
     }


Hope this helps.

Best wishes,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
MatFindlay
Top achievements
Rank 1
answered on 07 Jan 2008, 05:13 PM
This doesn't appear to work. When placed in the NeedsDataSource event handler, I get an exception telling me the index is out of range. When I try and blank out the default label in the ItemDatabound event handler, there's no change at all.
0
Chavdar
Telerik team
answered on 08 Jan 2008, 12:46 PM
Hi MatFindlay,

At the moment there is no way to customize the series if they are dynamically generated during the data-binding. The only approach to solve the problem is to create the series at design time, customize them and set the fields to which they will data bind through the DataYColumn property.

Let me know if you are experiencing any problems while implementing this approach.

Kind regards,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Maria Gracela
Top achievements
Rank 1
answered on 24 Jan 2008, 03:46 AM
<admin>
    Question moved to RadChart support section.
</admin>
Tags
General Discussions
Asked by
MatFindlay
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
MatFindlay
Top achievements
Rank 1
Maria Gracela
Top achievements
Rank 1
Share this question
or