0

在此处输入图像描述我面临 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();
4

1 回答 1

1
xAxis : [{categories : []}], // when defining X-Axis

chart.xAxis[0].setCategories(JSON_object); // when parsing data ,from another method ,

如果要使用类别 X 轴或 Y 轴?.bcoz代码和图表图像让我感到困惑,无论如何,如果你想手动设置类别,然后最初将类别设为空,并使用JQuery为其分配一个数组,如果你加载动态数据,那么应该有解析的 json 对象或类似的东西

于 2012-06-15T09:36:18.203 回答