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

[SOLVED] I've got custom theme.js and dunno how to import it into angular app #403

Open
armando-ota opened this issue Jul 13, 2023 · 3 comments

Comments

@armando-ota
Copy link

I've got angular 15 app.
Can anyone please tell me how or where to load theme.js file that registeres theme into echarts.

any help appreciated.
Regards

Armando

@xieziyu
Copy link
Owner

xieziyu commented Jul 13, 2023

just import your theme.js after echarts imported.

import 'echarts/theme/macarons.js';

@armando-ota
Copy link
Author

armando-ota commented Jul 13, 2023

in app.module.ts
i've got

imports: [
NgxEchartsModule.forRoot({
      /**
       * This will import all modules from echarts.
       * If you only need custom modules,
       * please refer to [Custom Build] section.
       */
      echarts: () => import('echarts'), // or import('./path-to-my-custom-echarts')
    }),
]

I've added to angular.json

"scripts": [
              "node_modules/echarts/dist/echarts.js",
              "src/assets/echarts/depoTheme.js"
            ]

and theme is loaded cause I've added console.log in theme JS file

using in directive attribute name theme="depo"

charts are not themed .. dunno what I'm doing wrong

@armando-ota
Copy link
Author

armando-ota commented Jul 13, 2023

ok I've managed to fix it by putting
into app.module.ts:
import * as echarts from 'echarts';
import '../assets/echarts/depoTheme.js';

and changed in imports to:
NgxEchartsModule.forRoot({ echarts }),

I was hoping that lazy loading with themes was also a posibility.

@armando-ota armando-ota changed the title I've got custom theme.js and dunno how to import it into angular app [SOLVED] I've got custom theme.js and dunno how to import it into angular app Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants