Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasDoesThings committed Apr 17, 2024
2 parents 60f1b8f + 2a392e8 commit a2f4cae
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sankeydiagram.net",
"version": "1.2.2",
"version": "1.3.0",
"private": true,
"browserslist": [
"defaults"
Expand All @@ -15,7 +15,8 @@
},
"license": "SEE LICENSE IN LICENSE.md",
"scripts": {
"start": "parcel ./src/*.html",
"start": "npm run dev",
"dev": "parcel ./src/*.html",
"build": "parcel build ./src/index.html ./src/404.html ./src/privacypolicy.html",
"lint": "eslint src/**/*.js",
"lint:fix": "eslint --fix src/**/*.js"
Expand Down
8 changes: 6 additions & 2 deletions src/css/index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@import "core";

:root {
--node-font-size: 20px;
}

.watermark {
font-family: 'Open Sans', 'Arial', sans-serif;
font-size: 12pt;
Expand All @@ -13,7 +17,7 @@
.nodes text {
font-weight: 600;
font-family: 'Open Sans', 'Arial', sans-serif;
font-size: 15pt;
font-size: var(--node-font-size);
}

.nodes rect {
Expand Down Expand Up @@ -207,4 +211,4 @@ li {
transform: translate3d(-50%,calc(-100% - 16px),0);
}
}
}
}
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ <h1 class="has-text-weight-bold">SankeyDiagram.net</h1>
<br>
<label for="sankey-settings-canvas-height">Canvas Height </label><input type="number" class="settings-input" id="sankey-settings-canvas-height" value="1080">
<br>
<label for="sankey-settings-font-size">Font Size (px) </label><input type="number" class="settings-input" id="sankey-settings-font-size" value="20" placeholder="20">
<br>
<div class="divider">Debug</div>
<span class="button is-dark p-1 mb-1 has-shadow anonymize-data-button is-clickable level-item"><span class="material-icons mr-1">shuffle</span> Anonymize Data</span>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/js/image-exporter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import * as saveSvg from 'save-svg-as-png';
import * as d3 from 'd3';

const modifyStyle = (value) => {
return value.replace(
'var(--node-font-size)',
window.getComputedStyle(document.documentElement).getPropertyValue('--node-font-size'),
);
};

document.querySelectorAll('.download-as-png-button').forEach((element) => {
element.addEventListener('click', function() {
saveSvg.saveSvgAsPng(d3.select('svg').node(), 'sankeydiagram-net-export', {
backgroundColor: 'white',
excludeUnusedCss: true,
modifyStyle: modifyStyle,
});
});
});
Expand All @@ -15,6 +23,7 @@ document.querySelectorAll('.download-as-svg-button').forEach((element) => {
saveSvg.saveSvg(d3.select('svg').node(), 'sankeydiagram-net-export', {
backgroundColor: 'white',
excludeUnusedCss: true,
modifyStyle: modifyStyle,
});
});
});
10 changes: 9 additions & 1 deletion src/js/sankey-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const sankeySuffixSetting = document.getElementById('sankey-settings-suffix');
const sankeyHideNumbersSetting = document.getElementById('sankey-settings-hidenumbers');
const sankeyCanvasWidthSetting = document.getElementById('sankey-settings-canvas-width');
const sankeyCanvasHeightSetting = document.getElementById('sankey-settings-canvas-height');
const sankeyFontSizeSetting = document.getElementById('sankey-settings-font-size');

import {lineRegex, sankeyInput} from './constants';
import './gui';
Expand Down Expand Up @@ -57,6 +58,13 @@ sankeyCanvasHeightSetting.addEventListener('change', function() {
processInput();
});

sankeyFontSizeSetting.addEventListener('input', () => {
document.documentElement.style.setProperty(
'--node-font-size',
`${sankeyFontSizeSetting.value.trim().length > 0 ? sankeyFontSizeSetting.value.trim() : '20'}px`,
);
});

/**
* recursively generates the value of an auto-sum connection
* @param {string[]} lines
Expand Down Expand Up @@ -85,7 +93,7 @@ function calculateValue(lines, originalTarget) {
} else {
totalValue += parseFloat(value);
}
} else if(target === originalTarget) {
} else if (target === originalTarget) {
if (value === '?') {
// todo, we should probably handle this as well.
} else {
Expand Down
1 change: 1 addition & 0 deletions src/js/settings-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function deserializeSettings() {
}

document.getElementById(key).value = val;
element.dispatchEvent(new Event('change'));
}
});
}

0 comments on commit a2f4cae

Please sign in to comment.