Created
October 8, 2013 19:37
-
-
Save TamaraAtanasoska/6890299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
Highcharts.setOptions({ | |
colors: ['#585D85', '#7F89D9', '#999999', '#F08F7A', '#E0605C'] | |
}); | |
function formatWithLineBreaks(str) { | |
var words = str.split(' '); | |
var lines = []; | |
var line = ''; | |
$.each(words, function(idx, word) { | |
if (line.length + word.length > 25) { | |
lines.push(line); | |
line = ''; | |
} | |
line += word + ' '; | |
}); | |
lines.push(line); | |
return lines.join('<br/>'); | |
} | |
var chart = new Highcharts.Chart({ | |
chart: { | |
renderTo: 'container', | |
defaultSeriesType: 'pie', | |
borderWidth: 1 | |
}, | |
title: { | |
text: 'Број на пензионери во Р. Македонија' | |
}, | |
subtitle: { | |
text: '2012' | |
}, | |
credits: { | |
position: { | |
align: 'left', | |
x: 20 | |
}, | |
href: 'http://www.piom.com.mk/', | |
text: 'Извор: ПИОМ | Прикажано на: rodovreactor.mk' | |
}, | |
plotOptions: { | |
pie: { | |
slicedOffset: 20, | |
allowPointSelect: true, | |
dataLabels: { | |
formatter: function() { | |
var str = this.point.name + ': ' + Highcharts.numberFormat(this.y, 0); | |
return formatWithLineBreaks(str); | |
} | |
} | |
} | |
}, | |
series: [{ | |
name: 'Број на пензионери', | |
dataLabels: { | |
formatter: function() { | |
return this.point.name + ': ' + Highcharts.numberFormat(this.percentage, 0) + '%'; | |
} | |
}, | |
data: [ [ 'Мажи', 204256 ], ['Жени', 81155], ] | |
}] | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment