in my array contain 3 values . how i pass this x axis to chart
You can try with the below apporach
Create a model class to hold the data
public class SampleChartData
{
public string[] XAxisValues { get; set; }
public string[] YAxisValues { get; set; }
}
Change the name as per your need
Now in controller Populate the Above model with data
public class SampleChartController : Controller
{
// GET: SampleChart
public ActionResult Index()
{
//Populate Data
//Here You can get data from Database and create a String array
SampleChartData chartData = new SampleChartData();
chartData.XAxisValues = new[] { "Apple", "Orange", "Grape" };
chartData.YAxisValues = new[] { "10", "25", "50" };
return View(chartData);
}
}
Please let me know if any question, welcome to back!
With regards, Angelia Jolie
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
17 Points
71 Posts
Pass dynamic values to x and y axis in char
Nov 15, 2017 09:15 AM|Binumon003|LINK
I generating chart using web.helpers library
my question is how i pass x and y axis values dynamically
in my array contain 3 values . how i pass this x axis to chart
string[] fruits = new string[] { "Apple", "Orange", "Grape" };
new System.Web.Helpers.Chart(width: 500, height: 300, theme: ChartTheme.Blue)
.AddTitle("Chart for Fruits")
.AddSeries(
chartType: "pie",
xValue: new[] { },// here i need to pass fruits array value?
yValues: new[] { "10", "25", "50" })
.ToWebImage().GetBytes());
All-Star
50651 Points
9839 Posts
Re: Pass dynamic values to x and y axis in char
Nov 15, 2017 09:32 PM|A2H|LINK
You can try with the below apporach
Create a model class to hold the data
Change the name as per your need
Now in controller Populate the Above model with data
we can pass data from Model in View like below
SOURCE URL
Aje
My Blog | Dotnet Funda
Contributor
5270 Points
2307 Posts
Re: Pass dynamic values to x and y axis in char
Nov 17, 2017 10:20 AM|AngelinaJolie|LINK
Hi Binumon,
After tested, it works well:
Please let me know if any question, welcome to back!
With regards, Angelia Jolie
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.