Sam
Sam

Reputation: 7678

How can I make a tiny line graph in .net

How can I make a little line graph with .net like shown in the sites below?

http://monitor.red-gate.com/

or

http://bandcamp.com

( http://bandcamp.com/img/schwing.gif )

Thanks for your input.

Upvotes: 0

Views: 249

Answers (2)

IAbstract
IAbstract

Reputation: 19881

Consideration: Graph must be drawn on UI thread, so how responsive do you want the graph (real-time or delayed)?

Layout a graph (I do this on paper) to determine X and Y ranges, limitations, etc. This will help you get a clear vision of what you want.

Putting this together without a way to test, but this might get you going in the right direction. I haven't ever created anything quite like a 'sparkline'.

Point newPoint;
Point lastPoint;

void SetNewPoint( Point NewPoint );
{
    newPoint = NewPoint;
    myPicBox.Refresh ( ); // include the Rectangle area to refresh
}

void myPicBox_Paint ( object sender, PaintEventArgs e)
{
    // grab Graphics handle
    // paint line from lastPoint to newPoint

    // you will have to keep a collection of points if redrawing the entire graph
}

Upvotes: 0

ondrejsv
ondrejsv

Reputation: 505

These little line graphs are called sparklines - this is the keyword you need. There are plenty of ways, doing it on a client with jQuery or hacking ASP.NET Charting or even DYI with System.Drawing.

Upvotes: 3

Related Questions