highcharts.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <view class="">
  3. <highcharts :options="chartOptions" :style="styles"></highcharts>
  4. </view>
  5. <!-- <view class="highcharts-container"></view> -->
  6. </template>
  7. <script>
  8. import {
  9. Chart
  10. } from 'highcharts-vue'
  11. // import Highcharts from 'highcharts/highstock';
  12. // import HighchartsMore from 'highcharts/highcharts-more';
  13. // import HighchartsDrilldown from 'highcharts/modules/drilldown';
  14. // import Highcharts3D from 'highcharts/highcharts-3d';
  15. // HighchartsMore(Highcharts)
  16. // HighchartsDrilldown(Highcharts);
  17. // Highcharts3D(Highcharts);
  18. export default {
  19. props: ['chartOptions', 'styles'],
  20. data() {
  21. return {
  22. }
  23. },
  24. onLoad() {
  25. this.initChart();
  26. },
  27. methods: {
  28. initChart() {
  29. console.log(this.$el);
  30. this.$el.style.width = (this.styles.width || 800) + 'px';
  31. this.$el.style.height = (this.styles.height || 400) + 'px';
  32. this.chart = new Highcharts.Chart(this.$el, this.options);
  33. }
  34. },
  35. components: {
  36. highcharts: Chart
  37. }
  38. }
  39. </script>
  40. <style lang="scss">
  41. .highcharts-container {
  42. width: 800px;
  43. height: 400px;
  44. }
  45. </style>