Table of Contents
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FusionCharts.DataEngine;
using FusionCharts.Visualization;
namespace FusionChartsVisualisationWebFormsSamples.Samples
{
public partial class FirstChart: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ { DataTable ChartData = new DataTable();
ChartData.Columns.Add("Programming Language", typeof(System.String));
ChartData.Columns.Add("Users", typeof(System.Double));
ChartData.Rows.Add("Java",62000);
ChartData.Rows.Add("Python",46000);
ChartData.Rows.Add("Javascript",38000);
ChartData.Rows.Add("C++",31000);
ChartData.Rows.Add("C#",27000);
ChartData.Rows.Add("PHP",14000);
ChartData.Rows.Add("Perl",14000);
// Create static source with this data table
StaticSource source = new StaticSource(ChartData);
// Create instance of DataModel class
DataModel model = new DataModel();
// Add DataSource to the DataModel
model.DataSources.Add(source);
// Instantiate Column Chart
Charts.ColumnChart column = new Charts.ColumnChart("first_chart");
// Set Chart's width and height
column.Width.Pixel(700);
column.Height.Pixel(400);
// Set DataModel instance as the data source of the chart
column.Data.Source = model;
// Set Chart Title
column.Caption.Text = "Most popular programming language";
// Sset chart sub title
column.SubCaption.Text = "2017-2018";
// hide chart Legend
column.Legend.Show = false;
// set XAxis Text
column.XAxis.Text = "Programming Language";
// Set YAxis title
column.YAxis.Text = "User";
column.ThemeName = FusionChartsTheme.ThemeName.FUSION;
// Render the chart to 'Literal1' literal control
Literal1.Text = column.Render();
}
}
} const dataSource = {
chart: {
caption: "Split of visitors by Channels",
placevaluesinside: "1",
showvalues: "0",
plottooltext: "<b>$dataValue</b> visitors from $label in $seriesName",
theme: "fusion"
},
categories: [
{
category: [
{
label: "Organic"
},
{
label: "Offline Stores"
},
{
label: "Email Campaigns"
},
{
label: "Social Events"
},
{
label: "Paid Channels"
}
]
}
],
dataset: [
{
seriesname: "2017",
data: [
{
value: "17000"
},
{
value: "19500"
},
{
value: "12500"
},
{
value: "14500"
},
{
value: "17500"
}
]
},
{
seriesname: "2018",
data: [
{
value: "25400"
},
{
value: "29800"
},
{
value: "21800"
},
{
value: "19500"
},
{
value: "21200"
}
]
}
],
trendlines: [
{
line: [
{
startvalue: "16200",
color: "#5D62B5",
thickness: "1.5",
displayvalue: "2017's Avg."
},
{
startvalue: "23500",
color: "#29C3BE",
thickness: "1.5",
displayvalue: "2018's Avg."
}
]
}
]
};
FusionCharts.ready(function() {
var myChart = new FusionCharts({
type: "msbar2d",
renderAt: "chart-container",
width: "100%",
height: "100%",
dataFormat: "json",
dataSource
}).render();
}); The above code will render the following chart: 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…