CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Grant Killian's Blog

No, this has nothing to do with beer -- but maybe it should?

Powerful Web Charting with NPlot

I previously considered the free web charting component from Carlos Aguilar to be my main web chart tool . . . but I recently strayed and found a new web chart component.  NPlot has become my new main web charting squeeze because it gives me more control over the chart surface area, plotting behaviour, etc.  Carlos Aguilar's component is quick and simple and will still be useful for basic web charting, but NPlot is the more sophisticated alternative. 

It's hard to describe unless you've worked with both charting tools, but I've got considerably more control when I use NPlot.  NPlot is still in development so you have to make due without much documentation and other polishes, but I really like what they've got so far.  NPlot has a much more scientific aspect to it, with Abscissa and other slick math nerdy things.  A project I'm working on requires some scientific data presentation and NPlot gives me the control I need and the customer wants. 

Since the docs aren't available yet, here's a snippet that will get you up and running:

  • Set a reference to the NPlot assembly (NPlot.dll) -- assuming you've downloaded the files from http://netcontrols.org/nplot/
  • Add a PlotSurface2D control on your web form (drag and drop it or manually add it with the Register ASPX Page directive and add the control tag "<cc1:PlotSurface2D id="surface" runat="server" Width="200px" Height="100px"/>" to your web form
  • Here is the quick-and-dirty sample code for your page Load event (in VB -gasp- since our customer requested we work in it):

surface.Title = "My Title"
Dim lp As LinePlot = New LinePlot
lp.DataSource = New Integer() {1, 5, 3, 4}
lp.Color = Color.RosyBrown
Dim dates As ArrayList = New ArrayList
dates.Add( CDate( "11/1/2004" ) )
dates.Add( CDate( "11/11/2004" ) )
dates.Add( CDate( "11/27/2004" ) )
dates.Add( CDate( "12/1/2004" ) )
lp.Color = Color.Blue
lp.AbscissaData = dates
surface.Add(lp)
surface.XAxis1.Label = "x-axis label"
surface.Refresh()

Oh yeah, if you want another reason to check out NPlot, it looks like the developers (Matt Howlett and Paolo Pierini) are into the Mono project after a fashion -- I don't know the full pedigree, I just know I can get great web reports out of it.  Keep up the great work!



Comments

Sesh said:

hi,

Do you know how to add datapoints to a plot during run time. My application continuously reads data and I would like to dynamically update this.

thanks

Sesh

# August 23, 2007 10:59 PM

Ariane said:

Its a great example ! Thanks !!

# October 14, 2007 3:53 AM

Sean Houng said:

Is there a way to show the data (coordinate values) of a point in the line plot?

For example, in Carlos Aguilar's webchart, the line chart can show them through the code "linechart.datalabels.visible = true".

Is there a similar call in NPlot's tool?

Thanks

# January 3, 2008 4:33 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!