Skip to content

Commit 8174a0c

Browse files
authored
Merge pull request #200 from mhkeller/verbose-mode
Add option to suppress layout warnings
2 parents aa0d80e + a2d9554 commit 8174a0c

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
===
33

4+
# 8.2.0
5+
6+
> 2024-05-17
7+
8+
Adds an option to suppress layout warnings. By default, Layer Cake warns you when you create a div that is too small. But sometimes you want to create a chart inside a hidden element or something and make the chart expand. In these cases, the warnings are annoying.
9+
10+
* [PR#200](https://github.com/mhkeller/layercake/pull/200)
11+
412
# 8.1.4
513

614
> 2024-05-06

src/lib/LayerCake.svelte

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@
131131
132132
/** @type {Boolean} debug Enable debug printing to the console. Useful to inspect your scales and dimensions. */
133133
export let debug = false;
134+
/** @type {Boolean} [verbose=true] Show warnings in the console. */
135+
export let verbose = true;
134136
135137
/**
136138
* Make this reactive
@@ -289,15 +291,17 @@
289291
b.left = $padding.left;
290292
b.width = b.right - b.left;
291293
b.height = b.bottom - b.top;
292-
if (b.width <= 0 && isMounted === true) {
293-
console.warn(
294-
'[LayerCake] Target div has zero or negative width. Did you forget to set an explicit width in CSS on the container?'
295-
);
296-
}
297-
if (b.height <= 0 && isMounted === true) {
298-
console.warn(
299-
'[LayerCake] Target div has zero or negative height. Did you forget to set an explicit height in CSS on the container?'
300-
);
294+
if (verbose === true) {
295+
if (b.width <= 0 && isMounted === true) {
296+
console.warn(
297+
'[LayerCake] Target div has zero or negative width. Did you forget to set an explicit width in CSS on the container?'
298+
);
299+
}
300+
if (b.height <= 0 && isMounted === true) {
301+
console.warn(
302+
'[LayerCake] Target div has zero or negative height. Did you forget to set an explicit height in CSS on the container?'
303+
);
304+
}
301305
}
302306
return b;
303307
}

src/lib/utils/padScale.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const unpaddable = ['scaleThreshold', 'scaleQuantile', 'scaleQuantize', 'scaleSe
1818

1919
export default function padScale (scale, padding) {
2020
if (typeof scale.range !== 'function') {
21-
console.log(scale);
2221
throw new Error('Scale method `range` must be a function');
2322
}
2423
if (typeof scale.domain !== 'function') {

0 commit comments

Comments
 (0)