I'm using amCharts and their SerialChart combined with a LineGraph. I've gotten it to work this way:
<amq:SerialChart x:Name="_24HoursLineGraph" DataSource="{Binding Data}" CategoryValueMemberPath="Date"
AxisForeground="White"
PlotAreaBackground="Black"
GridStroke="DarkGray" Grid.Row="1" Margin="20">
<amq:SerialChart.Graphs>
<amq:LineGraph ValueMemberPath="Close" Title="Close" Brush="Blue" />
</amq:SerialChart.Graphs>
</amq:SerialChart>
Code behind:
public ObservableCollection<Currency> Data { get { return _data; } }
private ObservableCollection<Currency> _data = new ObservableCollection<Currency>(){};
void SetContext(Item[] itemArray)
{
_data = new ObservableCollection<Item>();
foreach (var item in itemArray)
{
_data.Add(item);
}
_data.OrderByDescending(i => i.Date);
this.DataContext = this;
}
I don't understand how I can target the datacontext of the linegraph instead of setting the datacontext of the entire pivot? I have three graphs in three different pivot items and I need to set the datacontext of them individually. So instead I want to do something like:
_24HoursLineGraph.DataContext = theDataContext;
But this doesn't work. I've also tried to access the linegraph itself with _24HoursLineGraph.Graphs[0].DataContext but that doesn't work either.
Any suggestions?