5550

WPF: Chart is not plotting the chart

Question:

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.

<h2>XAML</h2> <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> <h2>Code Behind</h2> 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.

<hr />

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 !!!

Answer1:

Here is the link to complete source code for the chart. <a href="https://www.dropbox.com/s/helas5e8qdr1xhs/WPF.zip?dl=0" rel="nofollow">https://www.dropbox.com/s/helas5e8qdr1xhs/WPF.zip?dl=0</a>

Recommend

  • How to use google drive api in my android application?
  • iOS Objective-C UITextField Date Formatting
  • What does (0, eval) () do? [duplicate]
  • Why does hyperledger composer acl file not take effect?
  • How to make the SET command not wait for answer?
  • How To Create or Stabiles relationship between two tables in FMDB?
  • how to use if / else
  • MySQL RegEx: Got error 'empty (sub)expression' from regexp [duplicate]
  • Exchange web service set organizer of the appointment
  • codeigniter pass data from view to model and retrieve info
  • Binding an object to data grid cell - conditional cell style
  • Change out ObservableCollection upon ComboBox change
  • How add new row in datagrid (source in datatable)
  • No drop with basic gongsolution sample
  • Datagrid scroll bar stops working
  • text along curvature path like circular or arc in silverlight
  • Is it possible to have dynamically generated query names in ColdFusion?
  • How to access control in DataGridTemplateColumn to get value?
  • Drag-and-Drop UWP vs Button Style
  • Silverlight UI not unsubscribing from PropertyChanged events
  • WPF DataGrid shows dot instead comma
  • Deserializing nested JSON C# and Bind to XAML ListBox
  • How can I bind DataGrid row count after a CollectionView filter is applied?
  • Bind customObject to DataGrid
  • Scroller-like animation on a Label in WPF
  • Using ListPicker and DataBinding
  • DataGrid: Help accessing a control defined in a CellEditingTemplate
  • Why is wpf UpdateSourceTrigger not binding explicitly?
  • How to get instance of the GridControl in LookupEdit (Devexpress)
  • Return list instead of an item Webservice Phone 8.1 UAP
  • Symfony 2 form in embedded controller and AJAX
  • How to use a MultiBinding on DataGridTextColumn?
  • Add items to ComboBox at runtime?
  • Binding ContextMenu Tag to Owner
  • Caliburn Micro, How to use ContentControl (or display 'sub' ViewModel) using ViewModel Fir
  • Drawing a Path in XAML (with binding) vs. C#. One works, one doesn't
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Force show.bind execution
  • Get one-time binding to work for ng-if
  • QuartzCore.framework for Mono Develop