Giter VIP home page Giter VIP logo

Comments (13)

SayakMukhopadhyay avatar SayakMukhopadhyay commented on June 12, 2024 2

UPDATE:
The procedure mention in #59 (comment) is working in Angular 5. Tried and tested!

from angular-highcharts.

cebor avatar cebor commented on June 12, 2024

@tavuntu yes, the following should work.

import { Highcharts } from 'angular-highcharts';

// Apply the theme
Highcharts.setOptions(Highcharts.theme);

from angular-highcharts.

gustavostuff avatar gustavostuff commented on June 12, 2024

The object Highcharts is undefined when importing it, so it throws an error when trying to use .theme or .setOptions(). I've added the ChartModule un app.moduel.ts, maybe I'm missing something else?

EDIT: this results in an undefined object as well... weird:
import { Highcharts } from 'highcharts';

from angular-highcharts.

cebor avatar cebor commented on June 12, 2024

To resolve this issue i need more code to dig into this. Can you setup a minimal repo or Plunkr?

from angular-highcharts.

gustavostuff avatar gustavostuff commented on June 12, 2024

here you go, I'm using npm 5.4.0 and the latest version of angular-highcharts
https://github.com/tavuntu/general-stuff

from angular-highcharts.

SayakMukhopadhyay avatar SayakMukhopadhyay commented on June 12, 2024

Was this issue resolved? Is there any workaround?

from angular-highcharts.

gustavostuff avatar gustavostuff commented on June 12, 2024

@SayakMukhopadhyay I haven't tested this since then (I switched to Chart.js), are seeing the issue?

from angular-highcharts.

SayakMukhopadhyay avatar SayakMukhopadhyay commented on June 12, 2024

Yeah, I am. I am planning on the only workaround of loading the theme js in the header for now. Using setOptions is more flexible though.

from angular-highcharts.

dereklin avatar dereklin commented on June 12, 2024

Highcharts.setOptions(Highcharts.theme); seems to affect the new charts after it.

What would the easiest way to refresh the charts so that the new theme is applied immediately to existing charts?

from angular-highcharts.

SayakMukhopadhyay avatar SayakMukhopadhyay commented on June 12, 2024

If you don't mind looking through source code, I have implemented a dynamic theme switcher in https://github.com/SayakMukhopadhyay/elitebgs . This is the service file . The theme switch is triggered in this component and the chart is rendered in this component

from angular-highcharts.

dereklin avatar dereklin commented on June 12, 2024

Interesting, so you are basically recreating the chart when switching themes right?

this.themeService.theme$.subscribe(theme => {
            this.chart = new Chart(this.options);
        });

By doing

this.linkRef.onload = () => this.themeService.themeLoaded();

and

this.linkRef.href = this.themeService.getTheme().href;

You are loading the style sheet related to the theme dynamically and also triggering the theme change, right?

from angular-highcharts.

SayakMukhopadhyay avatar SayakMukhopadhyay commented on June 12, 2024

Yup. Recreating the chart object is the only way to change the theme as far as what I have found.

from angular-highcharts.

wiggitamoo avatar wiggitamoo commented on June 12, 2024

I was able to get it working like this:

this.chart = new Chart({...});
this.chart.theme = {...};
Highcharts.setOptions(this.chart.theme);

from angular-highcharts.

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.