首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用电子图表的vue.js项目不显示图例

使用电子图表的vue.js项目不显示图例
EN

Stack Overflow用户
提问于 2020-08-06 05:46:50
回答 1查看 616关注 0票数 3

我正在做一个vue.js项目,我正在使用v-charts插件。我无法为我生成的任何折线图显示图例。我能够生成具有x轴和y轴标签以及图表标题的适当图表。我已经尝试改变了一吨的不同选项的图例。我还单独导入了电子图表的图例组件。

我已经尝试了多种不同的图例格式选项。我已经开始了一个新的项目,没有任何样式,但仍然没有运气。我确信我的options对象中有一些简单的东西,但是我不能理解它。

有没有其他人遇到过这种情况,并找到了解决方案?

多年来,我一直使用这个网站作为资源,从来没有问过任何问题。我搞不懂这件事。

图表选项栏是在函数中设置的,数据在图表上适当地表示。我只需要能够显示图例。

下面是代码片段和图表截图:

代码语言:javascript
复制
<template>
    <div class="standard_div">
      <!-- Begin chart component of graph -->
        <v-chart v-if="showChart" :options="chartOptionsBar"/>
        <!-- End chart component-->
    </div>
</template>
代码语言:javascript
复制
<script>
// Import a different instance ECharts into the .vue file.
import ECharts from 'vue-echarts';
import 'echarts/lib/component/legend'
import 'echarts/lib/component/title'
</script>
代码语言:javascript
复制
chartOptionsBar = {
          xAxis: {
            // The data for the series
            data: this.xAxisSeries,
            // Parameters for the x axis
            name: this.x_axis,
            nameLocation: 'middle',
            nameTextStyle: {
              padding: [20, 20, 20, 20],
              fontWeight: 'bold',
            }
          },
          yAxis: {
            // Parameters for the x axis
            name: this.y_axis,
            nameLocation: 'middle',
            nameTextStyle:{
              padding: [25, 25, 25, 25],
              fontWeight: 'bold',
            }
          },
          series: [
            {type: 'line', data: this.yAxisSeries},
          ],
          legend:{
            top: 'auto',
            left: 'auto',
            right: 'auto',
            bottom: 'auto',
            width: '50%',
            orient: 'horizontal',
            lineHeight: '56',
            padding: 25,
            type: 'plain',
            zlevel: 20,
            data: ["item0"]
          },
          title:{
            show: true,
            text: this.graphTitle,
            x: 'center',
            textStyle: {
              fontSize: 20,
            }
          }, 
        };

The link includes an image of the graph that was produced from the options bar above.

EN

回答 1

Stack Overflow用户

发布于 2020-12-05 14:48:12

我在导入图例时遇到了同样的问题

代码语言:javascript
复制
import 'echarts/lib/component/legend'

在我的组件中为我工作!试着玩定位道具

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63273979

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档