Skip to content

Commit

Permalink
Release 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Dec 2, 2022
1 parent ab0e50e commit 2793743
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 31 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v1.6.1](https://github.com/toorshia/justgage/compare/v1.6.0...v1.6.1)

- fix: make differential work with all intervals [`ab0e50e`](https://github.com/toorshia/justgage/commit/ab0e50eb08cbe9a1099682212c0f0e9013a1eec4)

#### [v1.6.0](https://github.com/toorshia/justgage/compare/v1.5.1...v1.6.0)

> 1 December 2022
- feat: differential gauge [`#380`](https://github.com/toorshia/justgage/pull/380)
- chore: bump got and release-it [`#378`](https://github.com/toorshia/justgage/pull/378)
- chore: bump parse-url from 6.0.0 to 6.0.5 [`#377`](https://github.com/toorshia/justgage/pull/377)
- chore: bump minimist from 1.2.5 to 1.2.6 [`#369`](https://github.com/toorshia/justgage/pull/369)
- chore: bump deps and fix example [`7037f11`](https://github.com/toorshia/justgage/commit/7037f11927a6c3c590e7c36b0034aaa4c3742216)
- Release 1.6.0 [`0b5e9e9`](https://github.com/toorshia/justgage/commit/0b5e9e93fd2ec133b4fa6fbcd2ec750620b8cc0f)
- chore: bump ci [`da56338`](https://github.com/toorshia/justgage/commit/da563389aa25c5d5ceeea346e6df9d47daa7f589)

#### [v1.5.1](https://github.com/toorshia/justgage/compare/v1.5.0...v1.5.1)
Expand Down
38 changes: 25 additions & 13 deletions dist/justgage.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
donut: kvLookup("donut", config, dataset, false),

// differential : bool
// show gauge with 0 at 12 o'clock
// Gauge will fill starting from the center, rather than from the min value
differential: kvLookup("differential", config, dataset, false),

// relativeGaugeSize : bool
Expand Down Expand Up @@ -513,7 +513,18 @@
const gws = obj.config.gaugeWidthScale;
const donut = obj.config.donut;

let alpha, Ro, Ri, Cx, Cy, So, Si, Xo, Yo, Xi, Yi, path;
let alpha; // angle in radians
let Ro; // outer radius, from center to outer edge of gauge
let Ri; // inner radius, from center to inner edge of gauge
let Cx; // center x
let Cy; // center y
let So; // sweep flag for outer arc
let Si; // sweep flag for inner arc
let Xo; // outer x, from center to outer edge of arc
let Yo; // outer y, from center to outer edge of arc
let Xi; // inner x, from center to inner edge of arc
let Yi; // inner y, from center to inner edge of arc
let path; // SVG path string

if (min < 0 && !isDiff) {
max -= min;
Expand Down Expand Up @@ -551,9 +562,6 @@
path,
};
} else if (isDiff) {
// At the moment only works with min = -max
// otherwise would need to work out the zero point
// Which of course is possible, but haven't done it yet
alpha = (1 - (value - min) / (max - min)) * Math.PI;
Ro = w / 2 - w / 10;
Ri = Ro - (w / 6.666666666666667) * gws;
Expand All @@ -566,16 +574,20 @@
Xi = Cx + Ri * Math.cos(alpha);
Yi = Cy - Ri * Math.sin(alpha);

So = value < 0 ? 1 : 0;
Si = value < 0 ? 0 : 1;
const middle = min + (max - min) / 2;

path = "M" + Cx + "," + (Cy - Ri) + " ";
path += "L" + Cx + "," + (Cy - Ro) + " ";
path += "A" + Ro + "," + Ro + " 0 0 " + Si + " " + Xo + "," + Yo + " ";
path += "L" + Xi + "," + Yi + " ";
// sweep flag determines if the arc should begin moving at positive angles
// or negative ones
So = value < middle ? 1 : 0; // sweep flag for outer arc
Si = value < middle ? 0 : 1; // sweep flag for inner arc

path = "M" + Cx + "," + (Cy - Ri) + " "; // start at bottom center
path += "L" + Cx + "," + (Cy - Ro) + " "; // line to top center (Cx, Cy - Ro)
path += "A" + Ro + "," + Ro + " 0 0 " + Si + " " + Xo + "," + Yo + " "; // arc to outer edge
path += "L" + Xi + "," + Yi + " "; // line to inner edge (Xi, Yi)
path +=
"A" + Ri + "," + Ri + " 0 0 " + So + " " + Cx + "," + (Cy - Ri) + " ";
path += "Z ";
"A" + Ri + "," + Ri + " 0 0 " + So + " " + Cx + "," + (Cy - Ri) + " "; // arc to bottom center
path += "Z "; // close path

return {
path,
Expand Down
2 changes: 1 addition & 1 deletion dist/justgage.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/justgage.min.js.map

Large diffs are not rendered by default.

38 changes: 25 additions & 13 deletions docs/justgage.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
donut: kvLookup("donut", config, dataset, false),

// differential : bool
// show gauge with 0 at 12 o'clock
// Gauge will fill starting from the center, rather than from the min value
differential: kvLookup("differential", config, dataset, false),

// relativeGaugeSize : bool
Expand Down Expand Up @@ -513,7 +513,18 @@
const gws = obj.config.gaugeWidthScale;
const donut = obj.config.donut;

let alpha, Ro, Ri, Cx, Cy, So, Si, Xo, Yo, Xi, Yi, path;
let alpha; // angle in radians
let Ro; // outer radius, from center to outer edge of gauge
let Ri; // inner radius, from center to inner edge of gauge
let Cx; // center x
let Cy; // center y
let So; // sweep flag for outer arc
let Si; // sweep flag for inner arc
let Xo; // outer x, from center to outer edge of arc
let Yo; // outer y, from center to outer edge of arc
let Xi; // inner x, from center to inner edge of arc
let Yi; // inner y, from center to inner edge of arc
let path; // SVG path string

if (min < 0 && !isDiff) {
max -= min;
Expand Down Expand Up @@ -551,9 +562,6 @@
path,
};
} else if (isDiff) {
// At the moment only works with min = -max
// otherwise would need to work out the zero point
// Which of course is possible, but haven't done it yet
alpha = (1 - (value - min) / (max - min)) * Math.PI;
Ro = w / 2 - w / 10;
Ri = Ro - (w / 6.666666666666667) * gws;
Expand All @@ -566,16 +574,20 @@
Xi = Cx + Ri * Math.cos(alpha);
Yi = Cy - Ri * Math.sin(alpha);

So = value < 0 ? 1 : 0;
Si = value < 0 ? 0 : 1;
const middle = min + (max - min) / 2;

path = "M" + Cx + "," + (Cy - Ri) + " ";
path += "L" + Cx + "," + (Cy - Ro) + " ";
path += "A" + Ro + "," + Ro + " 0 0 " + Si + " " + Xo + "," + Yo + " ";
path += "L" + Xi + "," + Yi + " ";
// sweep flag determines if the arc should begin moving at positive angles
// or negative ones
So = value < middle ? 1 : 0; // sweep flag for outer arc
Si = value < middle ? 0 : 1; // sweep flag for inner arc

path = "M" + Cx + "," + (Cy - Ri) + " "; // start at bottom center
path += "L" + Cx + "," + (Cy - Ro) + " "; // line to top center (Cx, Cy - Ro)
path += "A" + Ro + "," + Ro + " 0 0 " + Si + " " + Xo + "," + Yo + " "; // arc to outer edge
path += "L" + Xi + "," + Yi + " "; // line to inner edge (Xi, Yi)
path +=
"A" + Ri + "," + Ri + " 0 0 " + So + " " + Cx + "," + (Cy - Ri) + " ";
path += "Z ";
"A" + Ri + "," + Ri + " 0 0 " + So + " " + Cx + "," + (Cy - Ri) + " "; // arc to bottom center
path += "Z "; // close path

return {
path,
Expand Down
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "justgage",
"version": "1.6.0",
"version": "1.6.1",
"description": "JustGage is a handy JavaScript plugin for generating and animating nice & clean gauges. It is based on Raphaël library for vector drawing, so it’s completely resolution independent and self-adjusting.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 2793743

Please sign in to comment.