apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.25k stars 19.61k forks source link

[Bug] Unable to get charts to render using custom treeshaking build #16834

Closed jkasperbl closed 5 months ago

jkasperbl commented 2 years ago

Version

5.3.2

Link to Minimal Reproduction

https://stackblitz.com/edit/github-1mzjky-bfluyv?file=src/app/app.module.ts

Steps to Reproduce

Open the StackBlitz link above and a simple line chart will render using a full Echarts build. The issue occurs if you modify app.module.ts to us the custom Echarts treeshaking build instead -- the chart will no longer render, despite no error message in the console.

Current Behavior

With the current code in the StackBlitz link provided above, my sample line chart renders correctly. However, this is using a "full" echarts import which you can see in app.module.ts:

NgxEchartsModule.forRoot({ echarts: () => import('echarts' as const) })

If you comment out that line and uncomment the line above, it will instead use my attempt at a custom build:

NgxEchartsModule.forRoot({ echarts })

Although no errors are present in the JavaScript console, the chart no longer renders.

Expected Behavior

The chart should render with a custom treeshaking build.

Environment

- OS: Windows 11
- Browser: Edge
- Framework: Angular

Any additional comments?

As far as I can tell, I have imported all of the necessary components required for such a simple example --I would think * from echarts/core, LineChart, and `CanvasRenderer' are all that's needed, but it seems likely there's something else I'm missing that I'm not aware of.

import * as echarts from 'echarts/core';
import { LineChart } from 'echarts/charts';
import {
  GridComponent,
  LegendComponent,
  TitleComponent,
  ToolboxComponent,
  TooltipComponent,
} from 'echarts/components';
import { CanvasRenderer } from 'echarts/renderers';
import { NgxEchartsModule } from 'ngx-echarts';

echarts.use([
  CanvasRenderer,
  GridComponent,
  LegendComponent,
  LineChart,
  TitleComponent,
  ToolboxComponent,
  TooltipComponent,
]);

Any help would be greatly appreciated in figuring this out. It's possible that this issue is with the ngx-echarts library rather than core Echarts, but since most of the imports are directly from the core package I think that's unlikely.

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] commented 5 months ago

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!