radchart (pie) bind with database

Thread is closed for posting
3 posts, 1 answers
  1. Jack
    Jack avatar
    67 posts
    Member since:
    Jul 2010

    Posted 19 Feb 2011 Link to this post

    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. Answer
    Ves
    Admin
    Ves avatar
    2926 posts

    Posted 23 Feb 2011 Link to this post

    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!
  3. Jack
    Jack avatar
    67 posts
    Member since:
    Jul 2010

    Posted 24 Feb 2011 Link to this post

    Thanks very much.It works great.
Back to Top