线图上WP7 [英] linegraph on wp7
问题描述
我使用amCharts及其SerialChart用线图相结合。我已经得到它的工作是这样的:
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;
}
我不明白我怎么能瞄准线图的DataContext的,而不是设置整个枢纽的DataContext的?我有三个不同的支点项目三个图形,我需要单独设置他们在DataContext。所以不是我想要做的是这样的:
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;
但是,这并不正常工作。我也试着访问线图本身_24HoursLineGraph.Graphs [0] .DataContext但这并不能工作。
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.
有什么建议?
推荐答案
快速图表是专为简单的场景,只有一个用于多个图形数据源。使用完全独立的数据来源为各图不是在快速图表支持。
Quick Charts is designed for simple scenarios with only one data source for multiple graphs. Using completely separate data sources for each graph is not supported in Quick Charts.
在你的情况,你需要将所有数据源合并成一个,然后设置ValueMemberPath每个图表中的数据添加相应的属性名称。
In your case you will need to merge all your data sources into one and then set ValueMemberPath on each graph to a respective property name in your data.
这篇关于线图上WP7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!