Code Monkey home page Code Monkey logo

Comments (6)

NexusInk avatar NexusInk commented on July 24, 2024

Managed a small hack on echart-components.ts with
ngOnDestroy(): void { window.removeEventListener('resize', this.resizeListener, true); this.chart.resize(); }
Refer to this Stackoverflow Q&A: https://stackoverflow.com/questions/38158318/is-it-possible-to-use-echarts-baidu-with-angular-2-and-typescript

This gets rid of runtime errors - but there are other bugs as well ;)

from blog.

ralscha avatar ralscha commented on July 24, 2024

Hi
Looks like there is now an angular directive for echarts 3.x
https://github.com/xieziyu/ngx-echarts

Maybe this is the better way going forward.

from blog.

NexusInk avatar NexusInk commented on July 24, 2024

Thanks.

Your work has been of great value - your blog has been an eye opener.

from blog.

NexusInk avatar NexusInk commented on July 24, 2024

Hey
Took a look at the ngx-echarts - pretty comprehensive - thanks.

Try this if you get the runtime error (from ngx-echarts):
ngOnDestroy() { if (this.myChart) { this.myChart.dispose(); this.myChart = null; } }

It is a more consistent approach than my awkward hack.

from blog.

NexusInk avatar NexusInk commented on July 24, 2024

ngx-echarts provides a wrapper for ECharts - very efficient for Angular Modules, but it feels like it's calling in an extra layer for Ionic to process.
Building out a custom component (like you did in your blog) seems more feasible.
Let me know what you think once you've played around with it.
I'll be posting a repo with ngx-echarts/echarts soon.
Very handy solution, nonetheless.

from blog.

ralscha avatar ralscha commented on July 24, 2024

I changed the code of the blog to ngx-echarts. I like it better than my approach.
The only problem is that it does not automatically import the echarts library.
One solution that I use now is copying the directive into my project and add an import statement
import * as echarts from 'echarts/dist/echarts-en.js';

Another solution is creating a custom copy config that copies the echarts library to the www directory and then reference it in the index.html

copy.config.js

module.exports = {
  copyEcharts: {
    src: ['./node_modules/echarts/dist/echarts-en.min.js'],
    dest: '{{WWW}}/build'
  }
}

package.json

   ...
  "config": {
    "ionic_copy": "./copy.config.js"
  },
  ...

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.