windows phone应用程序:创建图表 [英] windows phone application :create a chart

查看:89
本文介绍了windows phone应用程序:创建图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我想创建一个从xml文件中的数据显示图表的Windows Phone应用程序。当我运行应用程序时,图表为空无图表只有标题在屏幕上 我不知道问题在哪里


这是我的XMl FIle

< year> 
< month> Jan< / month>
< actual> 2000< / actual>
< / year>

< year>
< month> 2月< /月>
< actual> 3000< / actual>
< / year>

< year>
< month> 3月< /月>
< actual> 1000< / actual>
< / year>

这是我背后的代码

 InitializeComponent(); 
XDocument data = XDocument.Load(" Data.xml");

var results = from data inDescendants(" year")
select new ResultModel((string)query.Element(" month"),
(int )query.Element(QUOT;实际"));
var chart = new SerialChart
{
CategoryValueMemberPath =" month",
AxisForeground = new SolidColorBrush(Colors.White),
PlotAreaBackground = new SolidColorBrush(Colors。白色),
GridStroke =新的SolidColorBrush(Colors.White)
};

chart.SetBinding(SerialChart.DataSourceProperty,new Binding(" results"));


var lineGraph = new LineGraph
{
Title =" Test",
ValueMemberPath =" actual",
Brush =新的SolidColorBrush(Colors.Green),
StrokeThickness = 2,

};
chart.Graphs.Add(lineGraph);

test.Children.Add(chart);
}

公共类ResultModel
{
public string month {get;组; }
public int actual {get;组; }

public ResultModel(string label,int category)
{month = label;实际=类别; }

public ResultModel()
{
}
}
}



}

解决方案

没有内置图表控制。如果您在使用第三方控件时遇到问题,最好不要向控件的作者寻求帮助,但如果您告诉我们您正在使用哪种控件,那么社区中的某些人可能会获得
的帮助它

Hello 

I want to create a windows phone application who display chart from data in xml file.when i run the application the chart is null no chart only the title in the screen  i don't know where is the problem

this is my XMl FIle

 <year>
    <month>Jan</month>
    <actual>2000</actual>
  </year>

  <year>
    <month>Feb</month>
    <actual>3000</actual>
  </year>

  <year>
    <month>Mar</month>
    <actual>1000</actual>
  </year>

and this is my code behind

   InitializeComponent();
            XDocument data = XDocument.Load("Data.xml");

            var results = from query in data.Descendants("year")
                          select new ResultModel((string)query.Element("month"),
                           (int)query.Element("actual"));
             var chart = new SerialChart
            {
                CategoryValueMemberPath = "month",
                AxisForeground = new SolidColorBrush(Colors.White),
                PlotAreaBackground = new SolidColorBrush(Colors.White),
                GridStroke = new SolidColorBrush(Colors.White)
            };

             chart.SetBinding(SerialChart.DataSourceProperty, new Binding("results"));


            var lineGraph = new LineGraph
            {
                Title = "Test",
                ValueMemberPath = "actual",
                Brush = new SolidColorBrush(Colors.Green),
                StrokeThickness = 2,

            };
            chart.Graphs.Add(lineGraph);
            
            test.Children.Add(chart);
        }

        public class ResultModel
        {
            public string month { get; set; }
            public int actual { get; set; }

            public ResultModel(string label, int category)
            { month = label; actual = category; }

            public ResultModel()
            {
            }
        }
        }

        

        }

解决方案

There is no in-box charting control. If you are having trouble with a 3rd party control you will probably be best off asking the author of the control for help, but if you let us know which control you are using somebody in the community may be able to help with it.


这篇关于windows phone应用程序:创建图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆