wp7 上的线图

发布于 2024-11-15 04:24:36 字数 1351 浏览 5 评论 0原文

我正在使用 amCharts 及其 SerialChart 与 LineGraph 相结合。我已经让它以这种方式工作:

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

代码隐藏:

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;
}

我不明白如何定位线图的数据上下文而不是设置整个枢轴的数据上下文?我在三个不同的数据透视项中有三个图表,我需要单独设置它们的数据上下文。所以我想做一些类似的事情:

_24HoursLineGraph.DataContext = theDataContext;

但这不起作用。我还尝试使用 _24HoursLineGraph.Graphs[0].DataContext 访问线图本身,但这也不起作用。

有什么建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄意 2024-11-22 04:24:36

快速图表专为简单场景而设计,多个图表只有一个数据源。快速图表不支持为每个图表使用完全独立的数据源。

在您的情况下,您需要将所有数据源合并为一个,然后将每个图表上的 ValueMemberPath 设置为数据中相应的属性名称。

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文