Comments (8)
As you import Highcharts from 'highcharts/highmaps'
, which is already include highmaps, you don't need load map from 'highcharts/modules/map'
again.
import Vue from 'vue';
import VueHighcharts from 'vue-highcharts';
import Highcharts from 'highcharts/highmaps';
Vue.use(VueHighcharts, { Highcharts });
Live example: https://codesandbox.io/s/o48pkv67r9
from vue-highcharts.
Thanks for the example. I have exactly that code now except for the name of my main app.. but for me the component isn't working. I was using it as a component within another component, but re did it to look like the codesandbox
. Really perplexed about what the difference might be
from vue-highcharts.
Maybe you can try to import highcharts and vue-highcharts in your entry file and Vue.use it.
from vue-highcharts.
It appears that highmaps won't work if it's being imported dynamically. My import was in this listener
document.addEventListener('DOMContentLoaded', function(event) {
if (document.getElementById('fundData')) {
import(/* webpackChunkName: "chartComponents" */ './chartComponentsIndex');
}
});
And it failed silently. Can you think of why this would be and if there is a way around it? I want to confine the heavy highcharts related code to being loaded only when it's used.
Once I did as you suggested it started initializing highmaps, but my piechart and barchart components started throwing an error The requested series type does not exist
.
from vue-highcharts.
I'm not clear about what is in ./fundDataIndex
and which part of your code is imported dynamically. But if you want to load highmaps async, you should also load vue-highcharts async and then Vue.use it.
Example: https://codesandbox.io/s/xp7m85ypmo
from vue-highcharts.
The way I'm doing it is a little different with a dynamic import and then loading the data for the components via a service. I put the structure up on codesandbox, though it won't function without the endpoint and I'm not sure if codesandbox supports the dynamic webpack imports (it requires a babel plugin to support the import() syntax)
https://codesandbox.io/s/lx1yqq9nz9
If you see something that makes sense in keeping those from working.. the other types of charts are functioning exactly as expected. The loading process is a bit complex so I'm not sure how to mirror it online easily, but I'll try and work up a complete example maybe using require.ensure
if nothing sticks out
from vue-highcharts.
OK, let me try to explain:
In chartRenderer.vue
, you import pieChart.vue
and then mapChart.vue
, so we jump into pieChart.vue
, you call Vue.use(VueHighcharts)
without passing in a Highcharts
object, vue-highcharts will import Highcharts from 'highcharts'
by default, which point to highcharts/highcharts.js
file. Then in mapChart.vue
, you try to import Highcharts from 'highcharts/highmaps.js'
, a different file, means the two Highcharts
object don't have same reference. But it's not the point, you then call Vue.use(VueHighcharts, { Highcharts })
again, Vue will automatically prevents you from using the same plugin more than once, so the Highcharts
object inside vue-highcharts is still highcharts/highcharts.js
.
To fix this problem, the key point is make sure all Highcharts
have same reference. So always import Highcharts from 'highcharts'
and use add-ons by loading corresponding modules.
// pieChart.vue
import Vue from 'vue';
import VueHighcharts from 'vue-highcharts';
import Highcharts from 'highcharts';
Vue.use(VueHighcharts, { Highcharts });
// mapChart.vue
import Vue from 'vue';
import VueHighcharts from 'vue-highcharts';
import Highcharts from 'highcharts';
import loadMap from 'highcharts/modules/map';
loadMap(Highcharts);
// maybe we don't want to figure out which fooChart.vue is loaded first,
// just write it and Vue will handle it.
Vue.use(VueHighcharts, { Highcharts });
from vue-highcharts.
I'm closing this issue for it is not about vue-highcharts itself, and my comment above should figure out the reason.
from vue-highcharts.
Related Issues (20)
- How to change Highcharts object configuration locally? HOT 4
- why highstocks use this method does not take effect HOT 1
- how to extend it HOT 2
- 在vue中反复加载会导致图表显示不出来 HOT 1
- 如何在使用vue-router的情况下在其余的component中使用 HOT 5
- Dynamic Chart Example HOT 2
- Exporting CSV HOT 2
- Highcharts this.$refs undefined in mounted HOT 4
- solid gauge tag HOT 1
- Using HTML to render custom image labels on xAxis does not work under this wrapper HOT 6
- Drilldown in Map HOT 1
- vue-highcharts with typescript HOT 1
- vue-highcharts使用 MIT 证书是否合理? HOT 3
- 把垃圾代码库删除吧~~~
- highstock组件不起作用
- highcharts-gantt HOT 2
- 推荐使用 Highcharts 官方维护的 Vue 包 HOT 1
- missingModuleFor: bullet" HOT 1
- this.$refs is undefined inside of hover events HOT 5
- keyboard accessibility? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-highcharts.