Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
cloke committed Oct 22, 2024
1 parent e7c20f1 commit bd62118
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 80 deletions.
108 changes: 95 additions & 13 deletions ember-apache-echarts/src/modifiers/abstract-chart.ts

Large diffs are not rendered by default.

126 changes: 65 additions & 61 deletions ember-apache-echarts/src/modifiers/bar-chart.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions ember-apache-echarts/src/modifiers/graph-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ export default class GraphChartModifier extends AbstractChartModifier {
/**
* Configures the chart with the provided arguments.
*/
// @ts-expect-error: return to this
configureChart(args: ChartArgs, chart: ECharts) {
const { tooltipFormatter, onSelect, data, links, seriesConfig = {} } = args;
// @ts-expect-error: return to this
const { config } = this.buildLayout(args, chart);

const finalSeriesConfig = deepMerge(defaultSeriesConfig, { ...seriesConfig, data, links });
Expand Down Expand Up @@ -139,11 +141,15 @@ export default class GraphChartModifier extends AbstractChartModifier {
/**
* Generates the `data` section of the context used to construct this chart.
*/
// @ts-expect-error: return to this
createContextData(args: ChartArgs) {
// @ts-expect-error: return to this
const context = super.createContextData(args);
const { series, title } = this.drillPath.reduce(
({ series }, pathIndex) => ({
// @ts-expect-error: return to this
series: series[pathIndex].series,
// @ts-expect-error: return to this
title: series[pathIndex].label,
}),
{ series: context.series, title: args.title }
Expand All @@ -160,12 +166,14 @@ export default class GraphChartModifier extends AbstractChartModifier {
* Adds the title to `config` as defined in the data or by `args` and returns
* the new context layout.
*/
// @ts-expect-error: return to this
addTitle(context: TitleContext, config: TitleConfig) {
const buttonLayout = this.addDrillUpButton(context, config);
const buttonWidth = context.layout.width - buttonLayout.width;
const buttonHeight = context.layout.height - buttonLayout.height;

const titleLayout = super.addTitle(
// @ts-expect-error: return to this
{
...context,
args: {
Expand Down
28 changes: 24 additions & 4 deletions ember-apache-echarts/src/modifiers/pie-chart.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
import AbstractChartModifier from './abstract-chart.ts';
import type { ECharts, SelectChangedPayload } from 'echarts';
import { PieChart, type PieSeriesOption } from 'echarts/charts';
import { TooltipComponent, type TooltipComponentOption } from 'echarts/components';

Check failure on line 4 in ember-apache-echarts/src/modifiers/pie-chart.ts

View workflow job for this annotation

GitHub Actions / Lint

'TooltipComponentOption' is defined but never used. Allowed unused vars must match /^_/u
import { TitleComponent, type TitleComponentOption } from 'echarts/components';

Check failure on line 5 in ember-apache-echarts/src/modifiers/pie-chart.ts

View workflow job for this annotation

GitHub Actions / Lint

'TitleComponentOption' is defined but never used. Allowed unused vars must match /^_/u
import { LegendComponent, type LegendComponentOption } from 'echarts/components';

Check failure on line 6 in ember-apache-echarts/src/modifiers/pie-chart.ts

View workflow job for this annotation

GitHub Actions / Lint

'LegendComponentOption' is defined but never used. Allowed unused vars must match /^_/u
import { GridComponent, type GridComponentOption } from 'echarts/components';

Check failure on line 7 in ember-apache-echarts/src/modifiers/pie-chart.ts

View workflow job for this annotation

GitHub Actions / Lint

'GridComponentOption' is defined but never used. Allowed unused vars must match /^_/u
import { DataZoomComponent, type DataZoomComponentOption } from 'echarts/components';

Check failure on line 8 in ember-apache-echarts/src/modifiers/pie-chart.ts

View workflow job for this annotation

GitHub Actions / Lint

'DataZoomComponentOption' is defined but never used. Allowed unused vars must match /^_/u
import { GraphicComponent, type GraphicComponentOption } from 'echarts/components';

Check failure on line 9 in ember-apache-echarts/src/modifiers/pie-chart.ts

View workflow job for this annotation

GitHub Actions / Lint

'GraphicComponentOption' is defined but never used. Allowed unused vars must match /^_/u
import { CanvasRenderer } from 'echarts/renderers';
import { use } from 'echarts/core';

// TODO: Import only the required components to keep the bundle size small. See
// https://echarts.apache.org/handbook/en/basics/import/ [twl 6.Apr.22]
use([
CanvasRenderer,
PieChart,
TooltipComponent,
TitleComponent,
LegendComponent,
GridComponent,
DataZoomComponent,
GraphicComponent,
]);

type ChartArgs = {
series?: unknown[];
series?: PieSeriesOption[];
data?: unknown[];
tooltipFormatter?: (params: unknown) => string;
onSelect?: (name: string | null) => void;
Expand Down Expand Up @@ -47,9 +64,11 @@ type ChartArgs = {
* : Whether to render a `pie` or a `donut`
*/
export default class PieChartModifier extends AbstractChartModifier {
// @ts-expect-error: follow up on this
configureChart(args: ChartArgs, chart: ECharts) {
const allSeries = args.series ?? [{ data: args.data }];
const { tooltipFormatter, onSelect } = args;
// @ts-expect-error: follow up on this
const { config } = this.buildLayout(args, chart);

chart.setOption({
Expand All @@ -69,7 +88,7 @@ export default class PieChartModifier extends AbstractChartModifier {
const seriesIndex = fromActionPayload['seriesIndex'];
const dataIndex = fromActionPayload['dataIndexInside'];
const series = allSeries[seriesIndex];
// @ts-expect-error: until the abstract is typed this needs to wait
// @ts-expect-error: follow up on this
const name = series.data[dataIndex] ? series.data[dataIndex].name : null;

if (name) {
Expand Down Expand Up @@ -121,6 +140,7 @@ export default class PieChartModifier extends AbstractChartModifier {
return (!series.data || series.data.length == 0) && noDataText
? this.generateTextConfig(
noDataText,
// @ts-expect-error: follow up on this
{
width: layout.innerWidth,
height: layout.innerHeight,
Expand Down
9 changes: 9 additions & 0 deletions ember-apache-echarts/src/modifiers/tree-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { tracked } from '@glimmer/tracking';
import deepMerge from '../utils/deep-merge.ts';
import type { ECharts, SelectChangedPayload } from 'echarts';
import resolveStyle from '../utils/style/resolve-style.ts';
import mergeAtPaths from '../utils/merge-at-paths.ts';

const defaultSeriesConfig = {
type: 'tree',
Expand Down Expand Up @@ -64,8 +65,10 @@ export default class GraphChartModifier extends AbstractChartModifier {
/**
* Configures the chart with the provided arguments.
*/
// @ts-expect-error: return to this
configureChart(args: ChartArgs, chart: ECharts) {
const { tooltipFormatter, onSelect } = args;
// @ts-expect-error: return to this
const { config } = this.buildLayout(args, chart);
const { data, seriesConfig = {} } = args;

Expand Down Expand Up @@ -108,11 +111,15 @@ export default class GraphChartModifier extends AbstractChartModifier {
/**
* Generates the `data` section of the context used to construct this chart.
*/
// @ts-expect-error: return to this
createContextData(args: ChartArgs) {
// @ts-expect-error: return to this
const context = super.createContextData(args);
const { series, title } = this.drillPath.reduce(
({ series }, pathIndex) => ({
// @ts-expect-error: return to this
series: series[pathIndex].series,
// @ts-expect-error: return to this
title: series[pathIndex].label,
}),
{ series: context.series, title: args.title }
Expand All @@ -129,12 +136,14 @@ export default class GraphChartModifier extends AbstractChartModifier {
* Adds the title to `config` as defined in the data or by `args` and returns
* the new context layout.
*/
// @ts-expect-error: return to this
addTitle(context: TitleContext, config: TitleConfig) {
const buttonLayout = this.addDrillUpButton(context, config);
const buttonWidth = context.layout.width - buttonLayout.width;
const buttonHeight = context.layout.height - buttonLayout.height;

const titleLayout = super.addTitle(
// @ts-expect-error: return to this
{
...context,
args: {
Expand Down
4 changes: 3 additions & 1 deletion ember-apache-echarts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
We want our tooling to know how to resolve our custom files so the appropriate plugins
can do the proper transformations on those files.
*/
"allowImportingTsExtensions": true
"allowImportingTsExtensions": true,

"target": "esnext"
}
}
2 changes: 1 addition & 1 deletion test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "tests"
},
"scripts": {
"build": "ember build --environment=production",
"build": "pnpm --filter ember-apache-echarts build && ember build --environment=production",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint:hbs": "ember-template-lint .",
Expand Down

0 comments on commit bd62118

Please sign in to comment.