score:5
There is a NPM called commonjs-highcharts that solves it.
Just run npm i commonjs-highcharts
and import it:
import highcharts from "commonjs-highcharts"
Worked for me.
score:0
Try using the package name as used during npm install
:
import highcharts from 'highcharts-release';
score:0
i am working with AngulrJS, ES6, Webpack and Babel. it took me a while to find it but i ended up using expose on highchart.
this is what i did:
npm install highcharts --save
import 'expose?highcharts!highcharts/highcharts';
only import as shown, no need for any thing else.
and then you can simple use highchart in your controller (without adding it as a dependency)
score:0
import Highcharts from 'highcharts';
import 'highcharts-ng' //add this line if you wish to use highcharts angular directive
And then add a new rule in the webpack.config.js
{
test: require.resolve('highcharts'),
use:[{
loader: 'expose-loader',
options: 'Highcharts'
}]
}
score:1
You don't need any extra plugin or modification in your webpack config file. Just follow these steps:
install typings file for highcharts using this:
npm install --save @types/highcharts
change your import statements to following:
import * as Highcharts from 'highcharts';
import HighchartsMore = require('highcharts/highcharts-more');
HighchartsMore(Highcharts);
score:1
For me only this method is working with webpack(and was working with browserify as well):
global.js
import $ from 'jquery';
global.$ = global.jQuery = $;
app.js
import './globals';
import 'angular';
import 'highcharts';
// ...
I don't know why webpack.ProvidePlugin
works fine with AngularJS
but not with highcharts
.
My config was looking like:
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery', // for using with AngularJS
_: 'underscore',
moment: 'moment'
})
// I've also tried this but without luck:
{
test: require.resolve('highcharts'),
loader: 'imports-loader?jQuery=jquery'
}
score:2
Try doing an npm install highcharts-release
. Then in your JavaScript file do import Highcharts from 'highcharts-release/highcharts';
. There may be a better way, but that worked for me.
score:2
Try variations of:
require('expose?Highcharts!highcharts');
require('highcharts/modules/map')(Highcharts);
require('highcharts/highcharts-more')(Highcharts);
require('expose?Highcharts!highcharts/highstock');
If you wander around in ./node_modules/highcharts/...
you might be able to trial-and-error your way into the modules and/or libs you need.
I don't have any joy using the form
$('myselector').highcharts(...)
Replacing them with
Highcharts.chart('myselector', ...)
works for me.
score:3
This is how I solved it, using Webpack v4.16.5 and Highcharts v5.0.11.
webpack.config
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: [{
loader: 'babel-loader'
}]
},
{
test: /highcharts.*/,
loader: 'imports-loader?window=>global&window.jQuery=>$'
}
// ...
],
alias: {
jquery: 'jquery/jquery'
// ...
}
},
externals: {
jQuery: 'jQuery'
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'window.$': 'jquery',
Highcharts: 'highcharts/highcharts'
// ...
})
]
main.js 1st option
import addMore from 'highcharts/highcharts-more'
import addExporting from 'highcharts/modules/exporting'
import addOfflineExporting from 'highcharts/modules/offline-exporting'
import addSolidGauge from 'highcharts/modules/solid-gauge'
import addDrilldown from 'highcharts/modules/drilldown'
import addTreemap from 'highcharts/modules/treemap'
import addFunnel from 'highcharts/modules/funnel'
addMore(Highcharts)
addExporting(Highcharts)
addOfflineExporting(Highcharts)
addSolidGauge(Highcharts)
addDrilldown(Highcharts)
addTreemap(Highcharts)
addFunnel(Highcharts)
main.js 2nd option:
require('highcharts/highcharts-more')(Highcharts)
require('highcharts/modules/exporting')(Highcharts)
require('highcharts/modules/offline-exporting')(Highcharts)
require('highcharts/modules/solid-gauge')(Highcharts)
require('highcharts/modules/drilldown')(Highcharts)
require('highcharts/modules/treemap')(Highcharts)
require('highcharts/modules/funnel')(Highcharts)
This way, it's both $(..).highcharts()
and Highcharts.chart()
usable.
Hope this helps!
score:11
Try this:
npm install highcharts
The issue I faced with this approach is using other modules in highcharts, such as highcharts-more, map, etc., To overcome this I imported highcharts and the other required modules like this:
import highcharts from 'highcharts';
import highchartsMore from 'highcharts-more';
highchartsMore(highcharts);
Source: stackoverflow.com
Related Query
- how to import highcharts with webpack and babel
- How to structure Angular with Highcharts and lots of dynamic data
- Highcharts 3.0, area chart with stacked and unstacked series - how to fix?
- Highcharts - Global configuration with common code and unique data & Headings
- How to enable noData with highcharts and angular
- How to export CSV and XLS with external button in Highcharts
- How to use Highmaps and Highcharts with Meteor?
- How to draw a bubble map with longitude and latitude using Highcharts in react
- Highcharts - How to populate date with Mysql and PHP?
- Highcharts : How do I keep the marker formatting and make the click event fire with a 5K+ point scatter plot?
- HighCharts & MVC: How to load whole graph definition and data with JSON?
- How to properly import HighCharts with Backbone-boilerplate in an ECMAScript 2015 way?
- How do I export the content of a page as either jpg or pdf with Highcharts and scrollable data?
- How to have a highcharts chart in a container of a fixed width, and with a horizontal scrollbar?
- how to show column and area charts with different y axis with same category and same x axis in highcharts
- How to Change marker symbol and dataLabel with custom style in Highcharts
- How to display only last point on highcharts and that point should travel with chart line?
- How to transform a point with latitude and longitude value to a coordinates in highcharts map?
- Highcharts Angular - How to set chart width and height with percentages?
- How to have multiple highcharts with different series data in vuejs without repeating code
- How to combine highcharts (heatmap) and table (mapping each table row with heatmap row)?
- how to make chart real time with 2 line and get data from php with highcharts
- Import CSV to highcharts scatterplot with tooltip populated by point name and x,y values
- Using the source version instead of mimified when import lib with reactjs and npm
- Highcharts - how to display a chart with stacked and un-stacked columns side-by-side
- how can I use rangeselector and navigation in highcharts in the given code
- HIGHCHARTS - Given a series with UNIX stamps and values pairs for the data, how do I show only the date for the first and last point on xAxis?
- How to set category type with Highcharts and chartkick?
- How to implement highcharts navigator with 24HR and weekly zoom filter?
- How to create a column range chart in Highcharts using range and navigator functions?
More Query from same tag
- Update Series Array on HighChart after editing chart
- Rendering pie chart using xtype and Ext.create
- Highcharts / Highstock: How to access values at the centers of dataGroups of another series
- Show logo and menu before Highcharts
- Make the chart display current year in HighChart
- creating lists based on JSON data
- Retrieve missing column Values
- How to implement the KDJ indicator calculation in highcharts
- Highcharts - How to add background in bar series? And how to print page without lose quality?
- Weekly PDF generation using PHP and Highcharts
- How to prevent bars overlapping eachother in Highcharts?
- Highcharts dataLabels shadows
- Stack line on area / stack area on line in highcharts?
- highmap does not display
- How to make stacked column graph to show total data value on top
- Can't get drilldown module to work in highcharts in typescript
- Change a highchart subtittle
- Population density and Circles (to represent earthquakes) on the same Map
- It's not possible load Highstock from the CDN as an AMD module
- Highcharts age stacking
- Custom Marker (Rectangle with rounded corner) for highcharts scatter graph
- Highchart Pie Chart label size in Wordpress
- Issues Getting Highcharts Export Server Running Under iisnode
- JS Gauge with growing arc
- Customize Stacked column chart in highChart
- Unable to view highcharts in my yii2 project
- Highcharts - Change line style in line gaps (null)
- HighCharts: automatic x-axis issue in presence of missing data values
- high charts - how do I get a stacked graph to the full width?
- HighCharts performance issue and alternative