|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 6/28/2007 11:42:58 AM
Posts: 1,
Visits: 6
|
|
Hello,
I appreciate the example code that was placed in documentation, but it's not really helping in my certain application of Fusion Charts. The example calls GetFactorySummaryChartHtml and populates the object xmlData to be used in the execution of RenderChart in FusionCharts.js.
I need to populate multiple charts from the same query or sets of queries. I can certainly create different xmlData sets, but what's the best way to go about executing RenderChart multiple times instead of via the Return in the example?
<%=GetFactorySummaryChartHtml()%>
public string GetFactorySummaryChartHtml()
{
//In this example, we show how to connect FusionCharts to a database.
//For the sake of ease, we've used an Access database which is present in
//../DB/FactoryDB.mdb. It just contains two tables, which are linked to each
//other.
//xmlData will be used to store the entire XML document generated
string xmlData;
//Generate the chart element
xmlData = "";
//Iterate through each factory
string factoryQuery = "select * from Factory_Master";
using (OdbcConnection connection = DbHelper.Connection(DbHelper.ConnectionStringFactory))
{
using (OdbcCommand factoryCommand = new OdbcCommand(factoryQuery, connection))
{
using (OdbcDataAdapter adapter = new OdbcDataAdapter(factoryCommand))
{
DataTable table = new DataTable();
adapter.Fill ( table );
foreach ( DataRow row in table.Rows)
{
string quantityQuery = "select sum(Quantity) as TotOutput from Factory_Output where FactoryId=" + row["FactoryId"].ToString();
using (OdbcCommand quantityCommand = new OdbcCommand(quantityQuery,connection))
{
xmlData += "";
}
}
}
}
connection.Close();
xmlData += "";
}
//Create the chart - Pie 3D Chart with data from xmlData
return FusionCharts.RenderChart("../../FusionCharts/Pie3D.swf", "", xmlData, "FactorySum", "600", "300", false, false);
}
Thanks in advance for any assistance!
|
|
|
|
|
FusionCharts Team
      
Group: Administrators
Last Login: Today @ 5:03:15 AM
Posts: 2,183,
Visits: 514
|
|
You can call renderChart() multiple times - but parameterize the function which returns the XML data to return different XML data based on same recordset.
Thanks, Pallav Nadhani FusionCharts Team
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/14/2007 1:24:45 AM
Posts: 2,
Visits: 9
|
|
| I have a same issue that I want to have multiple charts programatically (each chart stands next to the other one). I have created multiple XML data files but I could not link them to the renderchart function. Can you pls show us a sample code (several code lines ) that we can call renderchart several time with seperate XML file? Thanks a lot.
|
|
|
|
|
FusionCharts Team
      
Group: Administrators
Last Login: Today @ 5:03:15 AM
Posts: 2,183,
Visits: 514
|
|
|
|
|
|
Supreme Being
      
Group: Moderators
Last Login: Today @ 9:29:56 AM
Posts: 870,
Visits: 1,385
|
|
hi,
To render multiple charts in the same page ....
[ This is exclusively for ASP.NET C# though the same technique can be used in any server side technology with some minor tweaks]
What you can do is :
1. In the main page you render multiple charts using renderChart() function a umber of times.
2. For each render you use dataURL method and pass the dataURL to a server side page...say dataGen.aspx with some additional parameters to get sepcific XML as dataURL XML from that page.
e.g.
using InfoSoftGlobal;
String dataURL1=Server.UrlEncode("Datagen.aspx?viewType=monthwise");
response.write(FusionCharts.RenderChart("{SWF}",dataURL1,"",chartID,"400",300",false,false);
String dataURL2=Server.UrlEncode("Datagen.aspx?viewType=factorywise");
Response.write(FusionCharts.RenderChart("{SWF}",dataURL2,"",chartID,"400",300",false,false);
3. Now you build your Datagen.aspx code in a way to mine data from database according to viewType request passed to it, create relevent XML (in a string, say, strXML) and setting Response.contentType="text/xml"
return the XML string : Response.write(strXML);
Regards,
Sudipto Choudhury FusionCharts Team
|
|
|
|