如何在ApexCharts上禁用下载选项?

25

我正在使用ApexCharts Vue绑定来绘制一些条形图。

根据文档的说法,应该可以通过将show:false设置为如此处所示来禁用工具栏。

所以我在我的帮助函数中进行了设置:

// do-char-options.js
const randomColor = require("randomcolor");
module.exports = labels => ({
  toolbar: { show:false },// docs says it should do the trick
  colors: randomColor({
    luminosity: "light",
    hue: "blue",
    count: 30
  }),
  plotOptions: {
    bar: { distributed: true, horizontal: true }
  },
  tooltip: {
    theme: "dark"
  },
  xaxis: {
    categories: labels,
    color: "white",
    labels: {
      style: {
        colors: ["white"]
      }
    }
  },
  yaxis: {
    labels: {
      style: {
        color: "white"
      }
    }
  }
});

然后我以这种方式将其传递给我的Vue组件:

<template>
    <v-layout row justify-center wrap>
        <v-flex xs12>
            <apexchart type="bar" height="500" :options="chartOptions" :series="series"/>
        </v-flex>
    </v-layout>
</template>

<script>
const doOptions = require("./do-chart-options");
const labels = [
    "Javascript",
    "Java",
    "SQL",
    "HTML",
    "CSS",
    "C",
    "C++",
    "PHP",
    "Python",
    "GO",
    "Ruby"
];
module.exports = {
    name: "chart-languages",
    data: _ => ({
        series: [{ data: [160, 110, 90, 85, 80, 80, 60, 30, 15, 14, 9] }],
        chartOptions: doOptions(labels)
    })
};
</script>

然而菜单仍然在那里:

输入图片描述

欢迎任何指导。

4个回答

62

工具栏应该在图表键下面

{
  chart: {
    toolbar: {
      show: false
    }
  },
  colors: randomColor({
    luminosity: "light",
    hue: "blue",
    count: 30
  }),
  plotOptions: {
    bar: {
      distributed: true,
      horizontal: true
    }
  },
  ...
}
你可以在这里查看我的演示。

8
  chart: {
      toolbar: {
        show: true,
        tools:{
          download:false // <== line to add
        }
      }
    }

只能禁用下载选项,但工具条仍存在


2

编辑这行可能会对你有所帮助

{chart: {toolbar: {show: false
}},
  colors: randomColor({
    luminosity: "light",
    hue: "blue",
    count: 30
  }),
  plotOptions: {
    bar: {
      distributed: true,
      horizontal: true
    }
  },
}

2
请添加详细信息,以便用户(包括 OP)理解为什么这个代码可以替换现有代码。 - Tushar Shahi

2
使用CSS隐藏下载部分的选项。
/* hide the Download CSV */

<style lang="scss" scoped>
  ::v-deep .apexcharts-menu-item.exportCSV {
    display: none;
  }
</style>

太棒了,这正是我想要做的。在我的普通CSS文件中,我只使用了这一部分,它对我很有效:.apexcharts-menu-item.exportCSV { display: none; } - amota

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接