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

RadGrid Aggregate Chart

8 Answers 230 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Afaan
Top achievements
Rank 1
Afaan asked on 09 Sep 2008, 04:08 PM
Hello,
I am trying to implement an Aggregate Chart like shown here:
http://demos.telerik.com/aspnet/prometheus/Controls/Examples/Integration/GridAndChart/GridAndAggregateChart/DefaultCS.aspx?product=chart
I would like to know if there is a way to use LINQ to SQL for loading the information into the graph. Any help would be appreciated,
Thanks.

8 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 11 Sep 2008, 08:41 AM
Hi Afaan,

We are not sure what kind of problems are you experiencing when binding the chart control to LINQ-to-SQL classes. We have attached a sample application that demonstrates the desired functionality by binding to the "Category Sales for 1997" view from the Northwind database (if you have SqlExpress with attached Northwind database you should be able to run the application as well).

Hope this helps.


All the best,
Manuel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Afaan
Top achievements
Rank 1
answered on 12 Sep 2008, 03:04 PM
Hi,
Thank you for the reply, I have the pie graph working now but there are still a couple of problems. First of all, when the pie graph is generated, each section of the graph shows the value of the field, as opposed to the percentage. I tried setting the DefaultLabelValue="#%" but that doesn't seem to work. Another problem is that there seems to be no legend either, it shows up, but only as one series where as the graph has multiple series. Another questions I had is that if it is possible to let the user of the page decide the type of graph(bar or pie in my case) based on a dropdown. Thank you for your help again.
0
Ves
Telerik team
answered on 15 Sep 2008, 01:58 PM
Hello Afaan,

Onto your questions:
  • Can you show the relevant code and markup, please? We are not aware of any issues with DefaultLabelValue and it seems to work fine at our end.
  • RadChart1.Legend.Appearance.LegendDisplayMode defines what the legend will show for each chart series: the series name, the item names or nothing. By the way - do you mean more than one series or more than one series items?
  • Yes, this is possible. All you need is to wire SelectedIndexChanged of the dropdown and change the type of the existing chart series like RadChart1.Series[0].Type = Telerik.Charting.ChartSeriesType.Bar;

All the best,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Afaan
Top achievements
Rank 1
answered on 15 Sep 2008, 04:00 PM
here is the code i use to create the chart,

chart.DataSource = _dataClass.ReportTotalTimeByUser2(StartDate.SelectedDate, EndDate.SelectedDate, User.SelectedValue.ToString()).ToList();
        chart.DataManager.ValuesYColumns = new string[] { "TotalHours" };       
        chart.PlotArea.XAxis.DataLabelsColumn = "ProjectName";
        chart.Legend.Appearance.LegendDisplayMode = "ItemLabels";
        chart.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 270;
        chart.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Ariel", 8);      

        chart.DataBind();

However, that gives me  

Error 2 'Telerik.Charting.Styles.StyleExtendedLabel' does not contain a definition for 'LegendDisplayMode' and no extension method 'LegendDisplayMode' accepting a first argument of type 'Telerik.Charting.Styles.StyleExtendedLabel' could be found (are you missing a using directive or an assembly reference?) 

 As for DefaultLabelValue, it still is not working, here is the ASPX code for it

<telerik:RadChart ID="RadChart2" runat="server" Height="600px" Width="1000px"
        DefaultType="Pie" AutoLayout="true" Skin="Vista">      
           

           <Series>
           <telerik:ChartSeries Type="Pie" DefaultLabelValue="#%">
           <Appearance LegendDisplayMode="ItemLabels">
            </Appearance>
            </telerik:ChartSeries>
            </Series>
Also, i did mean more than one series items, sorry about the confusion.
Thank you for the replies.

0
Ves
Telerik team
answered on 18 Sep 2008, 07:16 AM
Hi Afaan,

I am sorry for the misleading information provided in my previous reply. There is no chart.Legend.Appearance.LegendDisplayMode. It should be chart.Series[x].Appearance.LegendDisplayMode. Please, find attached a small example based on the code you provided. It shows how to create a pie chart with percentage shown in the item labels and how to switch the chart type based on the value selected in the DropDownList.

Hope this helps.

Kind regards,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Afaan
Top achievements
Rank 1
answered on 19 Sep 2008, 12:36 PM
Thank you! Finally have it working! Will lurk the forums for more help on legend, as i need more colours to show up in the pie. But thanks a lot again.
0
sp
Top achievements
Rank 1
answered on 29 Jan 2009, 01:10 AM





                        <telerik:RadChart ID="RadChart1" runat='server' DataSourceID="SqlDataSource1" DefaultType="Pie">  
                            <Series> 
                                <cc1:ChartSeries DataLabelsColumn="Cat_code_Total" DataYColumn="Cat_code_Total" DefaultLabelValue="#%" 
                                    Name="Series 1" Type="Pie">  
                                    <appearance legenddisplaymode="ItemLabels">  
                                        <Border Color="177, 215, 250"></Border> 
                                        <TextAppearance TextProperties-Color="78, 168, 188"></TextAppearance> 
                                        <FillStyle MainColor="194, 230, 252" FillType="Solid"></FillStyle> 
                                    </appearance> 
                                </cc1:ChartSeries> 
                            </Series> 
                            <ChartTitle> 
                                <TextBlock> 
                                    <Appearance TextProperties-Color="232, 140, 0" TextProperties-Font="Verdana, 20pt, style=Bold">  
                                    </Appearance> 
                                </TextBlock> 
                                <Appearance Dimensions-Margins="4%, 10px, 10px, 7%">  
                                    <FillStyle MainColor="">  
                                    </FillStyle> 
                                </Appearance> 
                            </ChartTitle> 
                            <Legend> 
                                <Appearance Corners="Round, Round, Round, Round, 6" Dimensions-Margins="20%, 3%, 1px, 1px">  
                                    <Border Color="194, 212, 109" /> 
                                    <ItemTextAppearance TextProperties-Color="120, 162, 19">  
                                    </ItemTextAppearance> 
                                </Appearance> 
                            </Legend> 
                        </telerik:RadChart> 
This is my code and I have the same problem. My labels do not show up as %. I also tried {F}. none of the formatting seems to work. I tried the sample above it works fine. Not sure what the difference is. Appreciate any help. Thanks
0
Ves
Telerik team
answered on 29 Jan 2009, 11:51 AM
Hi,

It is the DataLabelsColumn property that triggers this behavior. You cannot have either DefaultLabelValue along with DataLabelsColumn  set. The DefaultlabelValue will be ignored in this case. DefaultLabelValue will format the YValue property and will set the result as a label. On the other hand DataLabelsColumn defines the column which will provide the values for item labels and it might not be even a numeric column. In this case DataLabelsColumn is set to the same column as the one providing data for YValue property, so you will simply see the value as label. Removing it should fix it for you.

Sincerely,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Chart (Obsolete)
Asked by
Afaan
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Afaan
Top achievements
Rank 1
Ves
Telerik team
sp
Top achievements
Rank 1
Share this question
or