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

radchart (pie) bind with database

2 Answers 175 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 19 Feb 2011, 08:05 AM
hello to all

i m making pie chart and binding with database but i m not able to create correct

my code is:
    <div>
        <telerik:RadChart ID="RadChart2" runat="server" DefaultType="Pie" Width="710px" AutoTextWrap="true"
            DataSourceID="SqlDataSource1" Skin="LightGreen">

          
            <Series>
                <telerik:ChartSeries Name="Total Size" Type="Pie" DataYColumn="tsize">
                    <Appearance>
                        <FillStyle MainColor="243, 206, 119" FillType="ComplexGradient">
                            <FillSettings>
                                <ComplexGradient>
                                    <telerik:GradientElement Color="243, 206, 119"></telerik:GradientElement>
                                    <telerik:GradientElement Color="236, 190, 82" Position="0.5"></telerik:GradientElement>
                                    <telerik:GradientElement Color="210, 157, 44" Position="1"></telerik:GradientElement>
                                </ComplexGradient>
                            </FillSettings>
                        </FillStyle>
                        <TextAppearance TextProperties-Color="112, 93, 56">
                        </TextAppearance>
                        <Border Color="223, 170, 40"></Border>
                    </Appearance>
                </telerik:ChartSeries>
                <telerik:ChartSeries DataYColumn="size1" Name="Size" Type="Pie">
                    <Appearance>
                        <FillStyle FillType="ComplexGradient" MainColor="154, 220, 230">
                            <FillSettings>
                                <ComplexGradient>
                                    <telerik:GradientElement Color="154, 220, 230" />
                                    <telerik:GradientElement Color="121, 207, 220" Position="0.5" />
                                    <telerik:GradientElement Color="89, 185, 204" Position="1" />
                                </ComplexGradient>
                            </FillSettings>
                        </FillStyle>
                        <TextAppearance TextProperties-Color="112, 93, 56">
                        </TextAppearance>
                        <Border Color="117, 177, 192" />
                    </Appearance>
                </telerik:ChartSeries>
            </Series>
          
         
        </telerik:RadChart>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sagploConnectionString %>"
            SelectCommand="declare @aa as varchar(255);set @aa='1073741824' select(select @aa )as tsize, (SELECT isnull(sum([size1]),0) FROM [treeview] WHERE ([nodetype] = 'file'))as size1">
        </asp:SqlDataSource>
    </div>


i want to know that how to merge my both pie chart.

2 Answers, 1 is accepted

Sort by
0
Accepted
Ves
Telerik team
answered on 23 Feb 2011, 05:53 PM
Hello Goldy,

Your markup shows two ChartSeries, that is -- two pies. If it were bar series that would mean two sets of bars. Now, each pie will have as many slices as the number of records in the datasource is. For the bars this would be -- the number of bars in each set (series) will be equal to the number of records in the datasource. So, in order to get a single pie with two slices you need to provide the data like this:
 State Size
 Used 250
 Unused 750

This way you will need only one ChartSeries declared and you will get the expected result.

I understand that providing the data like this might not be always possible, so there is an alternative -- do not databind the chart. Create a single ChartSeries, do not set its DataYColumn property and populate it manually by looping through the data ( in this case by adding two ChartSeriesItems with their corresponding values, retrieved from the datasource).

Best regards,
Ves
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Jack
Top achievements
Rank 1
answered on 24 Feb 2011, 06:03 AM
Thanks very much.It works great.
Tags
Chart (Obsolete)
Asked by
Jack
Top achievements
Rank 1
Answers by
Ves
Telerik team
Jack
Top achievements
Rank 1
Share this question
or