Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 11-Dec-14 8:52am
v2
Comments
Sergey Alexandrovich Kryukov 11-Dec-14 11:31am    
There could be many ways to render such picture calculated out of your input data, whatever it is. First, it all depends on what graphics do you use (WPF, forms, ASP.NET, Silverlight, etc...).
What have you tried so far? What problems have you faced?
—SA
BillWoodruff 11-Dec-14 12:57pm    
I join with Sergey in asking you to state what MS technology stack you are using here.

Also: you mention "rules;" could you give more details on how those rules are defined: are the rules "fixed," or are they constructed dynamically ?
ali_crash 11-Dec-14 14:49pm    
I am so sorry, I forgot to tell , it's a simple windows form application. I have some rules for my fuzzy Knowledge base and I like to show them on charts. I wrote this program in console application mode first, then I decide to write it in form and with graphical elements.

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.
 
Share this answer
 
Comments
ali_crash 11-Dec-14 18:50pm    
I saw this before and it doesn't help me much.
did you see my chart sample? do you know how we can draw like that?
share with me.
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:
C#
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:
C#
 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);
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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900