Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var option = {
- chart: { renderTo: "chartDiv", marginleft: 100 },
- title: {
- text: '',
- x: -20 //center
- },
- xAxis: {
- title: {
- text: "Shifts"
- },
- },
- yAxis: {
- title: {
- text: "Volume"
- },
- min: 0
- },
- tooltip: {
- crosshairs: true,
- shared: true,
- formatter: function () {
- var s = [];
- s.push('<span> Day: <strong>' + this.points[0].x + '</strong></span>');
- $.each(this.points, function (i, point) {
- s.push('<span style="color:' + point.series.color + ';font-weight:bold;">' + point.series.name + ' : ' +
- Math.round(point.y * 1000) / 1000 + '<span>');
- });
- return s.join('<br />');
- }
- },
- legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', floating: true, borderWidth: 0, floating: false },
- plotOptions: {
- }
- };
- function generateChart(shiftNum, days) {
- var chart = new Highcharts.Chart(option);
- for (series = 0; series < shiftNum; series++) {
- chart.addSeries({
- type: 'bar',
- });
- }
- for (i = 1; i < days; i++) {
- $.ajax({
- type: "POST",
- url: "/ajaxcall/ShiftData",
- dataType: "json",
- data: JSON.stringify({
- 'shiftnum': shiftNum,
- 'dayOfMonth': i
- }),
- contentType: 'application/json; charset=utf-8',
- success: function(result) {
- if (result.Success) {
- $.each(result.Report, function(s, rep) {
- chart.series[s].data.push([i, rep.FinalVol]);
- });
- }
- },
- complete: function() {
- console.log(chart);
- chart.xAxis[0].isDirty = true;
- chart.redraw(); //This gives error
- }
- });
- }
- }
- generateChart(2, 7);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement