PlotSpectra.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div>
  3. <ReactiveChart :chart="$store.state.plotRuntime.spectrumPlots"/>
  4. </div>
  5. </template>
  6. <script>
  7. import ReactiveChart from 'components/ReactiveChart.vue'
  8. import { useStore } from 'src/store'
  9. import {
  10. defineComponent,
  11. computed,
  12. watch
  13. } from 'vue'
  14. export default defineComponent({
  15. name: 'PlotSpectra',
  16. components: {
  17. ReactiveChart,
  18. },
  19. setup () {
  20. const $store = useStore()
  21. const isPlotQsca = computed( ()=>$store.state.plotRuntime.isPlotQsca)
  22. watch(isPlotQsca, ()=>$store.commit('plotRuntime/updateSpectrumPlots'))
  23. const isPlotQabs = computed( ()=>$store.state.plotRuntime.isPlotQabs)
  24. watch(isPlotQabs, ()=>$store.commit('plotRuntime/updateSpectrumPlots'))
  25. const isPlotQext = computed( ()=>$store.state.plotRuntime.isPlotQext)
  26. watch(isPlotQext, ()=>$store.commit('plotRuntime/updateSpectrumPlots'))
  27. const isPlotQscaTotal = computed( ()=>$store.state.plotRuntime.isPlotQscaTotal)
  28. watch(isPlotQscaTotal, ()=>$store.commit('plotRuntime/updateSpectrumPlots'))
  29. const isPlotQabsTotal = computed( ()=>$store.state.plotRuntime.isPlotQabsTotal)
  30. watch(isPlotQabsTotal, ()=>$store.commit('plotRuntime/updateSpectrumPlots'))
  31. const isPlotQextTotal = computed( ()=>$store.state.plotRuntime.isPlotQextTotal)
  32. watch(isPlotQextTotal, ()=>$store.commit('plotRuntime/updateSpectrumPlots'))
  33. const isPlotModeE = computed( ()=>$store.state.plotRuntime.isPlotModeE)
  34. watch(isPlotModeE, ()=>$store.commit('plotRuntime/updateSpectrumPlots'), { deep: true })
  35. const isPlotModeH = computed( ()=>$store.state.plotRuntime.isPlotModeH)
  36. watch(isPlotModeH, ()=>$store.commit('plotRuntime/updateSpectrumPlots'), { deep: true })
  37. const sourceUnits = computed( ()=>$store.state.guiRuntime.sourceUnits)
  38. function setPlotTitle() {
  39. let title=''
  40. if (sourceUnits.value.endsWith('Hz')) {
  41. title = 'Frequency [' + sourceUnits.value + ']'
  42. } else if (sourceUnits.value.endsWith('eV')) {
  43. title = 'Energy [' + sourceUnits.value + ']'
  44. } else if (sourceUnits.value.endsWith('s')) {
  45. title = 'Period [' + sourceUnits.value + ']'
  46. } else {
  47. title = 'Wavelength [' + sourceUnits.value + ']'
  48. }
  49. $store.commit('plotRuntime/updateXAxisTitle', title)
  50. }
  51. function updateSpectraPlotsUnits(){
  52. setPlotTitle()
  53. $store.commit('plotRuntime/setWLsInUnits', sourceUnits.value)
  54. $store.commit('plotRuntime/updateSpectrumPlots')
  55. }
  56. updateSpectraPlotsUnits()
  57. watch(sourceUnits, ()=> updateSpectraPlotsUnits())
  58. return {}
  59. }
  60. })
  61. </script>