Skip to main content
Module

x/billboardjs/Chart/api/legend.ts

📊 Re-usable, easy interface JavaScript chart library based on D3.js
Go to Latest
File
/** * Copyright (c) 2017 ~ present NAVER Corp. * billboard.js project is licensed under the MIT license *//** * Define legend * @ignore */const legend = { /** * Show legend for each target. * @function legend․show * @instance * @memberof Chart * @param {string|Array} targetIds * - If targetIds is given, specified target's legend will be shown. * - If only one target is the candidate, String can be passed. * - If no argument is given, all of target's legend will be shown. * @example * // Show legend for data1. * chart.legend.show("data1"); * * // Show legend for data1 and data2. * chart.legend.show(["data1", "data2"]); * * // Show all legend. * chart.legend.show(); */ show: function(targetIds?: string | string[]): void { const $$ = this.internal;
$$.showLegend($$.mapToTargetIds(targetIds)); $$.updateAndRedraw({withLegend: true}); },
/** * Hide legend for each target. * @function legend․hide * @instance * @memberof Chart * @param {string|Array} targetIds * - If targetIds is given, specified target's legend will be hidden. * - If only one target is the candidate, String can be passed. * - If no argument is given, all of target's legend will be hidden. * @example * // Hide legend for data1. * chart.legend.hide("data1"); * * // Hide legend for data1 and data2. * chart.legend.hide(["data1", "data2"]); * * // Hide all legend. * chart.legend.hide(); */ hide: function(targetIds?: string | string[]): void { const $$ = this.internal;
$$.hideLegend($$.mapToTargetIds(targetIds)); $$.updateAndRedraw({withLegend: true}); }};
export default {legend};