PlotlyCharts.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!--
  2. * @Author: your name
  3. * @Date: 2024-08-05 17:19:47
  4. * @LastEditTime: 2024-08-05 17:27:32
  5. * @LastEditors: bogon
  6. * @Description: In User Settings Edit
  7. * @FilePath: /performance-test/src/views/performance/components/plotlyCharts.vue
  8. -->
  9. <template>
  10. <div id="plotly-chart"></div>
  11. </template>
  12. <script>
  13. import Plotly from "plotly.js-dist";
  14. export default {
  15. name: "PowerCurvePlot",
  16. mounted() {
  17. const data = {
  18. analysisTypeCode: "power_curve",
  19. graphType: "scatter",
  20. data: [
  21. {
  22. engineName: "#1",
  23. windSpeed: [
  24. 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
  25. ],
  26. power: [
  27. 6.06, 76.54, 184.1, 345.94, 574.4, 879.9, 1274.73, 1664.94, 1942.96,
  28. 2004.78, 2004.78, 2004.78, 2004.78, 2004.78, 2004.78, 2004.78,
  29. 2004.78, 2004.78,
  30. ],
  31. },
  32. {
  33. engineName: "#2",
  34. windSpeed: [
  35. 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10,
  36. 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15, 15.5, 16, 16.5,
  37. ],
  38. power: [
  39. 2, 9.23, 100.12, 155.51, 230.09, 400.15, 500.95, 689.55, 961.09,
  40. 1257.53, 1346.02, 1479.78, 1528.01, 1618.52, 1789.09, 1819.35,
  41. 1920.29, 2053.52, 2053.52, 2053.52, 2053.52, 2053.52, 2053.52,
  42. 2053.52, 2053.52, 2053.52, 2053.52, 2053.52, 2053.52, 2053.52,
  43. 2053.52,
  44. ],
  45. },
  46. ],
  47. };
  48. const plotlyData = data.data.map((engine) => ({
  49. x: engine.windSpeed,
  50. y: engine.power,
  51. mode: "lines",
  52. name: engine.engineName,
  53. }));
  54. const layout = {
  55. title: "Power Curve",
  56. xaxis: { title: "Wind Speed (m/s)" },
  57. yaxis: { title: "Power (kW)" },
  58. };
  59. Plotly.newPlot("plotly-chart", plotlyData, layout);
  60. },
  61. };
  62. </script>
  63. <style scoped>
  64. #plotly-chart {
  65. width: 100%;
  66. height: 100%;
  67. }
  68. </style>