Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't find <code>StackedColumnSeries</code> in WPF so I will use Silverlight. As I see you create <code>SeriesDefinition</code> in code, in that case there is no point in binding, here is correct code:</p> <p>Xaml without chart series:</p> <pre><code>&lt;charting:Chart x:Name="MyChart" Padding="10,10,10,10" /&gt; </code></pre> <p>Code behind:</p> <pre><code>public class SimpleDataValue { public string IndependentValue { get; set; } public int DependentValue { get; set; } } public partial class MainPage : UserControl { private int[] myCollection = new int[10]; private List&lt;DefinitionSeries&gt; Series = new List&lt;DefinitionSeries&gt;(); public MainPage() { InitializeComponent(); this.drawChart(); this.Series.ForEach(this.MyChart.Series.Add); } private void drawChart() { this.Series.Clear(); this.Series = new List&lt;DefinitionSeries&gt;(); var dataValues = new List&lt;List&lt;SimpleDataValue&gt;&gt;(); int wartoscNiezalezna = 1; for (int i = 0; i &lt; 2; i++) { dataValues.Add(new List&lt;SimpleDataValue&gt;()); } foreach (var item in myCollection) { dataValues[0].Add(new SimpleDataValue { IndependentValue = "Czujnik " + wartoscNiezalezna, DependentValue = 100 }); //czerwone dataValues[1].Add(new SimpleDataValue { IndependentValue = "" + wartoscNiezalezna, DependentValue = 200 }); wartoscNiezalezna++; } var stackedSeries = Activator.CreateInstance(typeof(StackedColumnSeries)) as DefinitionSeries; int itemnr = 0; foreach (var item in dataValues) { var definicja = new SeriesDefinition(); if (itemnr == 0) definicja.Title = "Stan 1"; else definicja.Title = "Stan 2"; definicja.DependentValuePath = "DependentValue"; definicja.IndependentValuePath = "IndependentValue"; ToolTipService.SetToolTip(definicja, "asdas"); definicja.ItemsSource = item; stackedSeries.SeriesDefinitions.Add(definicja); itemnr++; } Series.Add(stackedSeries); } } </code></pre> <p>What about me, I would solve your problem in this way, because <code>ViewModel</code> mustn't contains anything form the View:</p> <p>Xaml</p> <pre><code>&lt;charting:Chart x:Name="MyChart" Padding="10,10,10,10"&gt; &lt;charting:Chart.Series&gt; &lt;charting:StackedColumnSeries&gt; &lt;charting:SeriesDefinition Title="Stan 1" ItemsSource="{Binding FirstCollection}" DependentValuePath="DependentValue" IndependentValuePath="IndependentValue" /&gt; &lt;charting:SeriesDefinition Title="Stan 2" ItemsSource="{Binding SecondCollection}" DependentValuePath="DependentValue" IndependentValuePath="IndependentValue" /&gt; &lt;/charting:StackedColumnSeries&gt; &lt;/charting:Chart.Series&gt; &lt;/charting:Chart&gt; </code></pre> <p>Code-behind</p> <pre><code>public class ChartModel { public List&lt;SimpleDataValue&gt; FirstCollection { get; set; } public List&lt;SimpleDataValue&gt; SecondCollection { get; set; } } public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); this.MyChart.DataContext = new ChartModel { FirstCollection = Enumerable.Range(1, 10).Select(i =&gt; new SimpleDataValue { IndependentValue = "Czujnik " + i, DependentValue = 100 }).ToList(), SecondCollection = Enumerable.Range(1, 10).Select(i =&gt; new SimpleDataValue { IndependentValue = "" + i, DependentValue = 200 }).ToList() }; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload