在dotnet高图控件中的x轴重复值

时间:2012-06-14 11:40:44

标签: c# highcharts

enter image description here我遇到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();

1 个答案:

答案 0 :(得分:1)

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

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

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