Как отключить опцию загрузки на apexcharts?
Я использую привязки apexcharts vue для построения нескольких гистограмм.
Как сказано в документации, должна быть возможность отключить панель инструментов с помощью set 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 ответа
Решение
toolbar
должно быть под chart
ключ
{
chart: {
toolbar: {
show: false
}
},
colors: randomColor({
luminosity: "light",
hue: "blue",
count: 30
}),
plotOptions: {
bar: {
distributed: true,
horizontal: true
}
},
...
}
Вы можете проверить мое демо здесь
chart: {
toolbar: {
show: true,
tools:{
download:false // <== line to add
}
}
}
Можно отключить только вариант загрузки, но панель инструментов существует
Используйте CSS, чтобы скрыть параметры из раздела загрузки.
/* hide the Download CSV */
<style lang="scss" scoped>
::v-deep .apexcharts-menu-item.exportCSV {
display: none;
}
</style>
редактировать эту строку может помочь вам
{chart: {toolbar: {show: false
}},
colors: randomColor({
luminosity: "light",
hue: "blue",
count: 30
}),
plotOptions: {
bar: {
distributed: true,
horizontal: true
}
},
}