我面临 dotnet highcharts 控件的问题,问题是 x 轴上的值重复,即 0 0 1 1 2 2 3 3 4 4 5 5。请帮助
下面是我的代码。
Javascript代码
<div id='ContentAvailabilty_container'></div>
<script type='text/javascript'>
var ContentAvailabilty;
$(document).ready(function() {
ContentAvailabilty = new Highcharts.Chart({
chart: { renderTo:'ContentAvailabilty_container', type: 'bar' },
legend: { enabled: false, layout: 'horizontal' },
plotOptions: { bar: { borderWidth: 0 } },
title: { text: 'Content Availabilty' },
xAxis: { categories: ['#Rest of Published', '#Published Queue', '#Rest of Unpublished', '#Unpublished Queue', '#New Approved'] },
yAxis: { labels: { formatter: function() { return Highcharts.numberFormat(this.value, 0); } }, min: 0, title: { text: '' } },
series: [{ data: [5, 0, 0, 0, 0] }]
});
});
</script>
DOT NET CODE
DotNet.Highcharts.Highcharts currentReport = new DotNet.Highcharts.Highcharts("ContentAvailabilty");
currentReport.InitChart(new Chart { Type = ChartTypes.Bar });
currentReport.SetTitle(new Title { Text = "Content Availabilty" });
currentReport.SetXAxis(new XAxis
{
Categories = new[] { "#Rest of Published", "#Published", "#Rest of Unpublished", "#Unpublished", "#Approved" }
});
currentReport.SetYAxis(new YAxis
{
Title = new XAxisTitle { Text = "" }
, Labels = new XAxisLabels { Formatter = "function() { return Highcharts.numberFormat(this.value, 0); }" }//function to convert 4k to 4000
,Min=0
});
currentReport.SetLegend(new Legend { Enabled = false });
currentReport.SetPlotOptions(new PlotOptions { Bar = new PlotOptionsBar { BorderWidth=0} });
currentReport.SetSeries(new Series[] {
new Series{
Data = new Data( new object[]{ RestofPublished, publishedQueue, Rest_of_UnPublished, UnPublished_Queue, newApproved } )
}
});
ReportContainerLabel.Text = string.Empty;
ReportContainerLabel.Text = currentReport.ToHtmlString();