I have used Column with drilldown highchart.
and its drilldown is
I am getting the right output in its drilldown but I don't want PlotLine to be visible in the first image. How do I solve this?
$(document).ready(function () { });
angular.module('myModule', []).service("AttendanceService", function ($http) {
this.getdata = function () {
return $http({
method: "post",
url: "GetAttendanceReport",
params: [{ EmpID: $("#nameofEmp").val(), YearID: $("#YearIn").val() }],
dataType: "json"
});
};
}).controller('myController', function ($scope,AttendanceService) {
GetAlldata();
function GetAlldata() {
var getAttendanceData = AttendanceService.getdata();
getAttendanceData.then(function (Attendances) {
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Attendance Report' + ' ' + $("#YearIn option:selected").text()
},
xAxis: {
type: 'category'
},
yAxis: {
title: {
text: 'Total Attendance Recorded'
},
plotLines: [{
value: 8,
color: '#ff0000',
width: 2,
zIndex: 4,
label: { text: 'goal' },
}],
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y:.2f}'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}mins</b> of total<br/>'
},
series: [{
name: 'Attendance',
colorByPoint: true,
data: [{
name: 'Jan',
y: Attendances.data.YearlyReport[0],
drilldown: 'Jan'
}, {
name: 'Feb',
y: Attendances.data.YearlyReport[1],
drilldown: 'Feb'
}, {
name: 'March',
y: Attendances.data.YearlyReport[2],
drilldown: 'March'
}, {
name: 'April',
y: Attendances.data.YearlyReport[3],
drilldown: 'April'
}, {
name: 'May',
y: Attendances.data.YearlyReport[4],
drilldown: 'May'
}, {
name: 'June',
y: Attendances.data.YearlyReport[5],
drilldown: 'June'
}, {
name: 'July',
y: Attendances.data.YearlyReport[6],
drilldown: 'July'
}, {
name: 'Aug',
y: Attendances.data.YearlyReport[7],
drilldown: 'Aug'
}, {
name: 'Sep',
y: Attendances.data.YearlyReport[8],
drilldown: 'Sep'
}, {
name: 'Oct',
y: Attendances.data.YearlyReport[9],
drilldown: 'Oct'
}, {
name: 'Nov',
y: Attendances.data.YearlyReport[10],
drilldown: 'Nov'
}, {
name: 'Dec',
y: Attendances.data.YearlyReport[11],
drilldown: 'Dec'
}]
}],
drilldown: {
series:
[{
name: 'Jan',
id: 'Jan',
data: [
[
'1',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 1])
],
[
'2',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 2])
],
[
'3',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 3])
],
[
'4',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 4])
],
[
'5',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 5])
],
[
'6',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 6])
],
[
'7',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 7])
],
[
'8',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 8])
],
[
'9',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 9])
],
[
'10',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 10])
],
[
'11',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 11])
],
[
'12',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 12])
],
[
'13',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 13])
],
[
'14',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 14])
],
[
'15',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 15])
],
[
'16',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 16])
],
[
'17',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 17])
],
[
'18',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 18])
],
[
'19',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 19])
],
[
'20',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 20])
],
[
'21',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 21])
],
[
'22',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 22])
],
[
'23',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 23])
],
[
'24',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 24])
],
[
'25',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 25])
],
[
'26',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 26])
],
[
'27',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 27])
],
[
'28',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 28])
],
[
'29',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 29])
],
[
'30',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 30])
],
[
'31',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 31])
]
]},and so on]
}
});
}, function () {
alert('Error in getting records');
});
} $("#btnLoad").click(function (event) {
GetAlldata();
});
$("#btnBack").click(function (event) {
window.location.href = "homepage";
});
});
This is the full code I have used.
You could remove and add plotLine dynamically when drilling down or up.
Example: http://jsfiddle.net/a5yzsarx/
$(function() {
$('#container').highcharts({
chart: {
events: {
drilldown: function() {
this.xAxis[0].removePlotLine('p1');
},
drillup: function() {
this.xAxis[0].addPlotLine({
id: 'p1',
value: 8,
color: '#ff0000',
width: 2,
zIndex: 4,
label: {
text: 'goal'
}
});
}
}
},
series: [{
type: 'column',
data: [{
y: 42,
drilldown: 's2'
}]
}],
drilldown: {
series: [{
id: 's2',
data: [1, 2, 3]
}]
},
yAxis: {
plotLines: [{
id: 'p1',
value: 8,
color: '#ff0000',
width: 2,
zIndex: 4,
label: {
text: 'goal'
}
}]
}
});
});
Related
I computed a graph in Highcharts which words perfectly well in any browser but internet explorer (see https://jsfiddle.net/statistik_tg/e69Lp3cv/). I had to add a drill down and drill up as the main chart and the drilled down chart include other metrics. Since then, it hasn't been working in IE.
Does anybody know asolution to let the code run in IE, too? Thanks in advance!
$(document).ready(function() {
var chart = {
type: 'column',
marginBottom: 220,
spacingBottom: 85,
events: {
drilldown: function (e) {
if (!e.seriesOptions) {
var chart = this,
drilldowns = {
'Thurgau': {
name: 'Übrige',
color: '#878787',
data: [
['2009', 106],
['2010', 107],
['2011', 102],
['2012', 102],
['2013', 100],
['2014', 102],
['2015', 107],
['2016', 120],
['2017', 121]
]
}
},
drilldowns2 = {
'Thurgau': {
name: 'Phyisotherapie',
color: '#B5B5B5',
data: [
['2009', 79],
['2010', 83],
['2011', 82],
['2012', 85],
['2013', 89],
['2014', 103],
['2015', 115],
['2016', 128],
['2017', 132]
]
}
},
drilldowns3 = {
'Thurgau': {
name: 'Laboratorien',
color: '#E39E00',
data: [
['2009', 42],
['2010', 43],
['2011', 45],
['2012', 48],
['2013', 55],
['2014', 57],
['2015', 63],
['2016', 69],
['2017', 73]
]
}
},
drilldowns4 = {
'Thurgau': {
name: 'Spitex',
color: '#CD3700',
data: [
['2009', 48],
['2010', 49],
['2011', 53],
['2012', 58],
['2013', 62],
['2014', 68],
['2015', 75],
['2016', 80],
['2017', 83]
]
}
},
drilldowns5 = {
'Thurgau': {
name: 'Pflegeheime',
color: '#8B0000',
data: [
['2009', 192],
['2010', 186],
['2011', 182],
['2012', 182],
['2013', 179],
['2014', 169],
['2015', 171],
['2016', 175],
['2017', 173]
]
}
},
drilldowns6 = {
'Thurgau': {
name: 'Apotheken',
color: '#FFED00',
data: [
['2009', 119],
['2010', 121],
['2011', 126],
['2012', 136],
['2013', 141],
['2014', 145],
['2015', 159],
['2016', 178],
['2017', 188]
]
}
},
drilldowns7 = {
'Thurgau': {
name: 'Ärzte Laboranalysen',
color: '#00B4E8',
data: [
['2009', 52],
['2010', 45],
['2011', 46],
['2012', 47],
['2013', 51],
['2014', 54],
['2015', 58],
['2016', 61],
['2017', 62]
]
}
},
drilldowns8 = {
'Thurgau': {
name: 'Ärzte Medikamente',
color: '#0064e6',
data: [
['2009', 339],
['2010', 331],
['2011', 327],
['2012', 329],
['2013', 335],
['2014', 330],
['2015', 342],
['2016', 361],
['2017', 369]
]
}
},
drilldowns9 = {
'Thurgau': {
name: 'Ärzte Behandlung (ohne Labor)',
color: '#27408B',
data: [
['2009', 477],
['2010', 490],
['2011', 509],
['2012', 521],
['2013', 563],
['2014', 586],
['2015', 632],
['2016', 646],
['2017', 655]
]
}
},
drilldowns10 = {
'Thurgau': {
name: 'Spital ambulant',
color: '#a2c510',
data: [
['2009', 474],
['2010', 481],
['2011', 524],
['2012', 533],
['2013', 579],
['2014', 597],
['2015', 602],
['2016', 658],
['2017', 675]
]
}
},
drilldowns11 = {
'Thurgau': {
name: 'Spital stationär',
color: '#3CA433',
data: [
['2009', 724],
['2010', 733],
['2011', 736],
['2012', 727],
['2013', 874],
['2014', 865],
['2015', 844],
['2016', 833],
['2017', 793]
]
}
},
series = drilldowns[e.point.name],
series2 = drilldowns2[e.point.name];
series3 = drilldowns3[e.point.name];
series4 = drilldowns4[e.point.name];
series5 = drilldowns5[e.point.name];
series6 = drilldowns6[e.point.name];
series7 = drilldowns7[e.point.name];
series8 = drilldowns8[e.point.name];
series9 = drilldowns9[e.point.name];
series10 = drilldowns10[e.point.name];
series11 = drilldowns11[e.point.name];
chart.addSingleSeriesAsDrilldown(e.point, series);
chart.addSingleSeriesAsDrilldown(e.point, series2);
chart.addSingleSeriesAsDrilldown(e.point, series3);
chart.addSingleSeriesAsDrilldown(e.point, series4);
chart.addSingleSeriesAsDrilldown(e.point, series5);
chart.addSingleSeriesAsDrilldown(e.point, series6);
chart.addSingleSeriesAsDrilldown(e.point, series7);
chart.addSingleSeriesAsDrilldown(e.point, series8);
chart.addSingleSeriesAsDrilldown(e.point, series9);
chart.addSingleSeriesAsDrilldown(e.point, series10);
chart.addSingleSeriesAsDrilldown(e.point, series11);
chart.applyDrilldown();
chart.yAxis[0].update({
min: 0,
max: 4000
})
}
},
drillup(){
this.yAxis[0].update({
min: 0,
max: 100
})
}
}
};
var plotOptions = {
column: {
stacking: 'normal'
}
};
var title = {
text: "Fast die Hälfte der Kosten im Kanton Thurgau für Spitalbehandlungen",
style: {
fontSize: '18px',
},
align: 'left'
};
var subtitle = {
text: 'Struktur der Bruttokosten nach Kostengruppe, Kanton Thurgau und Schweiz, 2017, Anteile in %/CHF pro versicherte Person¹',
style: {
fontSize: '12px'
},
align: 'left'
};
var yAxis = {
gridLineWidth: 1,
title: '',
lineWidth: 1,
max: 100
};
var xAxis = {
type: 'category'
};
var tooltip = {
valueSuffix: ' CHF'
};
var series = [{
name: 'Übrige',
tooltip: {
valueSuffix: ' %'
},
color: '#878787',
data: [{
name: 'Thurgau',
y: 3.7,
drilldown: true
},{
name: 'Schweiz',
y: 3.5,
drilldown: false
}]
},{
name: 'Physiotherapie',
tooltip: {
valueSuffix: ' %'
},
color: '#B5B5B5',
data: [{
name: 'Thurgau',
y: 4.0,
drilldown: true
},{
name: 'Schweiz',
y: 3.1,
drilldown: false
}]
},{
name: 'Laboratorien',
color: '#E39E00',
tooltip: {
valueSuffix: ' %'
},
data: [{
name: 'Thurgau',
y: 2.2,
drilldown: true
},{
name: 'Schweiz',
y: 2.8,
drilldown: false
}]
},{
name: 'Spitex',
color: '#CD3700',
tooltip: {
valueSuffix: ' %'
},
data: [{
name: 'Thurgau',
y: 2.5,
drilldown: true
},{
name: 'Schweiz',
y: 2.7,
drilldown: false
}]
},{
name: 'Pflegeheime',
tooltip: {
valueSuffix: ' %'
},
color: '#8B0000',
data: [{
name: 'Thurgau',
y: 5.2,
drilldown: true
},{
name: 'Schweiz',
y: 5.7,
drilldown: false
}]
},{
name: 'Apotheken',
tooltip: {
valueSuffix: ' %'
},
color: '#FFED00',
data: [{
name: 'Thurgau',
y: 5.7,
drilldown: true
},{
name: 'Schweiz',
y: 11.8,
drilldown: false
}]
},{
name: 'Ärzte Laboranalysen',
tooltip: {
valueSuffix: ' %'
},
color: '#00B4E8',
data: [{
name: 'Thurgau',
y: 1.9,
drilldown: true
},{
name: 'Schweiz',
y: 1.7,
drilldown: false
}]
},{
name: 'Ärzte Medikamente',
tooltip: {
valueSuffix: ' %'
},
color: '#0064e6',
data: [{
name: 'Thurgau',
y: 11.1,
drilldown: true
},{
name: 'Schweiz',
y: 6.3,
drilldown: false
}]
},{
name: 'Ärzte Behandlungen (ohne Labor)',
tooltip: {
valueSuffix: ' %'
},
color: '#27408B',
data: [{
name: 'Thurgau',
y: 19.7,
drilldown: true
},{
name: 'Schweiz',
y: 22.6,
drilldown: false
}]
},{
name: 'Spital ambulant',
tooltip: {
valueSuffix: ' %'
},
color: '#a2c510',
data: [{
name: 'Thurgau',
y: 20.3,
drilldown: true
},{
name: 'Schweiz',
y: 19.1,
drilldown: false
}]
},{
name: 'Spital stationär',
tooltip: {
valueSuffix: ' %'
},
color: '#3CA433',
data: [{
name: 'Thurgau',
y: 23.8,
drilldown: true
},{
name: 'Schweiz',
y: 20.7,
drilldown: false
}]
}];
var drilldown = {
series: []
};
var legend = {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
padding: 25,
symbolPadding: 10,
symbolWidth: 25,
margin: -10,
/*maxHeight: 150,*/
alignColumns: false,
reversed: false,
itemStyle: {
fontWeight: 'normal'
}
};
var credits = {
text: '<b>Hinweis: Für den Vergleich der Kostenanteile im Kanton Thurgau von 2009-2017 klicken Sie <br><b>auf den Balken oder die Balkenbeschriftung zum Thurgau<br>¹ Vergleich Thurgau-Schweiz Anteile in %, Vergleich Thurgau 2009-2017 Anteile in CHF<br>Dienststelle für Statistik Kanton Thurgau <br>Datenquellen: Bundesamt für Gesundheit, Monitoring der Krankenversicherungs-<br>Kostenentwicklung',
href: false,
style: {
color:'#999999',
cursor: false,
fontSize:'10px'
},
position: {
align: 'left',
x: 10,
y: -90
}
};
var exporting = {
allowHTML: true,
enabled: true,
filename:'2019_07_Krankenversicherungskosten_Brutto_2017',
buttons: {
contextButton: {
menuItems: "printChart separator downloadPNG downloadJPEG downloadSVG".split(" ")
}
},
/*csv: {
columnHeaderFormatter: function (item) {
if(item instanceof Highcharts.Axis) {
return 'Quartal';
} else {
if(item instanceof Highcharts.Series) {
return item.name;
}
}
}
}*/
};
var responsive = {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
enabled: false
}
}
}]
};
var highchartsOptions = Highcharts.setOptions ({
lang: {
decimalPoint: '.',
thousandsSep: "'",
months: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
weekdays: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
shortMonths: ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
contextButtonTitle: 'Drucken, Download, Export',
downloadJPEG: 'Download JPEG Bild',
downloadPNG: 'Download PNG Bild',
downloadSVG: 'Download SVG Vektor Bild',
downloadXLS: 'Download XLS',
printChart: 'Bild drucken',
viewData: 'Datentabelle ein-/ausblenden',
resetZoom: "Zoom zurücksetzen",
resetZoomTitle: "Zoom zurücksetzen",
drillUpText: "Zurück",
numericSymbols: null //otherwise by default ['k', 'M', 'G', 'T', 'P', 'E']
}
});
colors = ["#878787","#B5B5B5","#E39E00","#CD3700","#8B0000","#3CA433","#a2c510","#FFED00","#00B4E8","#0064e6","#27408B"]
var json = {};
json.chart = chart;
json.plotOptions = plotOptions;
json.title = title;
json.subtitle = subtitle;
json.yAxis = yAxis;
json.xAxis = xAxis;
json.tooltip = tooltip;
json.series = series;
json.drilldown = drilldown;
json.legend = legend;
json.credits = credits;
json.exporting = exporting;
json.responsive = responsive;
json.highchartsOptions = highchartsOptions;
json.colors = colors;
$('#2019_07_Krankenversicherungskosten_Brutto_2017').highcharts(json);
});
There is an error in IE developer tools console - you need to change JS line 230 from this:
drillup(){
into this:
drillup: function() {
and then it works fine in IE11
I'm trying to avoid the chart's drilldown when the user clicks the x-Axis label, but, unless I'm doing something wrong, the DrillUpButton doesn't dissapear completly when I cancel the event:
chart: {
type: "column",
events: {
drilldown: function (e)
{
if (e.category != null)
return false;
}
}
}
http://jsfiddle.net/ar3k9wda/3/
Is this a bug??? Or what else do I need to do???
You want to disable data label click. check this post it will be help full
Highcharts.Tick.prototype.drillable = function () {};
// Create the chart
Highcharts.chart('container', {
chart: {
type: "column",
/*events: {
drilldown: function (e)
{
if (e.category != null)
return false;
}
}*/
},
xAxis: {
type: 'category'
},
legend: {
enabled: false
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [{
name: 'Microsoft Internet Explorer',
y: 56.33,
drilldown: 'Microsoft Internet Explorer'
}, {
name: 'Chrome',
y: 24.03,
drilldown: 'Chrome'
}, {
name: 'Firefox',
y: 10.38,
drilldown: 'Firefox'
}, {
name: 'Safari',
y: 4.77,
drilldown: 'Safari'
}, {
name: 'Opera',
y: 0.91,
drilldown: 'Opera'
}, {
name: 'Proprietary or Undetectable',
y: 0.2,
drilldown: null
}]
}],
drilldown: {
series: [{
name: 'Microsoft Internet Explorer',
id: 'Microsoft Internet Explorer',
data: [
[
'v11.0',
24.13
],
[
'v8.0',
17.2
],
[
'v9.0',
8.11
],
[
'v10.0',
5.33
],
[
'v6.0',
1.06
],
[
'v7.0',
0.5
]
]
}, {
name: 'Chrome',
id: 'Chrome',
data: [
[
'v40.0',
5
],
[
'v41.0',
4.32
],
[
'v42.0',
3.68
],
[
'v39.0',
2.96
],
[
'v36.0',
2.53
],
[
'v43.0',
1.45
],
[
'v31.0',
1.24
],
[
'v35.0',
0.85
],
[
'v38.0',
0.6
],
[
'v32.0',
0.55
],
[
'v37.0',
0.38
],
[
'v33.0',
0.19
],
[
'v34.0',
0.14
],
[
'v30.0',
0.14
]
]
}, {
name: 'Firefox',
id: 'Firefox',
data: [
[
'v35',
2.76
],
[
'v36',
2.32
],
[
'v37',
2.31
],
[
'v34',
1.27
],
[
'v38',
1.02
],
[
'v31',
0.33
],
[
'v33',
0.22
],
[
'v32',
0.15
]
]
}, {
name: 'Safari',
id: 'Safari',
data: [
[
'v8.0',
2.56
],
[
'v7.1',
0.77
],
[
'v5.1',
0.42
],
[
'v5.0',
0.3
],
[
'v6.1',
0.29
],
[
'v7.0',
0.26
],
[
'v6.2',
0.17
]
]
}, {
name: 'Opera',
id: 'Opera',
data: [
[
'v12.x',
0.34
],
[
'v28',
0.24
],
[
'v27',
0.17
],
[
'v29',
0.16
]
]
}]
}
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
I setting data to highchart with razor syntax like this :
series: [
#foreach (var item in Model)
{
<text>
{
name: '#item.name',
data: [
#foreach (var item2 in item.finalChart)
{
#:[Date.parse("#item2.date1"), #item2.value],
}
]
},
</text>
}
]
And here is executed code:
series: [
{
name: 'clicks6',
data: [
[Date.parse("04/03/2017"), 10],
[Date.parse("04/04/2017"), 45],
]
},
{
name: 'clicks4',
data: [
[Date.parse("04/03/2017"), 28],
[Date.parse("04/04/2017"), 22],
]
},
{
name: 'clicks8',
data: [
[Date.parse("04/03/2017"), 8],
[Date.parse("04/04/2017"), 35],
[Date.parse("04/05/2017"), 5],
[Date.parse("04/10/2017"), 0],
]
},
]
As you can see in below points not adapted with y axis.
If I add another format of data this problem doesn't happend
series: [{
name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
},{
name: 'Other',
data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 18111]
}]
How can fix this issue? with some reasons I can't use another format of data.
UPDATE:
It is desired mode that I want:
add UTC to each date input Date.parse("04/03/2017" + ' UTC')
#:[Date.parse("#item2.date1" + ' UTC'), #item2.value],
xAxis will be
xAxis: {
type: 'datetime',
tickInterval: 24 * 3600 * 1000 //this is for one day
},
Highcharts.chart('container', {
chart: {
type: 'spline',
zoomType: 'x'
},
title: {
text: 'Highcharts'
},
subtitle: {
text: document.ontouchstart === undefined ?
'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in'
},
xAxis: {
type: 'datetime',
tickInterval: 24 * 3600 * 1000
},
yAxis: {
title: {
text: 'Snow Depth'
},
},
series: [{
name: 'clicks6',
data: [
[Date.parse("04/03/2017" + ' UTC'), 10],
[Date.parse("04/04/2017" + ' UTC'), 45],
]
},
{
name: 'clicks4',
data: [
[Date.parse("04/03/2017" + ' UTC'), 28],
[Date.parse("04/04/2017" + ' UTC'), 22],
]
},
{
name: 'clicks8',
data: [
[Date.parse("04/03/2017" + ' UTC'), 8],
[Date.parse("04/04/2017" + ' UTC'), 35],
[Date.parse("04/05/2017" + ' UTC'), 5],
[Date.parse("04/10/2017" + ' UTC'), 0],
]
},
]
});
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
I have my highchart below
what I want is to colour those columns with some different colour which are having the value exactly 8.00
here is my code
$(document).ready(function () { });
angular.module('myModule', []).service("AttendanceService", function ($http) {
this.getdata = function () {
return $http({
method: "post",
url: "GetAttendanceReport",
params: [{ EmpID: $("#nameofEmp").val(), YearID: $("#YearIn").val() }],
dataType: "json"
});
};
}).controller('myController', function ($scope,AttendanceService) {
GetAlldata();
function GetAlldata() {
var getAttendanceData = AttendanceService.getdata();
getAttendanceData.then(function (Attendances) {
Highcharts.chart('container', {
chart: {
type: 'column',
events: {
drilldown: function () {
this.yAxis[0].addPlotLine({
id: 'p1',
value: 8,
color: '#ff0000',
width: 2,
zIndex: 4,
label: {
text: 'goal'
}
})
},
drillup: function () {
this.yAxis[0].removePlotLine('p1');
}
},
}
title: {
text: 'Attendance Report' + ' ' + $("#YearIn option:selected").text()
},
xAxis: {
type: 'category'
},
yAxis: {
title: {
text: 'Total Attendance Recorded',
plotLines: [{
id: 'p1',
value: 8,
color: '#ff0000',
width: 2,
zIndex: 4,
label: {
text: 'goal'
}
}]
},
}
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y:.2f}'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}mins</b> of total<br/>'
},
series: [{
name: 'Attendance',
colorByPoint: true,
data: [{
name: 'Jan',
y: Attendances.data.YearlyReport[0],
drilldown: 'Jan'
}, {
name: 'Feb',
y: Attendances.data.YearlyReport[1],
drilldown: 'Feb'
}, {
name: 'March',
y: Attendances.data.YearlyReport[2],
drilldown: 'March'
}, {
name: 'April',
y: Attendances.data.YearlyReport[3],
drilldown: 'April'
}, {
name: 'May',
y: Attendances.data.YearlyReport[4],
drilldown: 'May'
}, {
name: 'June',
y: Attendances.data.YearlyReport[5],
drilldown: 'June'
}, {
name: 'July',
y: Attendances.data.YearlyReport[6],
drilldown: 'July'
}, {
name: 'Aug',
y: Attendances.data.YearlyReport[7],
drilldown: 'Aug'
}, {
name: 'Sep',
y: Attendances.data.YearlyReport[8],
drilldown: 'Sep'
}, {
name: 'Oct',
y: Attendances.data.YearlyReport[9],
drilldown: 'Oct'
}, {
name: 'Nov',
y: Attendances.data.YearlyReport[10],
drilldown: 'Nov'
}, {
name: 'Dec',
y: Attendances.data.YearlyReport[11],
drilldown: 'Dec'
}]
}],
drilldown: {
series:
[{
name: 'Jan',
id: 'Jan',
data: [
[
'1',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 1])
],
[
'2',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 2])
],
[
'3',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 3])
],
[
'4',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 4])
],
[
'5',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 5])
],
[
'6',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 6])
],
[
'7',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 7])
],
[
'8',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 8])
],
[
'9',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 9])
],
[
'10',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 10])
],
[
'11',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 11])
],
[
'12',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 12])
],
[
'13',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 13])
],
[
'14',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 14])
],
[
'15',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 15])
],
[
'16',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 16])
],
[
'17',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 17])
],
[
'18',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 18])
],
[
'19',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 19])
],
[
'20',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 20])
],
[
'21',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 21])
],
[
'22',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 22])
],
[
'23',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 23])
],
[
'24',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 24])
],
[
'25',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 25])
],
[
'26',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 26])
],
[
'27',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 27])
],
[
'28',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 28])
],
[
'29',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 29])
],
[
'30',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 30])
],
[
'31',
parseFloat(Attendances.data.MonthlyReport[1 * 33 + 31])
]
]},and so on]
}
});
}, function () {
alert('Error in getting records');
});
} $("#btnLoad").click(function (event) {
GetAlldata();
});
$("#btnBack").click(function (event) {
window.location.href = "homepage";
});
});
I have used Column with drilldown highchart. Is there any way??
You can directly pass an attribute color the the datapoint of your series like this:
color: '#00ff00'
You then just need to cycle through your data and replace those point's color.
JsFiddle
You may find this question elsewhere on Stack Overflow helpful: Highcharts Change Bar Color Based on Value. Please refer to the accepted answer, which has code to iterate over the series and color them based on their value.
I have data that looks like this in JSON format. I have two data series with same time line. When I try to plot them in highstock, all my time-stamps are shown as starting in 1970s. Can anyone point me what would be wrong with my JSON format?
Reason I am not using - pointStart and pointInterval: is because sometime pointIntervals can be irregular and hence need to send in the dates.
{
"chart_data": {
"dates": [
1406876400000,
1406876700000,
1406877000000,
1406877300000,
1406877600000,
1406877900000,
1406878200000,
1406878500000,
1406878800000
],
"values": [
{
"data": [
54,
50,
62,
65,
65,
55,
51,
53,
57
]
},
{
"data": [
84,
70,
80,
78,
77,
84,
73,
83,
77
]
}
]
}
}
My Javascript method to display this data is below.
<script type="text/javascript">
$(document).ready(function() {
var chartOptions = {
chart: {
renderTo: 'chart_panel',
type: 'line',
zoomType: 'x'
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
title: {text: 'Temperature & Humidity' },
subtitle: {text: 'My-Text' },
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
month: '%e. %b',
day: '%b %e',
hour: '%b %e',
year: '%b'
}
},
yAxis: {
min: 0,
title: {
text: 'Temperature (°F)/Humidity (%)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
series: [{}],
rangeSelector : {
inputEnabled: true,
selected: '0'
},
};
var chartDataUrl = '{% url "chart_data_json" object.id %}';
function loadChart() {
$.getJSON(chartDataUrl,
function(data) {
var seriesOptions = [];
var obj1 = {};
var obj2 = {};
avgByDayOptions.xAxis.categories = data['chart_data']['dates'];
obj1.name = "Temperature";
obj1.data = data['chart_data']['values'][0]['data'];
obj2.data = data['chart_data']['values'][1]['data'];
obj2.name = "Humidity";
seriesOptions[0] = obj1;
seriesOptions[1] = obj2;
chartOptions.series = seriesOptions;
var chart = new Highcharts.StockChart( chartOptions,
function(chart){
// apply the date pickers
setTimeout(function(){
$('input.highcharts-range-selector', $('#'+chart.options.chart.renderTo))
.datepicker()
},0)
}
);
Highcharts.setOptions({ global: { useUTC: false } });
});
}
loadChart();
});
It was may bad once I passed the data in following format everything started work as expected. Just posting reply to my own question in case someone runs into similar issue?
{
"chart_data": {
"values": [
{
"data": [
[
1406851200000,
54
],
[
1406851500000,
50
],
[
1406851800000,
62
],
[
1406852100000,
65
],
[
1406852400000,
65
],
[
1406852700000,
55
],
[
1406853000000,
51
],
[
1406853300000,
53
],
[
1406853600000,
57
]
]
},
{
"data": [
[
1406851200000,
84
],
[
1406851500000,
70
],
[
1406851800000,
80
],
[
1406852100000,
78
],
[
1406852400000,
77
],
[
1406852700000,
84
],
[
1406853000000,
73
],
[
1406853300000,
83
],
[
1406853600000,
77
]
]
}
]
}
}