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

Support for Highcharts 5 styled mode #115

Closed
textbook opened this issue Nov 22, 2016 · 6 comments
Closed

Support for Highcharts 5 styled mode #115

textbook opened this issue Nov 22, 2016 · 6 comments

Comments

@textbook
Copy link

Highcharts 5, now supported by angular2-highcharts, has a "styled mode" where you use CSS instead of JS to style your charts. We would like to use this in a project, but it isn't currently exposed by this library. Are there any plans to add this functionality?

If something like:

imports: [
  ChartModule.styledMode(),
  ...
]

was available that would be great.

Having quickly looked into it, it seems that modifying the HighchartsWrapper to require('highcharts/js/highcharts') would be sufficient to enable this behaviour by default. However, as the HighchartsService is provided directly to ChartComponent, it is difficult to inject an alternative from outside.

@tsabran
Copy link

tsabran commented Nov 22, 2016

I was just looking for the same thing !
We would also need highcharts/css/highcharts.css in case of "styled mode", I don't know if this can be imported automatically, maybe with something like styleUrls: in the ChartComponent ?

@gevgeny
Copy link
Owner

gevgeny commented Dec 11, 2016

It is easy to use by changing your webpack or systemjs config. Look at this commit changes gevgeny/angular2-webpack-starter-and-angular2-highcharts@c585a6b

@gevgeny gevgeny closed this as completed Dec 11, 2016
@textbook
Copy link
Author

textbook commented Dec 14, 2016

We're using Angular-CLI to configure and build our project; although this uses Webpack, it doesn't expose the resolve.alias setting. Unfortunately, therefore, that config change won't work for us.

@textbook
Copy link
Author

textbook commented Dec 14, 2016

A bit more fiddling, and we found that you could alter src/tsconfig.json, adding:

"baseUrl": ".",
"paths": {
  ...,
  "highcharts": ["../node_modules/highcharts/js/highcharts.js"] 
}

and angular-cli.json, adding:

"styles": [
  ...,
  "../node_modules/highcharts/css/highcharts.css"
],

If anyone else has the same problem (trying to use styled mode with Angular-CLI), that seems to solve it.

@iacii
Copy link

iacii commented Oct 18, 2017

I couldn't get paths to work for some reason.

I'm not very happy about using a hack like this, but I included the following in my package.json:

"prebuild": "copy /y node_modules\\highcharts\\js\\highcharts.js node_modules\\highcharts\\"

Now whenever I execute npm run build it will overwrite the "classic" version of highcharts with the "styled" one.

Edit:
It would be better to do this in the postinstall instead:

"postinstall": "copy /y node_modules\\highcharts\\js\\highcharts.js node_modules\\highcharts\\"

@alphadever
Copy link

is there any updates on this thread ? my project is an angular/cli based project, and the approach @textbook suggested does not work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants