Skip to content

Commit

Permalink
Extract the default values for width/height onto the config object
Browse files Browse the repository at this point in the history
  • Loading branch information
tuzz committed Jan 17, 2024
1 parent 36f3e3d commit 3b2e028
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pygal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export const config = {
renderChart: (chart) => { throw new Error("The config.renderChart function has not been set for pygal."); }
renderChart: (chart) => { throw new Error("The config.renderChart function has not been set for pygal."); },
availableWidth: 400,
availableHeight: 300,
};

const COLORS = [
Expand Down Expand Up @@ -69,8 +71,8 @@ class Chart {
});
}

const defaultWidth = config.availableWidth || 400;
const defaultHeight = Math.min(defaultWidth, config.availableHeight || 300);
const defaultWidth = config.availableWidth;
const defaultHeight = Math.min(defaultWidth, config.availableHeight);

let chart = {
chart: {
Expand Down

0 comments on commit 3b2e028

Please sign in to comment.