Project High Level Advice Required : Project Multiple Stock Charts RRS feed

  • Question

  • User-1668014665 posted

    I wish to build a control/dll/class what ever. I am a newbie, very green.

    - That will allow me to view multiple stock charts (png graphic) on one html page.
    - That will only send to the html page a png graphic of the chart.
    - No Java, ...ASP.net only with vb.net code.
    - Must ber server side calculations, and send to client the final png chart image.

    Passed Project : I did this in vb6.0 I used a usercontrol to build a chart in a picture box, placed the usercontrol on the vb6.0 windows form then used the controls index property to repeat it many times on one form. Worked great.

    So now I wish to repeat this in Asp.net. I wish to avoid sending to the cleint any heavy control or activex downloads, only want the png graphic to goto the client html web page.


    - Do I build a web form control or a server control, or a dll that sits on the server and send png chart to HTML on client. What Please point me in the correct direction ???
    - How do I repeat the chart images.

    Any demos, downloads out there ???

    Thanks in advance !


    Friday, January 27, 2006 8:41 PM

All replies

  • User-421267774 posted
    I would either do one of two things. Either purchase a charting control which can be costly depending on which one you choose or create classes for handling this. If you create classes just have them return an image or a bit stream. To use the returned image you will either have to have the DevExpress databindable image control or use a custom httphandler. The code for a httphandler is readily available by searching on Google. It has been done may times. However the custom charting will probably not be found posted anywhere for free. If you are wanting to roll your own and allready have experience doing so then go for the class technique. Once you do it you can reuse it in later projects and that saves you more time down the road.
    Saturday, January 28, 2006 2:16 AM
  • User-1668014665 posted

    Thanks for a good response.  I will not be buying any third party control. Need to learn and do my own stuff.


    1) Class that return an "bit stream", whats that ?
    2) Whats DevExpress databindinable image control, what are pros and cons here ?
    3) Whats httphandler, whats pros and cons for this ?

    You didnt mention server control, I only want the image going to the cleint.

    I am interested in "best design", no matter degree of it challenge to build it for a newbie, just to be pointed in the correct area for my research.

    Please advise.

    Saturday, January 28, 2006 1:53 PM
  • User-421267774 posted

    1) Class that return an "bit stream", whats that ?
    I should have said ByteArray but it is just a stream containing the image data.
    2) Whats DevExpress databindinable image control, what are pros and cons here ?
    The DevExpress image control will let you use the streamed image without having to create a custom httphandler. Standard ASP.NET image controls only let you feed an image from an url or location. The DevExpress control will let you databind it to a ByteArray stored in the database or just use the .Content property and shove any ByteArray you want in it. Then the DevExpress control will render that image for you. The only pro really is that it will save you a lot of work. If you use it then you will not have to write a handler to do it for you. The Con is that it costs money, and I guess it kind of makes you lazy but the least amount of code you can use usually translates into improved performance.
    3) Whats httphandler, whats pros and cons for this ?
    A httphandler in this since will take your image ByteArray and convert it into the full image. Then it will allow you to supply the standard ASP.NET image control with a fake url where the image supposedly resides. The only Pros that I can think of is that you will be able to practice you Google skills abit and that writing your own is free. The Cons is that you are already contemplating writing your own charting control and now you will have to add this to your plate as well.

    Which ever you choose you will be alright. There are a ton of articles about custom httphandlers and displaying image ByteArrays, and of course if you want DevExpress they are always happy to take your money and do it for you. The only thing that I would be worried about is drawing these Charts. I dabbled with it once before and there were a ton of things to consider if you want to make it reusable in other projects. Such as upper and lower bounds, label customization, color changes, and which ever type of chart you choose you may need to be able to make it horizontal or vertical.

    Let me know how it goes and if I can help just drop me a line and I will attempt to guide you in the right direction.

    Saturday, January 28, 2006 3:46 PM
  • User-1668014665 posted

    As I am a vb6.0 convert to vb.net I was expecting to build a custom control that I could out my PNG and then upload that onto the HTML/asp.net page.

    So how do I build the initial chart ?

    In vb6.0 all I did was get user control, place a picture box on it and used those boundaries to draw in lines and objects. Save the control as OCX, as use it as many times as I wish.

    I thought all I would be building is a web server control, place objects on it, draw lines, etc, whatever then save the image as png and send that to the HTML/ASP.net page. So I gues I am building the comparsion to the "DevExpress control" am I not.

    Can you give me advice on what asp.net objects I would use to build the custom chart control.

    Saturday, January 28, 2006 4:47 PM
  • User-421267774 posted

    Yes basically you will be drawing a picture that you cannot see until you convert it and yes I have not checked out the source on the DevExpress image control but it almost has to be doing the same thing as you will.

    When you are drawing the chart it will all be in the System.Drawing namespace Within that you can grap pens, colors, etc. Just like drawing it by hand but you are telling a computer to do it. As one would guess you will start from the upper left hand corner at 0,0 and count pixils from there. What I would do first is the httphandler so that I could play with the drawing stuff and see my output. When you are doing the drawing within that namespace you will see shapes like box, retangle, and such. If you are doing a bar chart, which would be the easiest. I would define the size of the image then draw a retangle with some fill in color. Then devide up the width in pixils of the image size into how many marks I would need. With this knowledge you will be able to substitute your retangle points with the calulated points from the image width. Once you have this setup a loop that will move over and draw as many retangles as needed and place your calculated points in them as you create them. System.Drawing will also let you write text into the image so you can just follow your bar points and move outside of the chart area and place your labels. Then add a title, clean up your code, make any varibles that you may need to adjust later, and return your output as a ByteArray. The output should be simple enough as I think that this is a save option. I know that I made it sound easy but it takes alot of work to get there and even more to make it stable. Oh and don't forget the more bars you add the wider or taller the image will have to be. So you will have to figure that out before you start drawing. I know you can do it. I am no genius and I did one. I had not even touched System.Drawing before when I tryed it, other that for color references. Just think if you can do this you will deffinately be the MAN.

    Saturday, January 28, 2006 10:22 PM
  • User-1372641848 posted
    For building chart check following links, both code were written when asp.net was still in beta, but they works with 1.1 also. they will give you some idea about how to start.

    Creating a Pie Chart on Fly with VB.NET

    Created Exploded Pie Chart Having Click Through Functionality in C#

    Regarding Control then can render image on borwser check this one.

    ImageCanvas Web User Control in ASP.NET

    However I personally will use httphandler instead of this ImageCanvas control.
    Sunday, January 29, 2006 12:43 AM
  • User-1372641848 posted
    BTW: Just go through this site, I created this chart server before 2 years, I can't give source code but going through samples and rendering code will give you some idea.


    Sunday, January 29, 2006 12:58 AM