I've already written about the Open Flash Chart and ASP.NET library to work with it. Since that time the version 2 of the flash component has been released. The flash component now uses JSON format of data, some new types of charts has been added such as horizontal bar chart and there are other “cool new features”.
The great work was done this post. The author adapted the library to use JSON format also added support of some new chart types as well as new properties. All I've done after it it just some refactoring testing, and bugfixing the library to support all the chart types.
I added two examples of lib usage in the project: the static 2 charts on page and the page with a chart inside UpdatePanel control to show how to properly embed in that case. The demo pages are here. The source can be downloaded from codplex (VS2008 solution).
The second chart on the default.aspx page uses a custom data page and does not use ASP.NET cache. The control property SpecificDataHandler is designed to set the custom data page
<OpenFlash:OpenFlashChartControl runat="server" ID="ofcTest2" Height="350" Width="500" OnDrawChart="DrawChart" SpecificDataHandler="FlashData.aspx"/>
The FlashData.aspx is an ordinal ASP.NET page with nothing in aspx file and a code which simply builds and flushes an Graph object in the codebehind.
public partial class FlashData : System.Web.UI.Page
{
protected override void Render(HtmlTextWriter writer)
{
Graph g = new Graph();
g.Title = new Title("Bar Chart");
var bar = new BarSketch(3);
Random random = new Random();
bar.Fillalpha = 0.4;
bar.Text = "Test";
bar.Fontsize = 10;
int max = int.MinValue;
for (int i = 0; i < 12; i++)
{
int value = random.Next(i, i * 2);
if (value > max)
max = value;
var val = bar.NewValue(i.ToString(), value);
bar.Values.Add(val);
}
g.AddElement(bar);
g.OnBuildComplete();
writer.Write(g.ToPrettyString());
}
}
This approach is useful for web farms.
If you made a bug in the JSON you’ll have the most common Error #2032 which means that the data for the chart can not be loaded. To solve it the chart has properties DataHandlerUrl and SpecificDataHandler and you can exactly specify the HttpHandler or the specific data handler address.
Related posts: Open Flash Chart
Currently rated 4.0 by 1 people
- Currently 4/5 Stars.
- 1
- 2
- 3
- 4
- 5