HomeController.cs
public ActionResult Index()
{
List<ChartMultiLevelLabel>
multilevels = new List<ChartMultiLevelLabel>();
ChartMultiLevelLabel one = new ChartMultiLevelLabel();
ChartCategory category = new ChartCategory();
category.Start = "-0.5";
category.End = "0.5";
category.Text = "2020 AAAA";
List<ChartCategory> categoryOne
= new
List<ChartCategory>();
categoryOne.Add(category);
one.Categories = categoryOne;
multilevels.Add(one);
ViewBag.multiLevelLabels = multilevels;
}
Index.cshtml
@Html.EJS().Chart("container").PrimaryXAxis(py
=> py. MultiLevelLabels(ViewBag.multiLevelLabels)).Load("onChartLoad").Render()
<script>
function
onChartLoad(args) {
args.chart.series[0].connector.width = 0;
args.chart.primaryXAxis.border = { type: "Rectangle", width: 1 };
args.chart.primaryXAxis.multiLevelLabels = [
{
border: { type: 'Rectangle' },
categories: [
{ start: -0.5, end: 0.5, text: '2020 AAAA', },
//…
]
}
];
}
</script>
|