user1037747
user1037747

Reputation: 1373

Repeated values in x axis in dotnet highchart controls

enter image description hereI m facing problem with dotnet highcharts controls the problem is the values in x axis are repeating i.e. 0 0 1 1 2 2 3 3 4 4 5 5. Please help

below is my code.

Javascript code

<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();

Upvotes: 0

Views: 1702

Answers (1)

Lakshitha Udara
Lakshitha Udara

Reputation: 153

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

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

if you want to use categories X-Axis or Y-Axis ? .bcoz the code and the chart image confusing me , any way if you want to set the categories by manually , then initially make categories as null , and assigned a array to it by using JQuery , if you loading dynamic data , then there should be a parsed json object or something semilar

Upvotes: 1

Related Questions