1. in the controller, I write a public void function and do something like
Code: Select all
Steema.TeeChart.Web.WebChart WebChart1 = new Steema.TeeChart.Web.WebChart();
WebChart1.Chart.Header.Text = "Chart for blah blah";
Steema.TeeChart.Styles.FastLine Line1 = new FastLine();
WebChart1.Chart.Series.Add(Line1);
Line1.Title = "blah blah blah";
Line1.Color = Color.Black;
WebChart1.Width = 640;
WebChart1.Height = 480;
WebChart1.Chart.Legend.Visible = false;
/*
* skip how I get the data from database
* and assign into List<string> xvalue and yvalue
*/
for (var i = 0; i < xvalue.Count(); i++)
{
Line1.Add(Convert.ToDateTime(xvalue.ElementAt(i).ToString()), Convert.ToDouble(yvalue.ElementAt(i).ToString()));
}
Response.Clear();
Response.ContentType = "image/jpeg";
Response.BufferOutput = true;
using (MemoryStream ms = new MemoryStream())
{
WebChart1.Chart.Export.Image.JPEG.Save(ms);
ms.WriteTo(Response.OutputStream);
ms.Flush();
ms.Dispose();
ms.Close();
}
GC.Collect();
Code: Select all
<img src="/GetChart" width="640" height="480">
it become ...
for scroll, maybe I can just export a very large chart and put it into a div...let the client scroll the div...
but I would like to know if there are any easier way to export a zoomed image? (cause i don't want to do all the calculation myself...)
I am thinking to do something like this, write some javascript in the view handle how to trigger the zoom/scroll and use ajax to call the controller.
In the controller, before I save the chart to the stream, I save it in the session, so that when zoom is trigger,
it get the chart from session, do the zoom, export it to the stream and let the javascript handle the rest.
Before I try this, I need to make sure I can zoom a chart and export as a image.
I modify the code of the GetChart function so that every chart will be zoomed once it load...
The problem is, when i try to do something like this before export it to stream
Code: Select all
WebChart1.Chart.Zoom.ZoomPercent(120.0);
it seems it is not doing the zoom, the image export to the stream is a empty chart
with the min and max are both 0 can't see the FastLine.
Anyone have done something like this before?