Skip to content

Commit

Permalink
Merge pull request #209 from nzzdev/release-3.5.1
Browse files Browse the repository at this point in the history
Release 3.5.1
  • Loading branch information
manuelroth authored Feb 18, 2021
2 parents 86a87f4 + be20c8d commit e460276
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 18 deletions.
3 changes: 2 additions & 1 deletion chartTypes/area/vega-spec.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"autosize": {
"type": "fit"
"type": "fit",
"contains": "padding"
},
"height": 220,
"data": [
Expand Down
3 changes: 2 additions & 1 deletion chartTypes/line/vega-spec.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"autosize": {
"type": "fit"
"type": "fit",
"contains": "padding"
},
"height": 220,
"scales": [
Expand Down
3 changes: 2 additions & 1 deletion config/vega-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"labelPadding": 8,
"labelLimit": false,
"tickRound": true
}
},
"padding": { "left": 4, "right": 4 }
}
18 changes: 5 additions & 13 deletions helpers/textMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@ const canvas = createCanvas(200, 200);
const context = canvas.getContext("2d");

function getLabelTextWidth(text, toolRuntimeConfig) {
context.font =
toolRuntimeConfig.text.fontWeight +
" " +
toolRuntimeConfig.text.fontSize +
" " +
toolRuntimeConfig.text.font;
// CanvasRenderingContext2D.font expects the font string to be same form as CSS font specifier - https://developer.mozilla.org/en-US/docs/Web/CSS/font
context.font = `${toolRuntimeConfig.text.fontWeight} ${toolRuntimeConfig.text.fontSize}px ${toolRuntimeConfig.text.font}`;
return context.measureText(text).width;
}

function getAxisLabelTextWidth(text, toolRuntimeConfig) {
context.font =
toolRuntimeConfig.axis.labelFontWeight +
" " +
toolRuntimeConfig.axis.labelFontSize +
" " +
toolRuntimeConfig.axis.labelFont;
// CanvasRenderingContext2D.font expects the font string to be same form as CSS font specifier - https://developer.mozilla.org/en-US/docs/Web/CSS/font
context.font = `${toolRuntimeConfig.axis.labelFontWeight} ${toolRuntimeConfig.axis.labelFontSize}px ${toolRuntimeConfig.axis.labelFont}`;
return context.measureText(text).width;
}

module.exports = {
getLabelTextWidth,
getAxisLabelTextWidth
getAxisLabelTextWidth,
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "q-chart",
"version": "3.5.0",
"version": "3.5.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit e460276

Please sign in to comment.