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

Programmatic Chart

6 Answers 438 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stuart
Top achievements
Rank 1
Stuart asked on 03 Sep 2007, 08:31 AM
Hi

I want to know if there is a programatic way to creating charts on the Telerik Reporting Suite. I have tried the winforms documentations that gives a very clear indication on how to , but the problem is that the methods and object declarations are diferent in the reporting suite.

And if so can you please point me to a doc or tutorial

Thank you

6 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 03 Sep 2007, 04:04 PM
Hi Stuart,

Here is an example of how to create a report programmatically which has one chart report item. Once the chart report item is created you can use the same API as in the WinForms chart.

Function CreateChartReport() As Telerik.Reporting.Report 
    Dim report As New Telerik.Reporting.Report() 
 
    Dim chart As New Telerik.Reporting.Chart() 
 
    chart.Location = New Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Cm(0.5), Telerik.Reporting.Drawing.Unit.Cm(0.5)) 
    chart.Size = New Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Cm(10), Telerik.Reporting.Drawing.Unit.Cm(5)) 
 
    Dim s As New Telerik.Charting.ChartSeries() 
    s.Name = "Series 1" 
    Dim r As New Random(DateTime.Now.Millisecond) 
 
    Dim i As Integer = 0 
    While i < 3 
        s.AddItem(r.[Next](0, 100)) 
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1) 
    End While 
 
    chart.Series.Add(s) 
 
    Dim detail As New Telerik.Reporting.DetailSection() 
    report.Items.Add(detail) 
    detail.Items.Add(chart) 
    Return report 
End Function 

The documentation on the charting item will be enhanced considerably for the upcoming Q2 release.


Regards,
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:40 PM
Can you let me know where the updated doc's are. Had a quick look through and could not find anything helpful...
0
Steve
Telerik team
answered on 18 Nov 2008, 05:11 PM
Hello Mike,

Chart item documentation is available in our help documentation in Designing Reports --> Understanding Report Items --> Chart. Here is a link to the first available article.

All the best,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike Trill
Top achievements
Rank 1
answered on 18 Nov 2008, 06:10 PM
Thanks for the link. What I am trying to do (sorry for double post). Is set the x (or y) series lables. The example  Telerik Example only shows how to add the data.

If you took the report from the example, I would want to replace the x-axs labels of 0,1,2,3,4,5 with 2004,2005,2006,2007,2008 or othertext.... ( I selected years as that is the date).

There is an example posted before from one of your colleagues that does not work.... But below gives an idea of what I want to produce.

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());  
}                                
}  
0
Mike Trill
Top achievements
Rank 1
answered on 18 Nov 2008, 06:36 PM
Ok, I've sorted it (I had got my X & Y's  round the wrong way). But it would still be good to see better doc's

            Telerik.Reporting.Chart chartd =(Telerik.Reporting.Chart)chart.ItemDefinition;     
 
            chartd.PlotArea.XAxis.AutoScale = false;  
            chartd.PlotArea.XAxis.Clear();  
 
 
            foreach (OrdersPerDay.OrdersPerDayDataTableRow row in rd)  
            {  
                chartd.PlotArea.XAxis.Items.Add(new Telerik.Reporting.Charting.ChartAxisItem(((DateTime)row["DateOrdered"]).ToShortDateString()));  
            }  
 

My problem now is that the labels, bleed off the left of the report. Looking for another property to fiddle with...
0
Steve
Telerik team
answered on 19 Nov 2008, 01:16 PM
Hi Mike,

Have you tried increasing the Plot area and decreasing the margins? If still having problems, please provide us with screenshot or a sample report so that we can advise you further.

Kind regards,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Stuart
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Mike Trill
Top achievements
Rank 1
Steve
Telerik team
Share this question
or