【问题标题】:Resize a chart with vue使用 vue 调整图表大小
【发布时间】:2019-10-28 14:44:39
【问题描述】:

我想知道如何为图表指定尺寸。

我使用 vue-chartjs,但没有看到任何选项。

我只是在图表组件中有这段代码

<script>
    import { Line, mixins } from 'vue-chartjs'
    const { reactiveProp } = mixins;

    export default {
        name: 'line_chart',
        extends: Line,
        mixins: [reactiveProp],
        props: ['options'],
        mounted () {
            this.renderChart(this.chartData, this.options);
        }
    }
</script>

以及渲染组件脚本中的这段代码

            fillData () {
                this.data_collection = {
                    labels: [0, 25, 50, 100],
                    datasets: [
                        {
                            label: 'Blue',
                            backgroundColor: '#147aff',
                            fill: false ,
                            borderColor: '#147aff',
                            data: [0, 50, 100, 0],
                        },
                    ]
                };
                this.chart_options = {
                    responsive: true,
                }
            },

【问题讨论】:

    标签: vue.js vue-chartjs


    【解决方案1】:

    通过以下方式:

    <elemento :styles="myStyles"></elemento>
    <script>
    export default: {
    computed: {
        myStyles () {
            return {height: '99px'}
        }
      }
    }
    </script>
    

    示例: https://jsfiddle.net/hamiltongabriel/7s40paog/6/

    【讨论】:

      猜你喜欢
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      • 2020-02-21
      • 2019-03-16
      • 2014-10-05
      • 2012-08-24
      • 1970-01-01
      • 2023-02-09
      相关资源
      最近更新 更多