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

How to customize the pie chart?

4 Answers 294 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Uttam Dhakal
Top achievements
Rank 1
Uttam Dhakal asked on 31 Oct 2012, 01:07 AM
I am trying to implement few things on Pie Chart how can i do that?
1. I want to assing the full pie chart as a value like
Total = The Whole pie Chart
and Used will be a part
so Total will be 100%
and Used will be 30 then the pie should so me as
Total 100 and Used 30%
Whole value of pie should be 100
I can only add items now.

2. How do i modify the position of the pie Chart,the margins of the chart diagram, the position of the legends through server coding.

Any help will be highly appreciated Please

4 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 31 Oct 2012, 10:46 AM
Hello Uttam,

A Pie chart is generally 100%, as explained here: http://www.telerik.com/help/aspnet-ajax/htmlchart-types-pie-chart.html.

You can add a title for the chart or a regular span/ASP label around the chart to indicate that it shows 100%

You can also create two items for it - one with the Used value you have and another with value equal to 100-Used, so that they show up in the legend as desired. This will allow you to set their colors and names as well. For example
<telerik:RadHtmlChart runat="server" ID="rhc1" Width="400" Height="400">
    <ChartTitle Text="Total: 100%">
    </ChartTitle>
    <PlotArea>
        <Series>
            <telerik:PieSeries>
                <LabelsAppearance DataFormatString="{0}%">
                </LabelsAppearance>
            </telerik:PieSeries>
        </Series>
    </PlotArea>
</telerik:RadHtmlChart>

protected void Page_Load(object sender, EventArgs e)
{
    int used = 33;
    int remaining = 100 - used;
    SeriesItem itemUsed = new SeriesItem();
    itemUsed.YValue=used;
    itemUsed.Name="Used";
    itemUsed.BackgroundColor = System.Drawing.Color.Green;
    SeriesItem itemRemaining = new SeriesItem();
    itemRemaining.YValue = remaining;
    itemRemaining.Name = "Remaining";
    itemRemaining.BackgroundColor = System.Drawing.Color.Red;
    rhc1.PlotArea.Series[0].Items.Add(itemUsed);
    rhc1.PlotArea.Series[0].Items.Add(itemRemaining);
}

which results in the attached image.


On paddings - you can wrap the chart in another div and set its properties as desired to offset the chart from the adjacent elements.

Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Uttam Dhakal
Top achievements
Rank 1
answered on 31 Oct 2012, 11:57 AM
the problem is i cannot display remaining

i can display only 100 and used as a part of 100.
so the full pie will be 100% the used will be the 30% of that
100%. so that users can see how much remaining automatically.
i cannot add a two items like  this.
0
Uttam Dhakal
Top achievements
Rank 1
answered on 31 Oct 2012, 01:33 PM
Hi Marin thanks for your advice,
Please take a look at the picture which will describe what i want to achieve.
Here i have to items
1. Allotted Disk Space
2. Used Disk Space
I need to show the graph in a way that Whole Graph is Allotted Disk Space and Used Disk Space should be a part of the Allotted Disk Space.Not a different Item

Please Any Suggestions for that
0
Marin Bratanov
Telerik team
answered on 01 Nov 2012, 01:42 PM
Hi Uttam,

Once again, the pie chart is itself the whole object that is displayed. This means that the entire chart is the alloted space, so you cannot add the alloted space as an item. You can have items for parts of the entire space - e.g. free, reserved, used, etc. You can show the alloted space in the chart title or in a separate label on the page. This is how pie charts work - each item is a part of the whole thing, you cannot have an item that represents the entire object you wish to visualize inside the said object.

Regarding the labels - they are automatically positioned to be as far apart as possible, because with more items they will easily overlap. This behavior cannot be changed.

All the best,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Chart (HTML5)
Asked by
Uttam Dhakal
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Uttam Dhakal
Top achievements
Rank 1
Share this question
or