Skip to content

Commit

Permalink
Support treegraph and treemap modules (#472)
Browse files Browse the repository at this point in the history
* Support treegraph and treemap modules

* Add demo, fix import order
  • Loading branch information
charlesfries authored Oct 4, 2024
1 parent a5d9733 commit f720f3e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ember-highcharts/src/components/high-charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,19 @@ export default class HighCharts<
SolidGauge.default(Highcharts);
}

if (
this.args.chartOptions?.chart?.type === 'treegraph' ||
this.args.chartOptions?.chart?.type === 'treemap'
) {
const Treemap = await import('highcharts/modules/treemap');
Treemap.default(Highcharts);
}

if (this.args.chartOptions?.chart?.type === 'treegraph') {
const Treegraph = await import('highcharts/modules/treegraph');
Treegraph.default(Highcharts);
}

if (this.args.chartOptions?.chart?.type === 'waterfall') {
const More = await waitForPromise(import('highcharts/highcharts-more'));
More.default(Highcharts);
Expand Down
4 changes: 4 additions & 0 deletions test-app/app/components/chart-treegraph.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<HighCharts
@content={{this.chartData}}
@chartOptions={{this.chartOptions}}
/>
28 changes: 28 additions & 0 deletions test-app/app/components/chart-treegraph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Component from '@glimmer/component';

export default class Treegraph extends Component {
chartOptions = {
chart: {
type: 'treegraph',
},
title: {
text: 'Organizational Structure',
},
};

chartData = [
{
keys: ['id', 'parent'],
data: [
['Alice'],
['Bill', 'Alice'],
['Carson', 'Bill'],
['Edward', 'Bill'],
['Dwayne', 'Alice'],
],
dataLabels: {
format: '{point.id}',
},
},
];
}
5 changes: 5 additions & 0 deletions test-app/app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@
<h3>Scatter chart</h3>
<ChartScatter />
</section>

<section>
<h3>Treegraph chart</h3>
<ChartTreegraph />
</section>

0 comments on commit f720f3e

Please sign in to comment.