Table of Contents
FusionCharts XT with ASP.NET
- Part 1 – Create JavaScript charts in ASP.NET (C#)
- Part 2 – Plot JavaScript charts using SQL Server data
- Part 3 – Create Drill-Down charts in ASP.NET(C#)
- Part 4 – Create LinkedCharts in ASP.NET(C#)
FusionCharts XT Download Package > Code > CS > Bin > FusionCharts.dll. By referencing this library, rendering charts is just one line of code! Let us see how.. FusionChartsXT_with_ASPNET.Solution Explorer > Add New Item > Web Form. Keep the name as Default.aspx.Charts folder from the FusionCharts Download Package and paste it in the Solution Explorer.Default.aspx: <script src="Charts/FusionCharts.js" type="text/javascript"></script>
Solution Explorer > Add Reference > Browse. Now browse to FusionCharts XT Download Package > Code > CS > Bin > FusionCharts.dll.Default.aspx.cs, include the namespace of this library by writing using InfoSoftGlobal;
/path_to/data_provider.aspx, which will execute queries on the database, construct the XML data and output it to the stream, with content type set to text/xml. For this example, we will point FusionCharts XT to an XML file’s URL. Create a Literal tag in Default.aspx, and give it a unique ID. We will write the code required to generate a chart to this literal. Then, FusionCharts.js would process this code and show a chart instead. In Default.aspx.cs, within the Page_Load method, write the following code: // Set the rendering mode to "javascript". (Default is "flash")
FusionCharts.SetRenderer("javascript");
literal_1.Text = FusionCharts.RenderChart("FusionChartsXT/Column2D.swf", "Data/Data.xml", "", "browser_share", "640", "340", false, true);
Save. Run the project (F5). This is the chart that you should see: You were able to render a chart in your .NET app with just one single line! Literal tag with ID as literal_2. In the code-behind, comment the line of the RenderChart() method, and write the following code after it: // xmlStr contains the XML data required for the chart
String xmlStr = "";
// Set rendering mode to "javascript".
FusionCharts.SetRenderer("javascript");
literal_2.Text = FusionCharts.RenderChart("FusionChartsXT/Column2D.swf", "", xmlStr, "browser_share_2", "640", "340", false, true);
Save. Run the project (F5). You should see the following chart: // < ![CDATA[ // < ![CDATA[ // < ![CDATA[ // < ![CDATA[ FusionCharts.setCurrentRenderer('javascript'); var myChartId = 'browser_share_3'; var myChartSWF = '/Assets/fusioncharts/Column2D.swf'; var myChartWidth = '660'; var myChartHeight = '400'; document.write('‘); var chartObj = new FusionCharts( myChartSWF, myChartId, myChartWidth, myChartHeight); chartObj.setXMLData(”); chartObj.render(myChartId + ‘container’); // ]]> RenderChart() method: FusionCharts.SetDataFormat("json");
We provide a tool to convert XML to JSON. You can find it in FusionCharts XT Download Package > Tools > FCDataConverter. The JSON data for the above chart is: {
"chart": {
"caption": "Top 5 Employees for 2011",
"palette": "3",
"showvalues": "0",
"numberprefix": "$",
"useroundedges": "1"
},
"data": [
{
"label": "Leverling",
"value": "100524"
},
{
"label": "Fuller",
"value": "87790"
},
{
"label": "Davolio",
"value": "81898"
},
{
"label": "Peacock",
"value": "76438"
},
{
"label": "Callahan",
"value": "55091"
}
]
}
To create pie charts and generate statistical data, you’ll find this list of the best…
To implement FusionCharts in a dynamically resizing flexbox layout, ensure that the chart's dimensions are…
At FusionCharts, we believe in empowering developers and businesses with cutting-edge data visualization tools that…
Ever had a data set that seemed more complicated than a Rubik's cube? You’re not…
We’ve all seen them in textbooks or presentations—those overlapping circles that simplify complex information into…
We’re excited to announce the upcoming release of FusionCharts v4.1—a groundbreaking step forward in the…
View Comments
Not working ...=
Can you please let us know the issue faced?
I've downloaded your source code and ran it. But chart isn't displaying. Within the code there is a methoda FusionCharts.RenderChart("FusionChartsXT/Column2D.swf) but the swf file is not there in the folder
Hi Raghu,
The charts SWF files and JavaScript files are not uploaded to the FusionCharts XT folder. As per your requirement, paste the contents of the Charts folder obtained while downloading the package.
Download link:https://www.fusioncharts.com/download/trials/
Hi. i have all the file that are needed, but its not giving output...
its only showing message --- " Loading chart. Please wait "
With out this line " FusionCharts.SetRenderer("javascript");" i'm getting output normally. but i need to render in javascript which is very important. please help me on this issue.
Hi Tarun,
To render a Javascript charts, please ensure FusionCharts.HC.js, FusionCharts.HC.Charts.js and jquery.min.js are present in the same folder as FusionCharts.js.
Hi, I was able to get the XML example working as expected, but when following the steps for the json example, the chart does not render.
I changed the dataUrl from Data/Data.xml to Data/Data.json and set the FusionCharts.SetDataFormat("json") before calling the FusionCharts.RenderChart method. Does something else need to be done?