Grant Killian's Blog

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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!


Posted Wed, Mar 9 2005 12:56 PM by grant.killian

[Advertisement]

Comments

Mnaickam wrote re: Powerful Web Charting with NPlot
on Thu, Jul 21 2005 4:01 PM
I agree to you, that it helps in developing scientific graphs.
I am also involved in the same.
Can u let me know, whether there is any way to drop the saturday and sundays dates in pointplot charts.
Bcoz there is sunday and saturday dates in the table but the nplot library draws it.
Can u tell me some ways to get rid of this.
my mail id is manick_cse@yahoo.com
Sesh wrote re: Powerful Web Charting with NPlot
on Thu, Aug 23 2007 10:59 PM

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

Ariane wrote re: Powerful Web Charting with NPlot
on Sun, Oct 14 2007 3:53 AM

Its a great example ! Thanks !!

Sean Houng wrote re: Powerful Web Charting with NPlot
on Thu, Jan 3 2008 4:33 PM

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

Douglas wrote re: Powerful Web Charting with NPlot
on Fri, Jan 16 2009 2:00 PM

I've just started playing with NPlot myself.  The only way I've seen to see the coordinate is to use:

      "myNplot.ShowCoordinates = True"

That puts a floating text box on your mouse pointer that changes with every pixel movement.

The only other way that I've found is to use an arrow, but that's a lot of work since you have to create an arrow for each individual point.