473,473 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is there any chart control through which we can display it in a webpage in asp.net

29 New Member
Is there any chart control through which we can display it in a
webpage in asp.net.
Aug 6 '07 #1
9 1518
TRScheel
638 Recognized Expert Contributor
I assume you mean chart as in a graph, not chart as in a list.

If so, there are options you can purchase but nothing that comes for free in the framework, unless you count building your own solution.
Aug 6 '07 #2
yogeshtiwarijbp
29 New Member
is there any help in creating ur own chart
Aug 6 '07 #3
TRScheel
638 Recognized Expert Contributor
You could cheat with tables. If you gathered a bit of values, you could then create a table with the number of columns equal to 2 + the number of values. You would then have the first column as the units of the graph, the second column chop the table into values (0, 10, 20, etc), and the following columns have colored backgrounds to represent their value in graphical form. You would have one header row and one footer rows. The header row would include your title, the first footer row would have your column names. With select use of borders, you would have a fairly nice looking graph.

You could flip it and have a horizontal graph.

For circular graphs, its a bit more difficult. You would actually need to create an image and display it.
Aug 6 '07 #4
yogeshtiwarijbp
29 New Member
thank u sir but can u provide me one example in asp.net using c# or v.b
You could cheat with tables. If you gathered a bit of values, you could then create a table with the number of columns equal to 2 + the number of values. You would then have the first column as the units of the graph, the second column chop the table into values (0, 10, 20, etc), and the following columns have colored backgrounds to represent their value in graphical form. You would have one header row and one footer rows. The header row would include your title, the first footer row would have your column names. With select use of borders, you would have a fairly nice looking graph.

You could flip it and have a horizontal graph.

For circular graphs, its a bit more difficult. You would actually need to create an image and display it.
Aug 6 '07 #5
TRScheel
638 Recognized Expert Contributor
In your page somewhere:

Expand|Select|Wrap|Line Numbers
  1. <asp:Label ID="lblGraph" runat="server" Text="" />
  2.  

In you code when you want to create the graph:

Expand|Select|Wrap|Line Numbers
  1.         Dim values As Integer() = {23, 55, 64, 44, 91, 54, 12, 88, 67, 75}
  2.         Dim graph As String = String.Empty
  3.         graph = "<table border='1'>"
  4.         For i As Integer = 0 To 10 Step 1
  5.             graph = IIf(i = 5, String.Format("{0}<tr><td>Random Grades(%)</td><td>{1}</td>", graph, (10 - i) * 10), String.Format("{0}<tr><td></td><td>{1}</td>", graph, (10 - i) * 10))
  6.             For Each y As Integer In values
  7.                 graph = String.Format("{0}<td style='background:{1}'></td>", graph, IIf(y / 10 >= (10 - i), "#FF0000", "#FFFFFF"))
  8.             Next
  9.             graph = String.Format("{0}</tr>", graph)
  10.         Next
  11.  
  12.         graph = String.Format("{0}<tr><td colspan='2'></td>", graph)
  13.         For Each y As Integer In values
  14.             graph = String.Format("{0}<td>{1}</td>", graph, "GuyName")
  15.         Next
  16.         graph = String.Format("{0}</tr>", graph)
  17.  
  18.         graph = String.Format("{0}<tr><td colspan='2'></td><td align='center' colspan='{1}'>Student Names</td></tr></table>", graph, values.Length)
  19.  
  20.         lblWrite.Text = graph
  21.  
Where the array 'values' should be changed to reflect your data. You might also create an object to hold the names of each item and show that in your graph. This is a VERY rough draft of what you could do. I would suggest playing with it before using it.
Aug 6 '07 #6
yogeshtiwarijbp
29 New Member
Thank u sir for ur help and support sir i want to ask one question we can also
create graph using asp.net namespace "using systems.Drawing". Can u provide me some example .
thanking u sir
yogesh

In your page somewhere:

Expand|Select|Wrap|Line Numbers
  1. <asp:Label ID="lblGraph" runat="server" Text="" />
  2.  

In you code when you want to create the graph:

Expand|Select|Wrap|Line Numbers
  1.         Dim values As Integer() = {23, 55, 64, 44, 91, 54, 12, 88, 67, 75}
  2.         Dim graph As String = String.Empty
  3.         graph = "<table border='1'>"
  4.         For i As Integer = 0 To 10 Step 1
  5.             graph = IIf(i = 5, String.Format("{0}<tr><td>Random Grades(%)</td><td>{1}</td>", graph, (10 - i) * 10), String.Format("{0}<tr><td></td><td>{1}</td>", graph, (10 - i) * 10))
  6.             For Each y As Integer In values
  7.                 graph = String.Format("{0}<td style='background:{1}'></td>", graph, IIf(y / 10 >= (10 - i), "#FF0000", "#FFFFFF"))
  8.             Next
  9.             graph = String.Format("{0}</tr>", graph)
  10.         Next
  11.  
  12.         graph = String.Format("{0}<tr><td colspan='2'></td>", graph)
  13.         For Each y As Integer In values
  14.             graph = String.Format("{0}<td>{1}</td>", graph, "GuyName")
  15.         Next
  16.         graph = String.Format("{0}</tr>", graph)
  17.  
  18.         graph = String.Format("{0}<tr><td colspan='2'></td><td align='center' colspan='{1}'>Student Names</td></tr></table>", graph, values.Length)
  19.  
  20.         lblWrite.Text = graph
  21.  
Where the array 'values' should be changed to reflect your data. You might also create an object to hold the names of each item and show that in your graph. This is a VERY rough draft of what you could do. I would suggest playing with it before using it.
Aug 7 '07 #7
yogeshtiwarijbp
29 New Member
thank u sir 4 ur help and support sir i want to ask u one question we can also use .net namespace using "systems.Drawing". Can u provide me some example .
thanking u sir
yogesh
Aug 7 '07 #8
TRScheel
638 Recognized Expert Contributor
thank u sir 4 ur help and support sir i want to ask u one question we can also use .net namespace using "systems.Drawing". Can u provide me some example .
thanking u sir
yogesh
Oh that can be tricky, but I enjoy the challenge, so I will be back in a bit with an example on how to do it.
Aug 9 '07 #9
TRScheel
638 Recognized Expert Contributor
Figured it out.

You have to add:

Expand|Select|Wrap|Line Numbers
  1. <img src="Chart.aspx" />
  2.  
to the page in question.

In that charts page, your code should contain:

Expand|Select|Wrap|Line Numbers
  1. public Color[] CreatePieChart(int width, int height, Color backgroundColor, uint[] values)
  2. {
  3.     Color[] colors = new Color[values.Length];
  4.     using(Bitmap bmp = new Bitmap(width, height))
  5.     {
  6.         using (Graphics gfx = Graphics.FromImage(bmp))
  7.         {
  8.             gfx.Clear(backgroundColor);
  9.  
  10.             uint total = 0;
  11.             for (int i = 0; i < values.Length; i++)
  12.             {
  13.                 total += values[i];
  14.  
  15.                 colors[i] = Color.FromArgb(128, Color.FromArgb(new Random().Next()));
  16.             }
  17.  
  18.             float startAngle = 0;
  19.             for (int i = 0; i < values.Length; i++)
  20.             {
  21.                 float endAngle = startAngle + (((float)values[i] / (float)total) * 360f);
  22.                 gfx.FillPie(new SolidBrush(colors[i]), new Rectangle(0, 0, width, height), startAngle, endAngle);
  23.                 startAngle = endAngle;
  24.             }
  25.  
  26.             Response.ContentType = "image/jpeg";
  27.             bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
  28.         }
  29.     }
  30.  
  31.     return colors;
  32. }
  33.  
That should be fairly easy to understand whats going on as far as parameters are concerned. The random color generator, well, is crap. I would create a different algorithm for it. Otherwise its fairly simple. It goes to the output stream so thats the reason for needing another page to view that page as a picture, it destroys all the content on it. If you (or anyone else for that matter) has questions about this, shoot away.
Aug 9 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jim | last post by:
I have this chart on a form. I'm trying to get this chart to render only if the user chooses to do so. This because of that the chart is quite complex and takes some time to render. I know that I...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
8
by: LB | last post by:
Hello everybody I'm learning how to create pie chart using OWC. I'm able now to create a pie. But I can not figure out how to do the following : - for each pie, when mousing over, I would like...
5
by: Tomaz Koritnik | last post by:
Anyone knows of free or commercial pie chart control that has this features: - I need only 2D pie chart type - Can be commercial but not too expensive - Save chart to WMF or EMF - Since chart...
2
by: JP SIngh | last post by:
Hi All We urgently needs some help please. We need to create an org chart from our employee data but struglling. We are using ASP with SQL Server 2000. Does anyone know of a commercial...
0
by: Wayne | last post by:
I am charting data from a query that consists of a Date/Time field and a Number field. The Date/Time field is the x scale on my chart. Sometimes data is collected from different times during the...
0
debasisdas
by: debasisdas | last post by:
Here's a simple VB6 code snippet that uses the MSChart control to display Charts in VB6.0. To use this sample, please following steps Create a new project in VB6 Pull down the Project menu and...
9
by: Mel | last post by:
I have some Asp.net 2.0/vb.net code that creates a gantt chart with some dependencies as a new MS Project (.mpp) file. How would I show this resulting .mpp file on an Asp.net webpage? I want to...
14
by: Wayne | last post by:
I posted about this problem over 12 months ago and even after Vista SP1 the problem still exists when running an Access database (A2003 and A2007 tested) under Vista. A workaround was suggested by...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.