如何在C#中绘制带有非数值变量的图表 [英] How Do I draw a chart with non-Numerical Variables in C#

查看:107
本文介绍了如何在C#中绘制带有非数值变量的图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。



我对C#中的图表有一点问题。



该项目是一个简单的Windows窗体应用程序程序。



我想画一个这样的图表:



http://upload7.ir/imgs/2014-12/84930837744513480976.jpg [ ^ ]



例如:AA &安培;&安培; VC => A

所有这些字符串都是我的变量,我想绘制这种规则的图表:[()&& ()=> ()]。



我在seriesChartType或其他类中找不到图表的任何匹配模型。请帮帮我,我很着急。



问候。

Hi all.

I have a little issue with charts in C#.

The project is a simple windows form application program.

I want to draw a chart like this:

http://upload7.ir/imgs/2014-12/84930837744513480976.jpg[^]

for example: AA && VC => A
all of these strings are my variables and I want to draw a chart for this type of rules:[() && () => ()].

I couldn't find any match model of chart in seriesChartType or other classes. Please Help me I am in hurry.

Regards.

推荐答案

我不能在seriesChartType或其他类中找到任何匹配的图表模型。我不敢相信;)



见这里:示例Microsoft图表控件的环境 [ ^ ]。超过200个样本。
I couldn't find any match model of chart in seriesChartType or other classes. I can't believe ;)

See here: Samples Environments for Microsoft Chart Controls[^]. Over 200 samples.


我将发布一个想法(和代码),告诉你如何做到这一点,但它是基于这些假设:



1.你想要的是桌子而不是图表。



2.如果你得到你的数据...规则评估的结果......在正确的数据结构中,实际做绘图是你知道怎么做的。



示例:假设您已评估规则并生成此数据;这里使用了锯齿状数组,但是数组或通用List的类型几乎不重要:唯一重要的是你知道如何获取网格的值和相应的行/列标题:
I'm going to post an idea (and code) for how you might go about doing this, but it's based on these assumptions:

1. that what you want here is a "Table" more than it is a "Graph."

2. that if you get your data ... the outcome of rule evaluation ... in the right data structures, that actually doing the drawing is something you know how to do.

Example: assume you have evaluated your rules and generated this data; a jagged array is used here, but the type of Array or generic List hardly matters: the only important thing is you know how to get the values, and the appropriate row/column headers, for the grid:
string[][] data = new string[][]
{
    new string[] {"AA","KJ","LR"}, // rows
    new string[] {"VC", "QJ"}, // columns
    new string[] {"A", "B", "D", "E", "Z", "X"} // values
};

要保持诚实让我们写一个格式测试将匹配图形目标:

To "stay honest" let's write a format test will match the graphic goal:

 for (int i = 0; i < data[0].Length; i++)
{
    // write the row headers
    Console.Write("{0}{1}", data[0][i], "\t");

    for (int j = 0; j < data[1].Length; j++)
    {
        // write the values
        Console.Write("\t{0}{1}",data[2][(i * 2) + j], "\t");
    }

    Console.WriteLine();
}

// write the column headers
foreach (var str in data[1]) Console.Write("\t\t{0}", str);

所以,让我们粗略勾勒出你的工作,然后,创建图形表示......记住这只是一个想法.. 。



0.在数据值和颜色之间创建某种地图(字典?)



1.每行:



a。显示行ID:使用标签?



b。对于行中的每一列



1.创建一个面板并根据您的颜色贴图设置其背景颜色(#0)



2.将值放在面板中...面板中心的标签控件?



3.将面板放在面板中行。



4.当所有行都完成时:做正确的事情来创建最后一行下面的列标签。



这个草图考虑使用对象(面板,标签)而不是使用绘图;但是,没有什么可以阻止你使用油漆事件,画笔,钢笔等。

So, let's rough-sketch out what you do, then, to create the graphic representation ... remember this is just an idea ...

0. create some kind of map between data-values and colors (Dictionary ?)

1. for each row:

a. show the row ID: use a Label ?

b. for each column in the row

1. create a Panel and set its backcolor based on your value to color map (#0)

2. put the value in the Panel ... a Label Control centered in the Panel ?

3. position the Panel in the row.

4. when all rows are finished: do the right thing to create the column labels below the last row.

This sketch has considered using objects (Panels, Labels) rather than using Drawing; but, there's nothing stopping you from using the Paint Event, brushes, pens, etc.


这篇关于如何在C#中绘制带有非数值变量的图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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