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/9-3d-charts #21

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
15 changes: 12 additions & 3 deletions highcharts-api/highcharts/9-3d-charts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
<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/10.2.0/highcharts.js"></script>
<script src="https://code.highcharts.com/10.2.0/highcharts-3d.js"></script>
<script src="https://blacklabel.github.io/projections/js/projections.js"></script>

<script src="https://code.highcharts.com/highcharts.js"></script>
<!-- For part 2 -->
<script src="https://code.highcharts.com/10.2.0/modules/cylinder.js"></script>
<script src="https://code.highcharts.com/10.2.0/modules/funnel3d.js"></script>
<script src="https://code.highcharts.com/10.2.0/modules/pyramid3d.js"></script>

</head>

<body>
<div id="container"></div>
<div id="solar-container"></div>
<div id="pyramid-container"></div>
</body>

<script src="main.js"></script>
<script src="solar.js"></script>
<script src="pyramid.js"></script>
Empty file.
26 changes: 26 additions & 0 deletions highcharts-api/highcharts/9-3d-charts/pyramid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Highcharts.chart('pyramid-container', {
chart: {
options3d: {
enabled: true,
alpha: 8
},
},

title: {
text: 'Highcharts Funnel/Pyramid3D Chart'
},

series: [{
type: 'funnel3d',
data: [15654, 4064, 1987, 976, 846],
neckWidth: '25%',
neckHeight: '100%',
height: 150,
}, {
type: 'pyramid3d',
data: [15654, 4064, 1987, 976, 846],
height: 150,
width: 400,
center: ['50%', '35']
}]
})
129 changes: 129 additions & 0 deletions highcharts-api/highcharts/9-3d-charts/solar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
let time = 0;

function generateGradient(color) {
return {
radialGradient: { cx: 0.4, cy: 0.3, r: 0.5 },
stops: [
[0, color],
[1, Highcharts.color(color).brighten(-0.5).get('rgb')]
],
}
}

Highcharts.chart('solar-container', {
chart: {
margin: 100,
type: 'scatter3d',
animation: false,

options3d: {
enabled: true,
alpha: 10,
beta: 45,
depth: 250,
viewDistance: 5,
fitToPlot: false,
frame: {
bottom: { size: 1, color: 'black', },
back: { size: 1, color: 'black', },
side: { size: 1, color: 'black', }
}
},

events: {
load() {
const chart = this,
timeInterval = 0.001;

const calculatePosition = (start, multiplier, func = Math.sin, angularFrequency = 10) => start + multiplier * func(angularFrequency * time);

setInterval(() => {
chart.series[0].data[1].update({
x: calculatePosition(5, 2.5),
z: calculatePosition(5, 2.5, Math.cos)
});

chart.series[0].data[2].update({
x: calculatePosition(chart.series[0].data[1].x, 0.5, Math.sin, 25),
z: calculatePosition(chart.series[0].data[1].z, 0.5, Math.cos, 25),
})

time += timeInterval;
}, timeInterval);
}
}
},

title: {
text: 'Solar System',
},

plotOptions: {
series: {
width: 10,
height: 10,
planeProjection: {
enabled: true,
byPoint: true
}
}
},

yAxis: {
min: 0,
max: 10,
title: null,
},

xAxis: {
min: 0,
max: 10,
gridLineWidth: 1,
},

zAxis: {
min: 0,
max: 10,
showFirstLabel: false,
},

legend: {
enabled: false,
},

series: [{
name: 'Solar System',
data: [
{
name: 'Sun',
x: 5, y: 5, z: 5,
color: '#d6cf4b',
marker: {
fillColor: generateGradient('#d6cf4b'),
radius: 15,
symbol: 'circle'
},
},
{
name: 'Earth',
x: 4.5, y: 5, z: 5,
color: '#7caff7',
marker: {
fillColor: generateGradient('#7caff7'),
radius: 7,
symbol: 'circle'
}
},
{
name: 'Moon',
x: 4.5, y: 5, z: 6,
color: '#ff9cfa',
marker: {
fillColor: generateGradient('#ff9cfa'),
radius: 4,
symbol: 'circle'
}
}
],
}]
})