From fa2aeb93171943bb61604eb3dfa5057bdbc9bc8c Mon Sep 17 00:00:00 2001 From: Tim Niemueller Date: Fri, 6 Apr 2018 00:30:35 +0200 Subject: [PATCH] c3: add missing fields in LegendOptions There is configuration for tiles introduced with https://github.com/c3js/c3/issues/1033 and defined in spec/legend-spec.js which is missing from @types/c3. --- types/c3/c3-tests.ts | 20 ++++++++++++++++++++ types/c3/index.d.ts | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/types/c3/c3-tests.ts b/types/c3/c3-tests.ts index 7ac2f0ccd8..f2e630cd09 100644 --- a/types/c3/c3-tests.ts +++ b/types/c3/c3-tests.ts @@ -1798,6 +1798,26 @@ function legend_custom() { }); } +function legend_tiles() { + const chart = c3.generate({ + data: { + columns: [ + ["sample", 30, 200, 100, 400, 150, 250] + ] + }, + legend: { + // amount of padding to put between each legend element + padding: 5, + // define custom height and width for the legend item tile + item: { + tile: { + width: 15, + height: 2 + } + } + }}); +} + ///////////////////// // Tooltip Tests ///////////////////// diff --git a/types/c3/index.d.ts b/types/c3/index.d.ts index a1dfaaf8f0..6c466458e3 100644 --- a/types/c3/index.d.ts +++ b/types/c3/index.d.ts @@ -1,9 +1,10 @@ -// Type definitions for C3js 0.5 +// Type definitions for C3js 0.6 // Project: http://c3js.org/ // Definitions by: Marc Climent // Gerin Jacob // Bernd Hacker // Dzmitry Shyndzin +// Tim Niemueller // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -700,6 +701,10 @@ export interface LegendOptions { y?: number; step?: number; }; + /** + * Padding between legend elements. + */ + padding?: number; item?: { /** @@ -714,6 +719,19 @@ export interface LegendOptions { * Set mouseout event handler to the legend item. */ onmouseout?(id: any): void; + /** + * Tile settings for legend color display. + */ + tile?: { + /** + * Tile width. + */ + width?: number; + /** + * Tile height + */ + height?: number; + } }; }