Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
Newie Question for Simple charting
posted

We have is a somewhat unique situation.  we are not using standard Asp.net which produces .Aspx pages, we are using C# that will grab data from a sql server database and do some other manipulations then output it to a standard html page.

so for example we will execute a function on our website that will invoke a dll that will grab data, format it and them do a response.write to a html page.

it's our understand that your charting tool is a server control that requires a webform as a container in order for it to be used.  It is our hope that we have a misunderstand and that we can invoke the your charting tool object via it's API and dynamically create, render it to an html page since our enviroment and content management software does not allow nor support the use of .NET webforms.  if you need additional information please let me know.

 thanks for your assistance as we try to determine if your product will in our unique environment.

 any examples to generate a simple graph would be greatly appreciated.

I am looking for something like this

 

Chart newChart = new Chart();

newChart.ID = "MyChart1";

newChart.Width = 400;

newChart.Height = 200;

Label1.Text=newChart.RenderControl();

Parents
No Data
Reply
  • 28464
    posted

    There are several ways to proceed - if you just need the image, you can do something along the lines of:

     Infragistics.WebUI.UltraWebChart.UltraChart chart = new Infragistics.WebUI.UltraWebChart.UltraChart();
    chart.DataSource = Infragistics.UltraChart.Data.DemoTable.Table(0);
    chart.Data.DataBind();
    chart.SaveTo("image.gif", System.Drawing.Imaging.ImageFormat.Gif);

    and then create custom html with <img> to point to it.

    If you need the HTML and client-side functionality, you may try something to what I do below, but I really cannot guarantee it will work in all cases without the ASP.NET Page/Form infrastructure. 

    Typically all ASP.NET server controls require a server-side from (e.g. <form runat="server">) in order to operate correctly. In this case, however I was able to get something runnig that may help you get started in your situation - the following code returns the chart html in what (as far as I can tell) seems to be the correct chart output

            UltraChart ultraChart1 = new UltraChart();
            ultraChart1.ID = "UltraChart1";

            StringWriter stringWriter = new StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

            ultraChart1.RenderControl(htmlWriter);

            string chartHtmlOutput = stringWriter.ToString();

    You can then use chartHtmlOutput and place it in the place needed in your custom presentation framework. 

    Still, this is just a simple case and a place start, I cannot guarantee that the chart will work in all cases without the ASP.NET Page infrastructure. 

    You can also try creating a fake server-side form and add the chart instance there:

            HtmlForm form = new HtmlForm();
            UltraChart ultraChart1 = new UltraChart();
            ultraChart1.ID = "UltraChart1";

            form.Controls.Add(ultraChart1);

Children