highcharts.vue 845 B

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