NPlot Bar Charts

There is a free charting component for ASP.NET by the name of NPlot but it is poorly documented and I could not figure out how to create a simple bar chart. I contacted one of the developers and he sent me some code that pointed me in the right direction.

I have created some sample code in VB.NET and C# which I shall offer to the developers because their Wiki asks for someone to submit some examples of bar charts. I used the Northwind SQL Server sample database as the data source for my bar charts. The Northwind database is frequently used to demonstrate database concepts and anyone may download a copy. The only innovative aspect to my sample code is the rather complicated SQL query I use to get the data. First I get the distinct values for one of the columns and then I get a record count of another column based on the distinct value. This is a fairly difficult query to create but it is useful for getting data for charts of record counts by date.

I also created a NPlot bar chart that used a XML file as the data source. This was pretty difficult because I loaded the XML into a dataset and the columns wound up having a string data type when they needed to have the double data type. I had to create new columns with the correct data type and then use dataset expressions to calculate their values based on the existing columns. Dataset expressions were another NET Framework feature that I’d never heard of.

This entry was posted in ASP.NET, General. Bookmark the permalink.

3 Responses to NPlot Bar Charts

Leave a Reply

Your email address will not be published.