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

Dates as value labels on chart axes.

5 Answers 259 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
MatFindlay
Top achievements
Rank 1
MatFindlay asked on 13 Dec 2007, 11:06 PM
Hey, there... I'm trying to build a report, including charts, to display a series of metrics. The X-axis values on my charts are to be dates. I've set the format of the values on that axis to be a short date, and I'm trying to use the Chart.PlotArea.XAxis.DataLabelsColumn to get the values from the data source I'm using. Unfortunately, all I'm getting is zeroes for each column. Here's the code in my NeedDataSource handler:

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;
        }

Any advice? Even some general info on using dates as value labels along an axis would be helpful.

5 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 14 Dec 2007, 02:08 PM
Hello MatFindlay,

To solve the problem you may use the following workaround which populates the X axis items manually:

private void chart1_NeedDataSource(object sender, System.EventArgs e)
{
Telerik.Reporting.Processing.Chart chartItem = sender as Telerik.Reporting.Processing.Chart;

sqlDataAdapter1.Fill(dataSet);
DataView view = dataSet.Tables[0].DefaultView;
chart.DataSource = view;

Telerik.Reporting.Chart chart =
(Telerik.Reporting.Chart)chartItem.ItemDefinition;
chart.PlotArea.XAxis.AutoScale = false;
chart.PlotArea.XAxis.AutoShrink = false;
chart.PlotArea.XAxis.Clear();           
foreach (DataRowView rowView in view)
{
chart.PlotArea.XAxis.AddItem(((DateTime)(rowView["Date"])).ToShortDateString());
}                             
}


Give it a try and let me know if there are any problems. Thank you in advance.

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 14 Dec 2007, 05:33 PM
I gave that a try, and it doesn't seem to be working. There were a few changes I needed to make, though. It doesn't appear that the Telerik.Reporting.Processing.Chart object even has a PlotArea property, so instead of using the chart reference, I'm using the reference I have to the actual Telerik.Reporting.Chart object on the page.

Now it's labelling the columns on the X-axis from 1 to 17 for each item, which is a bit better, but still not quite what I'm looking for.
0
Chavdar
Telerik team
answered on 15 Dec 2007, 10:06 AM
Hi MatFindlay,

I suppose that you haven't cleared the DataLabelsColumn property of the chart but cannot be sure. Would it be possible to open a support ticket and send us the report definition so that we can examine the settings of the Chart report item more carefully.

Thanks in advance.

Best wishes,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mike Trill
Top achievements
Rank 1
answered on 18 Nov 2008, 04:44 PM
As the OP said, the code posted by Telerik does not work.

Telerik.Reporting.Chart chart =   
(Telerik.Reporting.Chart)chartItem.ItemDefinition;  
chart.PlotArea.XAxis.AutoScale = false;  
chart.PlotArea.XAxis.AutoShrink = false;  
chart.PlotArea.XAxis.Clear();              
foreach (DataRowView rowView in view)  
{  
chart.PlotArea.XAxis.AddItem(((DateTime)(rowView["Date"])).ToShortDateString());  
}                                
}  
 

Could someone post an updated version of this, or point me to some doc's that explain for Q2 or Q3....

Thanks!
0
Mike Trill
Top achievements
Rank 1
answered on 18 Nov 2008, 06:42 PM
Sorted here, don't want to double post.
Tags
General Discussions
Asked by
MatFindlay
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
MatFindlay
Top achievements
Rank 1
Mike Trill
Top achievements
Rank 1
Share this question
or