简体   繁体   English

使用vue-chartjs连续显示两个数字

[英]Two figures in one row using vue-chartjs

I use vue-chartjs to display some figures in my vue application in which I use semantic-ui for the layout. 我使用vue-chartjs在我的vue应用程序中显示一些图形,在其中我使用语义UI进行布局。

I would like to have two figures next to each other on the screen but somehow I do not manage this. 我想在屏幕上将两个数字彼此相邻,但是以某种方式我无法管理。

I tried using template as in my other components but this does not seem to work with vue-chartjs. 我尝试在其他组件中使用模板,但这似乎不适用于vue-chartjs。 I also tried to use two fields functionality from semantic ui without success. 我还尝试使用语义ui中的两个字段功能,但未成功。

Here is some code snippets: 以下是一些代码片段:

<template>
  <div class="DisplayResults">
    <div class="ui relaxed divided padded full grid">
      <div class="column">
        <div class="ui tiny form">
          <div class="two fields">
      <div class="field eight wide">
        <Chart class="Chart" v-model="resultsData" v-if="hasResults" />
      </div>
      <div class="field eight wide">
        <ChartN class="Chart" v-model="resultsData" v-if="hasResults"/>
      </div>
    </div>
  </div>
</template>
import Chart from '@/components/Chart.vue'
import ChartN from '@/components/ChartN.vue'
import CaseDataState from '@/components/CaseDataState.vue'

export default {
  name: 'DisplayResults',
  CaseDataState,
  components: {
    Chart,
    ChartN
  },
  data: function () {
    return { computing: false }
  },
  computed: {
    hasResults () {
      return (this.resultsData.time) && !(this.computing)
    },
    resultsData () {
      return CaseDataState.getters.resultsData
    }
  }
}
</script>

Can anybody help how I can achieve this? 有人可以帮我实现这一目标吗?

I solved my issue. 我解决了我的问题。 Apparently the problem was with my usage of semantic ui. 显然问题出在我对语义ui的使用上。 Here is what worked for me in the end: 这最终对我有用:

<template>
  <div class="DisplayResults">
    <h1 class="ui header" v-if="hasResults">Results</h1>
    <div class="ui center aligned grid" v-if="hasResults">
      <div class="six wide column">
        <div class="ui fluid spaced image">
          <Chart v-model="resultsData"/>
        </div>
      </div>
      <div class="six wide column">
        <div class="ui fluid spaced image">
          <ChartN v-model="resultsData"/>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// @ is an alias to /src
import Chart from '@/components/Chart.vue'
import ChartN from '@/components/ChartN.vue'
import CaseDataState from '@/components/CaseDataState.vue'

export default {
  name: 'DisplayResults',
  components: {
    Chart,
    ChartN,  
    CaseDataState
  },
  computed: {
    hasResults () {
      return (this.resultsData.time) && !(this.running)
    },
    resultsData () {
      return CaseDataState.getters.resultsData
    }
  }
}
</script>

Thanks, 谢谢,

Clemens 克莱门斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM