Question

I have a project in c# and I need to show sparkline graphs that there info come from .CSV file. Im working with Windows form application and i cant find anything that work on that. I need to have alot of sparkline graphs under each other.

do I need to change from Windows form ? if so to what? I cant do it as a web page.

my professore brought us this sites:

P.S. I'm writing this in c#.

Was it helpful?

Solution 2

The first site your professor suggested can use WPF which is not web based.

May I suggest you go over MSDN - WPF and then turn to the site suggested?

OTHER TIPS

You should definitely learn to use WPF, but it's possible to implement sparkline with winforms standard controls. Correct me if I'm wrong, but sparkline is a simple line chart.

Check out documentation for Chart control. You should set ChartType to SeriesChartType.Spline to draw sparkline.

Example: To achieve similar appearance like in the blogpost linked

var series = new Series("First")
                         {
                             ChartType = SeriesChartType.Spline, //line chart
                             ChartArea = "chartArea", 
                             Color = Color.White
                         };
//generating data
var random = new Random();
for (int i = 0; i < 50; i++)
{
    //random values
    series.Points.AddXY(i, random.Next(100));
}

//creating display area
var chartArea = new ChartArea("chartArea")
                            {
                                //hiding grid lines
                                AxisX =
                                    {
                                        LineWidth = 0,
                                        IntervalType = DateTimeIntervalType.NotSet,
                                        LabelStyle = {Enabled = false},
                                        MajorGrid = {LineWidth = 0},
                                        MajorTickMark = {LineWidth = 0}
                                    },
                                AxisY =
                                    {
                                        LineWidth = 0,
                                        LabelStyle = {Enabled = false},
                                        MajorGrid = {LineWidth = 0},
                                        MajorTickMark = {LineWidth = 0}
                                    },
                                BackColor = Color.Black
                            };

//creating chart control
var chart = new Chart {Dock = DockStyle.Fill, BackColor = Color.Black};
chart.ChartAreas.Add(chartArea);
chart.Series.Add(series);

//add chart control to form
Controls.Add(chart);

And the result is:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top