Sign in to follow this  
jcoutre4

Displaying Multiple Charts

Recommended Posts

I'm just starting out with FusionCharts and have used the basic example for ASP.NET as a basis to make different charts successfully, but now when I try and put two of them on the same page in a simple HTML table the charts won't show. I've attached my code so I hope somebody can point out where I've gone wrong. Thanks in advance!

 

<%@ Page Language="C#" AutoEventWireup="true" Inherits="BasicExample_BasicChart" Codebehind="Chart3.aspx.cs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>FusionCharts - Simple</title>
        <!-- FusionCharts script tag -->
        <script type="text/javascript" src="../fusioncharts/fusioncharts.js"></script>
        <!-- End -->
    </head>
    <body>
        <table style="width:100%">
        <tr>
        <td>
        Chart 1
        </td>
        <td>
        Chart 2
        </td>
        </tr>
        <tr>
        <td>
        <div style="text-align:center">
            <asp:Literal ID="Literal1" runat="server"></asp:Literal>
        </div>
        </td>
        <td>
        <div style="text-align:center">
            <asp:Literal ID="Literal2" runat="server"></asp:Literal>
        </div>
        </td>
        </tr>
        </table>
    </body>
</html>
 
 
and my Code Behind:
 
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
// Use the `FusionCharts.Charts` namespace to be able to use classes and methods required to create charts.
using FusionCharts.Charts;
public partial class BasicExample_BasicChart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Initialize the chart.    
        Chart sales = new Chart("pie3d", "myChart", "600", "300", "jsonurl", "../Data/Data.json");
        // Initialize the second chart.
        Chart chart2 = new Chart("column3d", "myChart2", "600", "400", "jsonurl", "../Data/Data2.json");
        // Render the chart
        Literal1.Text = sales.Render();
        Literal2.Text = chart2.Render();
    }
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this