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

Add support for polar charts #481

Merged
merged 2 commits into from
Oct 7, 2024
Merged
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
5 changes: 5 additions & 0 deletions ember-highcharts/src/components/high-charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,10 @@ export default class HighCharts<
const More = await waitForPromise(import('highcharts/highcharts-more'));
More.default(Highcharts);
}

if (this.args.chartOptions?.chart?.polar === true) {
const More = await waitForPromise(import('highcharts/highcharts-more'));
More.default(Highcharts);
}
}
}
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,
},
];
}
5 changes: 5 additions & 0 deletions 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