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/1-simple-column #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
65 changes: 65 additions & 0 deletions highcharts-api/highcharts/1-simple-column/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const generateRandomNumber = () => Math.floor(Math.random() * 10);
const generateRandomTriplet = () => Array.from({ length: 3 }, generateRandomNumber);
jszuminski marked this conversation as resolved.
Show resolved Hide resolved

Highcharts.chart('container', {
chart: {
type: 'column',

jszuminski marked this conversation as resolved.
Show resolved Hide resolved
events: {
load() {
const chart = this;
const maxY = chart.yAxis[0].dataMax;
jszuminski marked this conversation as resolved.
Show resolved Hide resolved

chart.yAxis[0].update({
max: maxY * 2,
plotLines: [{
color: 'green',
value: 1.5 * maxY,
dashStyle: 'dash',
width: 2
}]
});
jszuminski marked this conversation as resolved.
Show resolved Hide resolved

chart.update({
plotOptions: {
series: {
dataLabels: {
enabled: true,
formatter() {

return this.point.y === maxY ? 'max' : '';
}
}
}
}
})
jszuminski marked this conversation as resolved.
Show resolved Hide resolved
}
}
},

title: {
text: ''
},
jszuminski marked this conversation as resolved.
Show resolved Hide resolved

yAxis: {
title: {
text: ''
}
},

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

series: [{
name: 'Tokyo',
data: generateRandomTriplet()
}, {
name: 'New York',
data: generateRandomTriplet()
}, {
name: 'London',
data: generateRandomTriplet()
}]

});