vCurve.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view :prop="config" :change:prop="curve.updateEcharts" :id="chartID"></view>
  3. </template>
  4. <script>
  5. export default {
  6. props: ["list"],
  7. data() {
  8. return {
  9. chartID:
  10. "chart" +
  11. parseInt(Math.random() * 100000) +
  12. "" +
  13. parseInt(Math.random() * 100000),
  14. };
  15. },
  16. computed: {
  17. config() {
  18. return {
  19. chartID: this.chartID,
  20. list: this.list,
  21. };
  22. },
  23. },
  24. onLoad() {},
  25. methods: {},
  26. };
  27. </script>
  28. <script module="curve" lang="renderjs">
  29. import highstock from "highcharts/highstock";
  30. export default {
  31. data(){
  32. return {
  33. currentList:[],
  34. currentChartID:''
  35. }
  36. },
  37. mounted() {
  38. this.initPage();
  39. this.intiChart();
  40. },
  41. methods: {
  42. initPage() {
  43. this.currentList = this.config.list.map(item=>item*1)
  44. this.currentChartID= this.config.chartID
  45. },
  46. intiChart() {
  47. return highstock.stockChart(document.getElementById(this.currentChartID), {
  48. chart: {
  49. panning: false,
  50. spacingRight: 0,
  51. spacingLeft: 0,
  52. backgroundColor: "transparent",
  53. },
  54. credits: {
  55. enabled: false,
  56. },
  57. rangeSelector: {
  58. enabled: false,
  59. },
  60. navigator: {
  61. enabled: false,
  62. },
  63. scrollbar: {
  64. enabled: false,
  65. },
  66. legend: {
  67. enabled: false,
  68. },
  69. tooltip: {
  70. enabled: false,
  71. },
  72. xAxis: {
  73. visible: false,
  74. },
  75. yAxis: {
  76. visible: false,
  77. },
  78. plotOptions: {
  79. spline: {
  80. enableMouseTracking: false,
  81. },
  82. },
  83. series: [{
  84. color:{
  85. linearGradient:{
  86. x1:'0%',
  87. y1:'0%',
  88. x2:'100%',
  89. y2:'100%'
  90. },
  91. stops:[
  92. [0, '#B4EC51'],
  93. [1, '#429321'],
  94. ]
  95. },
  96. data: this.currentList,
  97. lineWidth: 1.5,
  98. type: "spline",
  99. }, ],
  100. });
  101. },
  102. updateEcharts() {
  103. },
  104. }
  105. }
  106. </script>
  107. <style>
  108. .content {
  109. display: flex;
  110. flex-direction: column;
  111. align-items: center;
  112. justify-content: center;
  113. }
  114. .echarts {
  115. margin-top: 100px;
  116. width: 100%;
  117. height: 300px;
  118. }
  119. </style>