Search code examples
javascriptvue.jsapexcharts

how to disable download option on apexcharts?


I am use apexcharts vue bindings to plot a few bar charts.

As told by docs it should be possible to disable the toolbar by set show:false as seen there.

So i did it on my helper function:

// 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"
      }
    }
  }
});

and i pass it to my vue component this way:

<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>

However the menu is still there:

enter image description here

Any guidance is welcome.


Solution

  • toolbar should be under chart key

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

    You can check my demo here