Ariovaldo

FusionCharts library .NET

Recommended Posts

Hello,

I'm using the fusioncharts library for .NET.

I would like to show a graph with two columns, I will leave an example of how it is and how I would like it to be.

Any help is welcome, thanks.
Source code

5e3953faef9f9_2020-02-0408_20_35-Window.thumb.png.bc57b8b81524200f4890cdc747f49f61.png

 

Currently

2020-02-04 08_22_56-Window.png

Intended(Example)

5e39546b9d355_2020-02-0408_23_59-Window.png.25edc30356a3b666bd1a636079782175.png

 

Thanks.

Edited by Ariovaldo

Share this post


Link to post
Share on other sites

Hi,

 

Yes, you need to provide multiple measures for each category label.

For reference check the below code snippet and implement accordingly.

 

using System;
using System.Web.Mvc;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using FusionCharts.Visualization;
using FusionCharts.DataEngine;
using System.Data;
namespace FusionChartsSamples
{
	public class HomeController : Controller
	{
		
		public ActionResult Index()
		{				
			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;
            
            ViewData["Chart"] = column.Render();
            return View();
		}

		
	}
}

For reference check the following sample   https://dotnetfiddle.net/nVVeWE

 

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