Skip to content

Commit

Permalink
Better color legend. Downgrade to TS 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
derpylz committed Oct 12, 2020
1 parent 4b7ad4d commit e47dbd7
Show file tree
Hide file tree
Showing 21 changed files with 85,375 additions and 73 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"preLaunchTask": "npm: debug",
"type": "pwa-msedge",
"request": "launch",
"name": "Open index.html",
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "debug",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"label": "npm: debug",
"detail": "webpack --mode development"
}
]
}
33 changes: 21 additions & 12 deletions babyplots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,20 +980,23 @@ export class Plots {
let innerGrid = new Grid();
innerGrid.addColumnDefinition(0.2);
innerGrid.addColumnDefinition(0.8);
innerGrid.addRowDefinition(1);
grid.addControl(innerGrid, 1, 1);

let nBreaks = 265;
let labelSpace = 0.05;
let nBreaks = 115;
let labelSpace = 0.15;
if (this.canvas.height < 70) {
nBreaks = 10;
labelSpace = 0.45;
innerGrid.addRowDefinition(1);
} else if (this.canvas.height < 130) {
nBreaks = 50;
labelSpace = 0.3;
} else if (this.canvas.height < 350) {
nBreaks = 100;
labelSpace = 0.15
innerGrid.addRowDefinition(1);
} else {
let padding = (this.canvas.height - 115) / 2
innerGrid.addRowDefinition(padding, true);
innerGrid.addRowDefinition(115, true);
innerGrid.addRowDefinition(padding, true);
}
// color bar
let colors: string[];
Expand All @@ -1016,25 +1019,31 @@ export class Plots {
legendColor.height = 1;
scaleGrid.addControl(legendColor, i, 0);
}
innerGrid.addControl(scaleGrid, 0, 0);


// label text
let labelGrid = new Grid();
labelGrid.addColumnDefinition(1);
labelGrid.addRowDefinition(labelSpace);
labelGrid.addRowDefinition(1 - labelSpace * 2);
labelGrid.addRowDefinition(labelSpace);
innerGrid.addControl(labelGrid, 0, 1);

if (this.canvas.height < 130) {
innerGrid.addControl(scaleGrid, 0, 0);
innerGrid.addControl(labelGrid, 0, 1);
} else {
innerGrid.addControl(scaleGrid, 1, 0);
innerGrid.addControl(labelGrid, 1, 1);
}

let minText = new TextBlock();
minText.text = parseFloat(legendData.breaks[0]).toFixed(4).toString();
minText.text = parseFloat(legendData.breaks[0]).toFixed(2);
minText.color = legendData.fontColor;
minText.fontSize = legendData.fontSize + "px";
minText.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
labelGrid.addControl(minText, 2, 0);

let maxText = new TextBlock();
maxText.text = parseFloat(legendData.breaks[1]).toFixed(4).toString();
maxText.text = parseFloat(legendData.breaks[1]).toFixed(2);
maxText.color = legendData.fontColor;
maxText.fontSize = legendData.fontSize + "px";
maxText.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
Expand Down
22 changes: 14 additions & 8 deletions build/Axes.js

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

Loading

0 comments on commit e47dbd7

Please sign in to comment.