FusionCharts Net Wrapper

by Tommy T 20. April 2009 09:48

A few days ago I needed to be able to create quick graphs on a website, so I surfed around for a while and I found Fusion Charts, they had a nice flash based one. So I downloaded the trial and started playing around with it.

To create a chart you needed to write xml data och add it to a webpage with some calls back to to code behind page. I didn’t like that at all so I started to write a .Net Wrapper so that I could create my charts in a more object-oriented way, by creating objects and setting properties. And finally when I am done I call the RenderChart() method in my object, assign the output to a literal and “wham” there is the chart.

This wrapper is in really really realy early stages, i still have more to fix and its messy so please bare with me until im done with it. I just though I would post it, in case anyone needs it.

The charts that are working are, Bar,Column, Area, Pie,Doughnut and Line for now (both 2D and 3D), bots singel and multiseries and stacked.

  • Settings that can me modified are:
  • Chart Cosmetics (? yes its like that on their page)
  • Margins and Padding
  • Divisional Lines and grids.
  • Number Settings and formatting.
  • Global Style definitions and map to graph objects.
  • TrendLines
  • Advanced background settings
  • ToolTip and more….

To use the the object its pretty easy, all youhave to do is creata a class of any of the following objects.

  • FusionChartsWrapper.Charts.ColumnChart – All Column variant sof the chart.
  • FusionChartsWrapper.Charts.AreaChart – Area charts
  • FusionChartsWrapper.Charts.LineChart – For Line charts
  • FusionChartsWrapper.Charts.PieChart – For pie an donut charts.
  • FusionChartsWrapper.Charts.BarChart for the Bar charts.
  • FusionChartsWrapper.Charts.CombinationCharts – are combinations, but in very experimental stage.

All the objects have the same constructow where you need to supply the following paramters:

ChartType (the charttypes you can create, enumeration)
Path (Path to the folder where the flash files are.
Width (with of the chart)
Height (Height of the chart)

Thats it now you have a a chart object youh can work with. To add data series you need to create a Series object and add it to the Dataseries list of the object.

Like this:

Serie serie = new Serie("2009");

And start adding DataPoints to the serie you do like this:

serie.Data.Add(new DataPoint("Jan",1100));

When you are finished you just add the series to the DataSeries List:

serie.Data.Add(new DataPoint("Oct", 2055));
serie.Data.Add(new DataPoint("Nov", 2199));
serie.Data.Add(new DataPoint("Dec", 2322));

grf.DataSeries.Add(serie);

If you are doing a Multi series graph, remove the “name” of the data point and create Categories. You can se very tiny example in the included web site example.

For the moment there is no validation of any kind, so If you get an Invalid Data when rendering the graph, please go to the documentation on the FusionCharts website to see how to create each graph, I will add at a later time but for the moment I am concentrating on adding chart types.

Here is some screen dumps of the charts:

gf1 Multiseries Column chart 2D

gfdonut 3D donut chart.

Like I said, this wrapper is a ongoing project and if you have any problems contact me and Ill try and help but do not expect to get my full attention, replies might take a day or two.

I hope it help you a little and good luck.

Tommy

Source Code and Test web App. Fusion Charts Wrapper Source Code

Tags: ,

ASP.Net | C#

LightBox.Net revisited

by Tommy T 14. April 2009 07:07

Hi again,

I received an comment from David, where he asked on how to create an thumbnail with you own custom size in this control.

So I thought about it and thought it would be the easiest way to create an aspx page that creates an thumbnail,this page could then be used in your website for other thumnail generation aswell.


All you have to do now is to change the imageurl property and pointto the GenerateThumb.aspx webpage and add some properties to the url.

It would look like this.

 <lbn:hyperlink id="img1" runat="server" imageurl="generatethumb.aspx?image=images/image-1.jpg&width=92&height=92" navigateurl="images/image-1.jpg"  tooltip="Picture 1" />

Easy right ?

Attached is the updated site with the generatethumb aspx included.

 /tommy

LightBox.Net_Updated.zip (1.05 mb)

Tags: , ,

ASP.Net | C#

Linq and Mirosoft.Net

by Tommy T 1. September 2008 03:52

Well the summer is to an end and its time to get back to work :-),

During this autumn its time to learn the "old" technologies like Linq and WCF and others. I spent most part of my summer learning WCF and think its
time to learn Linq.

While starting to look for information I found two useful tools.

LinqPad

A very simple client for talking and creatin Linq Queries directly agaisbt databases. :-D Yihaa I love the open source community.

 



Visual Linq Query Builder

This is an addin to Visual Studio 2008, wher you design and write Linq Queries directly from within The Visual Studio 2008 IDE



So time to learn.

Have a nice day !

/Tommy

Tags: , , ,

ASP.Net | C# | Web 2.0 | Tools

Summertime is down and slow time.

by Tommy T 6. August 2008 04:22
This summer have been very slow, nothing to read, nothing to do at work and everyone is at vacation.
 
So I have been building a web application for my friends, it is an internal one but I will post some techniques I used
int the web application.
 
My friends have started a company delivering all the lost luggage from airlines, they are calling themselves Airport Xpress.

So I am building the administration system for them aswell as a airline page where the customers will be able to
login and get an exact up to date information on all the lugagge on the road.
 
Here is a little teaser :-D
 
The system was built using the following components:
 
  • The new Subsonic 2.1 RepositoryRecord
  • A very layered application to enable propert Testing of the frameworks.
  • Abstract DataFactory, to make it easier switching sources in the backend.
  • Ajax webpages
I will just have to check with my friends what I can post and what I cannot post.
 
Until then.. I wish you a nice day.
 
/tommy
 
 

Tags: ,

ASP.Net | C# | Web 2.0

Small update Website Snapshot

by Tommy T 27. May 2008 00:12

I made a little update to the WebSite Snapshot pages, not the control but the aspx page version.

I enabled the thumbnailer to make a screenshot of the whole webpage, but of course the old option
is still there, all you have to do is to set the switch ?fullheight=false to the query string.

I also tried to thumbnail some problem sites before, Microsoft Webpage is now captured successfully
but yahoo is till problematic. According to a www.surpluscode.com application, ( se earlier posts on this blog)
I have to implement an retry feature and compare with an empty browser.

I will do that but just thought I would make a small update. Here is an example of the fullHeight feature
I made a thumbnail of my own blog.

Note** The thumbnailer is still slow as h***l but If anyone have a tip, please let me know on how to make it run faster.

Oh yes and dont forget to add a reference to  System.Windows.Forms to your website. Pagesa re using the webbrowser control fromt this namespace.

Updated file:

  WebSiteSnapshot.zip (2.01 kb)

I will try to implement the blank image problems as soon as I can. :-D But do remind me if it takes to long.

Have a wonderful day !

/Tommy Turkijvic

Tags:

ASP.Net | C#

Create Thumbnail of Website updated

by Tommy T 30. April 2008 00:56

Hey again,

I  have been receiving some mails and comments about that the control sometimes returns a blank image. I really dont know what causes this, so I started googling around. Some people suggest to implement the mshtml.tlb and implement the interfaces. Which of course would be good but will take some time. The blank image problems seems to arise when the pages are dynamic or contain flash, so maybe the page signals its fully loaded while the dynamic content of the page is still generating site content.

Anyhow while surfing I came across this page . Surplus.code WebPage thumnail maker.

This is a thumbnail of yahoo which usually is a problem.

 

He built a a small application that makes thumnails of webpages and also makes a thumbnail of the full height of the webpage as well, and his application is based on a CodeProject called Extended WebBrowser Control.

So until I implement all the functionality here is the sourcecode for the other thumbnailer control.

 
Thumbnailer_src-0.2.zip (129.67 kb)
Thumbnailer-0.2.zip (95.66 kb)

Give me a week and I will return with an updated websnapshot control that dont return balnk images and enables the possibility to capture the FULL image of the webpage. 

Best regards 

/Tommy 

Tags:

ASP.Net | C#

Embed an ASPX/ASCX file inside a DLL.

by Tommy T 17. April 2008 10:40

Lately I have been building a bunch of graphical controls, or maybe better to say aspx files that returns a image. Then I have been playing around with a web site snapshot generator page.

I wanted to create a webcontrol of this page but didn't want to cache an image to the disk or anything like that, I simply wanted to embed the aspx page into my DLL and access it like an web page from my Webcontrol.

So after a whole lot of searching on the net i finally realized that i had to build a Virtual Path Provider that accesses resource files, in this case mine aspx page.

It is quite simple actually to build one, just create a new class and inherit from System.Web.Hosting.VirtualPathProvider

   1: public class WebResourceVirtualPathprovider : System.Web.Hosting.VirtualPathProvider

There is also a few methods to override and implement, in my case I only needed to implement FileExists and GetFile methods.

In FileExists I simply check if the page requested is my Virtual File, then I return a true otherwise I let the ordinary PathProvider do all the work.

Here is the code for the two methods:

   1: public override bool FileExists(string virtualPath)
   2: {
   3:   if (virtualPath.EndsWith("snapshot.aspx"))
   4:       return true;
   5:   else
   6:       return base.FileExists(virtualPath);
   7: }
   8: public override System.Web.Hosting.VirtualFile GetFile(string virtualPath)
   9: {
  10:    if (virtualPath.EndsWith("snapshot.aspx"))
  11:       return new WebResourceVirtualFile(virtualPath);
  12:    else
  13:       return base.GetFile(virtualPath);
  14: }

As you can see I am returning a VirtualFile when snapshot.aspx is requested. The Web resources Virtual file is actually responsible to get the aspx file from the resource and stream it back to the browser.

VirtualFile

The WebResourceVirtualFile have to inherit the System.Web.Hosting.VirtualFile and you also have to implement the Open method.

This is how my virtual file class is:

   1: public class WebResourceVirtualFile : System.Web.Hosting.VirtualFile
   2: {
   3:     private string _virtualPath = "";
   4:     string _assemblyPath = "WebSnapShotControlLibrary.snapshot.aspx";
   5:     
   6:     public WebResourceVirtualFile(string VirtualPath)
   7:         : base(VirtualPath)
   8:     {
   9:         this._virtualPath = VirtualPath;
  10:     }
  11:  
  12:     public override System.IO.Stream Open()
  13:     {
  14:         StreamReader _textStreamReader;
  15:         Assembly _assembly = Assembly.GetExecutingAssembly();
  16:         //_textStreamReader = new StreamReader(_assembly.GetManifestResourceStream(_assemblyPath));
  17:         //string[] _names = _assembly.GetManifestResourceNames();
  18:         return _assembly.GetManifestResourceStream(_assemblyPath);
  19:     }
  20:     }

Finished, now we just have to register the the  Virtual Path provider to the ASP.Net Hosting. This should be done as soon as possible, The best method is to register it in the Global.asax file in the App_Start method.

I wanted to use it in my control so I register it in my control and also checks if the VirtualPathProvider is already regostered to avoid unneccesery regostrations.

It looks like this:

   1: Type vprov = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetType();
   2:  
   3: if (vprov.Name.ToLower() != "webresourcevirtualpathprovider")
   4:     System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new WebResourceVirtualPathprovider());

Anyhow this is just a brief explanation, I will enclose the actual project and code for you, so you can download it and explore it yourself. I used the SolutionZipper to zip my Vs2005 solution and I am not sure it zipped it correctly, but all the files are there.

Thanks and have a good day !

/Tommy Turkijevic

Tags:

ASP.Net | C#

Preparing NLOG and Webservices Visual Studio Solution

by Tommy T 11. April 2008 03:49

I am preparing a VS Solution and a little articel on how to use NLOG for logging in your applications and how to configure
a webservice to accept input from NLOG .

The Source code will be for the WebService, SQL Server tables and procedures and of course a simple solution with Logging functionality in it. 

Meanwhile here is the link to LOG a .Net Logging library

Regards

/Tommy Turkijevic 

Tags:

ASP.Net | C#

Create Thumbnail of a Website using C# and ASP.Net

by Tommy T 28. March 2008 10:23

I was just curious and started investigating how to make a snaphost/thumbnail of a webpage and to use it in a ASP.Net webpage.

So once again, after searching the web I found a snippet on how to do this. I had to change it a little since the code was in APP_Code folder but i wanted everything to be contained in a aspx page.

After a little fiddling around i created a Snapshot page for use in any asp.net website.

 

How to use:

Place an Image control in you webpage and set the ImageUrl to the snapshot.aspx page. NOw you can set some querystring options for the page.

 

site This tells the page which site to capture
width width of the thumnail
height height of the thumbnail
capWidth What Width should the Site capture be (the thumbnail is based on this size)
capHeight What Height should the Site capture be.

So here are a few examples:

   1: snapshot.aspx?site=www.tommyt.se&width=100&height=80&capWidth=800&capHeight=600

Now the page will capture a image sized 800x600 of www.tommyt.se sita and create a thumbnail with the size 100x80.

I have not fully errorhandled it but as soon as its done this page will be updated with the code. I will also try and create a HttpHandler for use in ASPX pages.

Here is the source code:

 

 

 

Good luck and have fun

/Tommy

Technorati Tags: ,,,

Tags:

ASP.Net | C#

About the me

Im 38 years old and working as a System Architect. I have been woring in the IT field the last 16 years and covered most of the techniques.

In my spare time I train Kyokushin Karate and try to spend as much time as possible with my family.

On this blog I am trying to post things and Code i make or encounter on the www.

Page List

RecentComments

Comment RSS