Skip to content

Commit

Permalink
docs: Polar chart in test app
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalBryxi committed Oct 4, 2024
1 parent 7995a3e commit c26858e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test-app/app/components/chart-line-polar.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<HighCharts
@content={{this.chartData}}
@chartOptions={{this.chartOptions}}
/>
44 changes: 44 additions & 0 deletions test-app/app/components/chart-line-polar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Component from '@glimmer/component';

const DIRECTIONS = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
const WIND_DATA = [
0, 10, 15, 10, 20, 45, 47, 90, 110, 115, 130, 150, 160, 188, 190, 185, 192,
];

export default class LineBasic extends Component {
chartOptions = {
chart: {
type: 'line',
polar: true,
},
title: {
text: 'Wind direction history',
},
xAxis: {
tickInterval: 45,
min: 0,
max: 360,
labels: {
formatter: function ({ value }) {
return DIRECTIONS[Math.round(value / 45)];
},
},
},
yAxis: {
min: 0,
max: 1,
labels: {
enabled: false,
},
},
tooltip: false,
};

chartData = [
{
name: 'Amisbühl',
data: WIND_DATA.map((x, i) => ({ x, y: i / (WIND_DATA.length - 1) })),
connectEnds: false,
},
];
}
7 changes: 6 additions & 1 deletion test-app/app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<ChartBarBasic />
</section>

<section>
<h3>Polar chart</h3>
<ChartLinePolar />
</section>

<section>
<h3>Basic highmaps chart</h3>
<ChartMapBasic />
Expand Down Expand Up @@ -53,4 +58,4 @@
<section>
<h3>Scatter chart</h3>
<ChartScatter />
</section>
</section>

0 comments on commit c26858e

Please sign in to comment.