highcharts.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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'
  12. import HighchartsNoData from 'highcharts/modules/no-data-to-display'
  13. HighchartsNoData(Highcharts)
  14. // import Highcharts from 'highcharts/highstock';
  15. // import HighchartsMore from 'highcharts/highcharts-more';
  16. // import HighchartsDrilldown from 'highcharts/modules/drilldown';
  17. // import Highcharts3D from 'highcharts/highcharts-3d';
  18. // HighchartsMore(Highcharts)
  19. // HighchartsDrilldown(Highcharts);
  20. // Highcharts3D(Highcharts);
  21. export default {
  22. props: ['chartOptions', 'styles'],
  23. data() {
  24. return {
  25. }
  26. },
  27. onLoad() {
  28. this.initChart();
  29. },
  30. methods: {
  31. initChart() {
  32. console.log(this.$el);
  33. this.$el.style.width = (this.styles.width || 800) + 'px';
  34. this.$el.style.height = (this.styles.height || 400) + 'px';
  35. this.chart = new Highcharts.Chart(this.$el, this.options);
  36. }
  37. },
  38. components: {
  39. highcharts: Chart
  40. }
  41. }
  42. </script>
  43. <style lang="scss">
  44. .highcharts-container {
  45. width: 800px;
  46. height: 400px;
  47. }
  48. </style>