反正是有集团每年我的数据,将汇总并使其1?

问题描述 投票:-1回答:1

在我的代码我尝试显示,每年所有的在校生,我想总结一下他们都在每年的1列。反正是有添加过滤器或最有可能在代码itselft每年所有的数据结合起来?

    var strCampus = "ORT";

            $(function() {
  $.getJSON("http://localhost:37590/Get_OGSData/" + strCampus, function(data) {
    console.log(data);
    Highcharts.chart('container', {
      chart: {
        type: 'column'
        },
         rangeSelector: {
            selected: 1
        },
      title: {
        text: 'On Going Students per Year'
      },
      subtitle: {
        text: 'Click each column to see details'
      },
      xAxis: {
        type: 'category',
        categories: data.map(function(x) {
          return x.YEAR;
        })
      },
      yAxis: {
        title: {
          text: 'On Going Students'
        }
        },


        credits: {
            enabled: false
        },
      legend: {
        enabled: false
      },
      plotOptions: {
        series: {
          borderWidth: 0,
          dataLabels: {
            enabled: true,
            //format: '{point.y:.1f}'
          }
        }
      },
        tooltip: {
          enabled: false,
        headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
        pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:2f}</b> of total<br/>'
      },
      series: [{
        colorByPoint: true,
        data: data.map(function(x) {
          return x.OGS * 1;
        })
      }]
    });
  });
});

我想每年所有的数据结合起来,1列

javascript c# highcharts
1个回答
1
投票

您可以使用dataGrouping下面的选项:

    dataGrouping: {
        approximation: 'sum',
        forced: true,
        units: [
            ['year', [1]]
        ]
    }

现场演示:http://jsfiddle.net/BlackLabel/me3Lzur6/

API参考:https://api.highcharts.com/highstock/series.column.dataGrouping

© www.soinside.com 2019 - 2024. All rights reserved.