I'm trying to set from the Code Behind a color of some line in Chart. I have searched for 3 hours how to do it and I couldn't find anything. Is it possible do to that? If it can't be do, please recommend another chart library where I can do that.
Thanks!
XAML
<Charting:Chart Title="Name" x:Name="LineChart" HorizontalAlignment="Left" VerticalAlignment="Center" Width="510" Height="450">
<Charting:LineSeries Title="PB" IndependentValuePath="Name" DependentValuePath="Amount" IsSelectionEnabled="True"/>
<Charting:LineSeries Title="Oil" IndependentValuePath="Name" DependentValuePath="Amount" IsSelectionEnabled="True"/>
</Charting:Chart>
WPF
Random rand = new Random();
List<FinancialStuff> financialStuffList = new List<FinancialStuff>();
for (int i = 0; i < 30; i++ )
financialStuffList.Add(new FinancialStuff() { Name = Convert.ToString(i), Amount = rand.Next(0, 200) });
(LineChart.Series[0] as LineSeries).ItemsSource = financialStuffList;
for (int i = 0; i < 30; i++)
financialStuffList[i].Amount = rand.Next(0, 50);
(LineChart.Series[1] as LineSeries).ItemsSource = financialStuffList;
public class FinancialStuff
{
public string Name { get; set; }
public int Amount { get; set; }
}
Have you tried this? Try to set it when you get the line here
You may also try the following XAML: