(function () {
var script = document.getElementById('highcharts-script');
function addChart() {
var onCustomCodeError;
function customCode(options, product) {
try {
Highcharts.extend(options, Highcharts.merge(options, {
yAxis: {
stackLabels: {
style: {
fontWeight: 'normal',
fontSize: '14px',
fontWeight: '600',
},
}
},
title: {
style: {
color: '#26292a',
fontWeight: '600',
fontSize: '18px',
}
}
}));
} catch(error) {
console.error(error)
if (onCustomCodeError && onCustomCodeError(error) === false){
// stop execution
return;
}
}
var chart = new Highcharts['Chart'](options);
}
function parseData(completeHandler, chartOptions) {
try {
var dataOptions = {
"seriesMapping": [
{
"x": 0
},
{
"x": 0
},
{
"x": 0
},
{
"x": 0
},
{
"x": 0
},
{
"x": 0
},
{
"x": 0
},
{
"x": 0
}
],
"columnTypes": [
"string",
"float",
"float",
"float",
"float",
"float",
"float",
"float",
"float"
],
"csv": "Kriminalitetstype,ØKONOMI,VINNING,VOLD,SEDELIGHET,NARKOTIKA,SKADEVERK,TRAFIKK,ANNEN\n1. halvår 2016,54,351,312,50,189,57,43,173\n1. halvår 2017,62,555,387,52,268,63,57,186"
};
dataOptions.sort = true
dataOptions.complete = completeHandler;
Highcharts.data(dataOptions, chartOptions);
} catch (error) {
console.log(error);
completeHandler(undefined);
}
}
var shareUrl = 'https://app.everviz.com/show/igagihi';
var encodedUrl = encodeURIComponent(shareUrl);
var template = {
chart: {
renderTo: 'highcharts-igagihi'
},
navigation: {
menuItemStyle: {
fontFamily: Highcharts.SVGRenderer.prototype.getStyle().fontFamily,
padding: '2px 10px'
}
},
exporting: {
buttons: {
contextButton: {
menuItems: [{
text: '' +
'Share on Facebook'
}, {
text: '' +
'Share on Google+'
}, {
text: '' +
'Share on Twitter'
}, {
text: '' +
'Share on LinkedIn'
}, {
separator: true
}]
.concat(Highcharts.getOptions().exporting.buttons.contextButton.menuItems)
.concat([{
separator: true
}, {
text: '' + 'Edit chart'
}, {
text: '' + 'Create chart'
}])
}
}
}
};
var chartOptions = {
"plotOptions": {
"columnrange": {
"dataLabels": {
"style": {
"fontWeight": "normal"
}
},
"colors": ""
},
"series": {
"dataLabels": {
"color": "#26292a",
"format": "{y} ",
"style": {
"color": "#26292a",
"fontSize": "12px",
"fontWeight": "600",
"textOutline": "0"
},
"enabled": true
},
"stacking": "normal"
},
"column": {
"dataLabels": {
"style": {
"fontWeight": "700",
"textOutline": "0px 0px contrast",
"fontSize": "14px"
}
},
"colors": [
""
]
}
},
"yAxis": {
"stackLabels": {
"verticalAlign": "middle",
"enabled": true
},
"reversedStacks": false,
"endOnTick": false,
"title": {
"style": {
"fontSize": "12px",
"color": "#26292a"
},
"text": null
},
"labels": {
"format": " {value} "
}
},
"xAxis": {
"gridLineColor": "#c8c8c8",
"minorTickInterval": "",
"tickLength": 0,
"lineColor": "#c8c8c8",
"tickPositions": "",
"title": {
"style": {
"fontSize": "16px",
"color": "#26292a"
},
"text": null
},
"tickPosition": "inside",
"labels": {
"x": -10
}
},
"exporting": {
"enabled": false
},
"credits": {
"style": {
"fontSize": "11px"
},
"href": "https://www.politiet.no/globalassets/dokumenter/oslo/rapporter/kriminalitet-i-oslo/kriminaliteten-i-oslo-forste-halvar-2017-pdf",
"text": "Kilde: Oslo politidistrikt",
"position": {
"align": "center"
}
},
"legend": {
"itemStyle": {
"color": "#26292a",
"fontWeight": "600"
}
},
"series": [
{
"color": "#4dcef6",
"index": 0
},
{
"index": 1
},
{
"index": 2
},
{
"index": 3
},
{
"index": 4
},
{
"index": 5
},
{
"index": 6
},
{
"index": 7
}
],
"subtitle": {
"style": {
"color": "#26292a",
"fontSize": "14px"
},
"text": null
},
"tooltip": {
"borderColor": "#c8c8c8",
"backgroundColor": "#ffffff",
"borderRadius": 0,
"shadow": false
},
"title": {
"style": {
"fontSize": "16px",
"color": "#26292a",
"fontWeight": "normal"
},
"text": "Straffbare forhold med mistenkt/siktet under 18 år i Oslo"
},
"chart": {
"marginRight": 20,
"spacingBottom": 30,
"spacingLeft": 0,
"style": {
"fontFamily": "\u0027LFT Etica\u0027, \u0027Helvetica Neue\u0027, Arial, sans-serif"
},
"inverted": true,
"type": "column",
"spacingRight": 0,
"height": 450
},
"colors": [
"#d4d4d4",
"#80d4d5",
" #b2eafb",
" #b2c6d4",
" #cceeee",
" #c9c1d5 "
]
};
parseData(function (dataOptions) {
// Merge series configs
if (chartOptions.series && dataOptions) {
Highcharts.each(chartOptions.series, function (series, i) {
chartOptions.series[i] = Highcharts.merge(series, dataOptions.series[i]);
});
}
var options = Highcharts.merge(dataOptions, chartOptions, template);
customCode(options, 'Chart');
}, chartOptions);
}
// Load the Highcharts script if undefined, and add the chart
if (typeof Highcharts !== 'undefined') {
addChart();
} else if (script) {
script.deferredCharts.push(addChart);
} else {
script = document.createElement('script');
script.id = 'highcharts-script';
script.src = '//app.everviz.com/resources/js/highstock-cloud-5.0.7.js';
script.type = 'text/javascript';
script.deferredCharts = [addChart];
script.onload = function () {
// Prevent double firing of event in IE9/IE10
if (!script.chartsAdded) {
script.chartsAdded = true;
while(script.deferredCharts.length) {
script.deferredCharts.shift()();
}
}
};
script.onreadystatechange = function() {
if (this.readyState == 'complete' || this.readyState == 'loaded') {
script.onload();
}
};
document.getElementsByTagName('head')[0].appendChild(script);
}
}());