nskirov Posted February 16, 2009 Report Share Posted February 16, 2009 I would like to create multiple charts on my website. My application does not know how many charts are going to be drawn and it will retrieve their data using a service. I was wondering if ChartFX is capable of handling such a scenario and if anyone could point me in the right direction or provide a sample application that does that. IndexOutOfRangeException.zip Quote Link to comment Share on other sites More sharing options...
AndreG Posted February 17, 2009 Report Share Posted February 17, 2009 Sure you can create charts dynamically using Chart FX. I am assuming you have already downloaded the trial, so here is all you need to do. Chart chart1 = new Chart(); chart1.ID = "Chart1"; chart1.Height = 400; chart1.Width = 600; Page.Controls.Add(chart1); Another way you can do this (and have even more control of your charts) is instanciate the chart on code behind and export it. Exporting will create three streams: the chart image, the html image tag and the html image map. You can then modify it (if necessary) and add it to the page. Here is some sample code for that. Chart chart1 = new Chart();System.IO.FileStream fileStream;System.IO.StreamWriter imgMapText;System.IO.StreamWriter htmlTag; fileStream = new System.IO.FileStream(Server.MapPath("chart.jpg"), System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);imgMapText = System.IO.File.CreateText(Server.MapPath("MapTags.txt"));htmlTag = System.IO.File.CreateText(Server.MapPath("HTMLTag.txt"));chart1.ImageSettings.ToolTips = ImageToolTipStyle.AsTitle;chart1.ID = "TestChart";chart1.RenderFormat = "Jpeg"; chart1.RenderToStream(fileStream, imgMapText, htmlTag); imgMapText.Close();htmlTag.Close();fileStream.Close(); Quote Link to comment Share on other sites More sharing options...
nskirov Posted February 18, 2009 Author Report Share Posted February 18, 2009 Exporting sounds more plausible for my project since I get more control over my charts. I do have one concern: will I be able to keep my charts interactive? Quote Link to comment Share on other sites More sharing options...
AndreG Posted February 18, 2009 Report Share Posted February 18, 2009 Rendering to stream will give you more control in the sense that you have the img tag, map and the image itself to modify as you wish. But the only interactivity you will get that way would be tooltips and links. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.