试图在VS 2015中的Windows应用程序中创建图表 [英] trying to create a chart in a windows application in VS 2015

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

问题描述

我正在使用.NET 4.6.x在Windows 10机器上的Visual Studio 2015中开发C#windows应用程序。

I am developing a C# windows application in Visual Studio 2015 on a Windows 10 box with .NET 4.6.x.

项目属性目标框架设置为4.5.2。

Project properties target framework set to 4.5.2.

我已尝试在互联网上找到的所有内容,以获取工具箱数据 - >图表,以便我可以拖放到我的MainWindow.xaml文件中。不行。图表线是灰色的。我已经将System.Windows.Forms.DataVisualization.Charting添加到.NET Framework
组件。

I've tried everything I can find on the internet to get the toolbox Data->Chart to allow me to drag and drop into my MainWindow.xaml file. No go. The Chart line is grey'd out. I've added System.Windows.Forms.DataVisualization.Charting to the .NET Framework Components.

stackoverflow上的20个页面,我找不到灵丹妙药。它必须是简单的东西,但我找不到它。

20 pages on stackoverflow and I can't find the magic bullet. It must be something simple but I can't find it.

谢谢。

推荐答案

您好stg1fuggles,

Hi stg1fuggles,

感谢您在此发帖。

对于您的问题,什么是类型你的项目? Winform,WPF?

For your question, what is the type of your project? Winform, WPF?

>>我已经尝试了所有可以在互联网上找到的工具箱数据 - >图表允许我拖动并放入我的MainWindow.xaml文件。

我不确定这是什么意思。请提供更多详细信息。

I am not sure what does this mean. Please provide more details.

如果您想在winform中创建图表,请参考以下代码。

If you want to create a chart in winform, here is the code for your reference.

string[] seriesArray = { "ProdutoA", "ProdutoB", "ProdutoC", "ProdutoD" };
            double[] pointsArray = { 20, 10, 70, 50 };

            // Set palette.
            this.chart2.Palette = ChartColorPalette.SeaGreen;

            // Set title.
            this.chart2.Titles.Add("Produtos");

            // Add series.
            for (int i = 0; i < seriesArray.Length; i++)
            {
                // Add series.
                Series series = this.chart2.Series.Add(seriesArray[i]);

                // Add point.
                series.Points.Add(pointsArray[i]);
            }

如果 你想在WPF中创建一个图表,你可以尝试下面链接中的代码。

If  you want to create a chart in WPF, you could try the code in the link below.

https://www.c-sharpcorner.com/UploadFile/mahesh/ charting-in-wpf /

最好的问候,

Wendy


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

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