Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highcharts/2-polar-rings #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions highcharts-api/highcharts/2-polar-rings/index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<!doctype html>

<html>
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">

<script src="https://code.highcharts.com/highcharts.js"></script>

<script src="https://code.highcharts.com/highcharts-more.js"></script>
</head>

<body>
<div id="container"></div>
<script src="main.js"></script>
</body>

<script src="main.js"></script>
</html>
82 changes: 82 additions & 0 deletions highcharts-api/highcharts/2-polar-rings/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const getRandomData = (length) => Array.from({ length }, () => Math.floor(Math.random() * 10));

const chart = Highcharts.chart('container', {
chart: {
polar: true,

events: {
load() {
const chart = this,
maxY = chart.yAxis[0].dataMax;

chart.yAxis[0].update({
max: maxY * 2,
plotLines: [{
color: 'green',
value: 1.5 * maxY,
dashStyle: 'dash',
width: 2
}, {
color: 'red',
value: 1.75 * maxY,
width: 1.5
}]
});
},

render() {
jszuminski marked this conversation as resolved.
Show resolved Hide resolved
const chart = this,
radius = chart.yAxis[0].toPixels(2 * chart.yAxis[0].dataMax) * 2;

if(chart.circle) {
chart.circle.attr({
x: chart.chartWidth / 2,
y: chart.plotHeight / 2 + chart.plotTop,
radius
});
} else {
chart.circle = chart.renderer.circle(chart.chartWidth / 2, chart.chartHeight / 2 - 20, radius).attr({
fill: 'transparent',
stroke: 'dodgerblue',
'stroke-width': 2
}).add();
}
},
}
},

title: {
text: ''
},

xAxis: {
categories: ['Jan', ' Feb', 'Mar']
},

plotOptions: {
series: {
dataLabels: {
enabled: true,
formatter() {
return this.point.y === this.point.series.yAxis.dataMax ? 'max' : '';
}
}
}
},

series: [{
type: 'column',
name: 'Tokyo',
data: getRandomData(3)
}, {
type: 'column',
name: 'New York',
data: getRandomData(3)
}, {
type: 'column',
name: 'London',
data: getRandomData(3)
}]

});