Reputation: 14044
I am developing a Chart in WPF Application. But it is not showing the chart. Chart Plot area is blank whereas I can see the number of legends on the basis of number of valueList.add I do in the code.
<chartingToolkit:Chart HorizontalAlignment="Stretch"
x:Name="MyPie"
Margin="10"
Title="Total Voting Percentage"
VerticalAlignment="Stretch">
<chartingToolkit:PieSeries ItemsSource="{Binding}"
DependentValuePath="Total Participants"
IndependentValuePath="Total Voted" />
</chartingToolkit:Chart>
public partial class TotalVoting : Window
{
int TotalParticipant;
int TotalVoted;
public TotalVoting()
{
InitializeComponent();
TotalParticipant = int.Parse(da[0].ToString()); //data reaches here
TotalVoted = int.Parse(da1[0].ToString()) / 2; //data reaches here
ObservableCollection<Writer> Team = new ObservableCollection<Writer>
{
new Writer("Total Participants", TotalParticipant),
new Writer("Participants Voted", TotalVoted),
new Writer("Total Participants", TotalParticipant),
new Writer("Participants Voted", TotalVoted)
};
MyPie.DataContext = Team;
}
}
public class Writer
{
public Writer() { }
public Writer(string writerName, int numOfTypes)
{
Name = writerName;
Types = numOfTypes;
}
public string Name { get; set; }
public int Types { get; set; }
}
When I run the code I can see the number of legends that too with number 1,2,3 ... so with current code it shows from 1 to 4. but doesn't show any chart on my chart control. Any clue so that I can get it done.
EDIT : A Change has been made to the code .. but still the same result
public void GenerateChart()
{
List<KeyValuePair<string, double>> valueList = new List<KeyValuePair<string, double>>();
valueList.Add(new KeyValuePair<string, double>("Apple", 101));
valueList.Add(new KeyValuePair<string, double>("Banana", 201));
valueList.Add(new KeyValuePair<string, double>("Cake", 20));
valueList.Add(new KeyValuePair<string, double>("Others", 200));
pieChart.Title = "Top Products";
pieChart.DataContext = valueList;
}
the number of time valueList.Add
is added. I can the same number of legends on the chart but no chart :(
Hope Somebody can help me !!!
Upvotes: 0
Views: 847
Reputation: 1303
Here is the link to complete source code for the chart. https://www.dropbox.com/s/helas5e8qdr1xhs/WPF.zip?dl=0
Upvotes: 2