I want to display a label on each bar of the chart horizontally
@using GJob.Models.Views
@model BasicChart1
@{
ViewBag.Title = "The Chart";
Layout = "~/Views/Shared/_Layout2.cshtml";
}
@{
var myChart = new Chart(width: 1200, height: 800)
.AddTitle("My chart title")
.AddSeries("Default",
chartType: "bar",
markerStep: 1,
xValue: Model.XData, xField: "Name",
yValues: Model.YDataINT, yFields: "Value")
.Write("png");
}
I have tried to get help from those articles
https://docs.microsoft.com/en-us/aspnet/web-pages/overview/data/7-displaying-data-in-a-chart
https://weblogs.asp.net/imranbaloch/chart-helper-in-asp-net-mvc-3-0-with-transparent-background
https://forums.asp.net/t/1654046.aspx?Chart+Helper+need+all+xvalue+labels+not+just+a+few
and as well as the definition of the constructor of the Chart
namespace System.Web.Helpers
{
//
// Summary:
// Displays data in the form of a graphical chart.
public class Chart
but no clue how to do it.
Please help. Thanks!
UPDATE 1
I assume that we have work around ChartArea
<asp:Chart ID="Chart1" runat="server" Width="600" Height="400" DataSourceID="SqlDataSource1">
<series>
<asp:Series Name="Series1" XValueMember="Country" YValueMembers="Column1"
ChartType="Column">
</asp:Series>
</series>
<chartareas>
<asp:ChartArea BackColor="NavajoWhite" BackGradientStyle="LeftRight"
Name="ChartArea1" ShadowOffset="5">
<AxisY Title="Number of Customers">
</AxisY>
<AxisX Title="Countries" IsLabelAutoFit="True">
<LabelStyle Angle="-90" Interval="1" />
</AxisX>
<Area3DStyle Enable3D="True" />
</asp:ChartArea>
</chartareas>
</asp:Chart>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT COUNT(*),Country FROM Customers GROUP BY Country">
</asp:SqlDataSource>
But it is unclear the syntax to config Chart class in ASP.NET MVC.
So I found correct approach here https://www.danylkoweb.com/Blog/simplified-aspnet-mvc-charts-A5
Controller
View
So the answer is to use this line
<LabelStyle Angle = ""-90"" Interval = ""1"" />