-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adopt the new classes for plot's big numbers (#554)
* adopt the new classes for plot's big numbers * fix padding and color, the hard way * Update examples/plot/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * Update examples/plot/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * quote attributes * link not muted, fix slag * Update examples/plot/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * remove redundant client-side html generation * a bit of clean-up in the google-analytics example * add a gap class * fix links * remove .gap * fix indentation, close div * trend function * Update examples/google-analytics/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * Update examples/google-analytics/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * Update examples/google-analytics/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * Update examples/google-analytics/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * Update examples/plot/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * Update examples/plot/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * Update examples/plot/docs/index.md Co-authored-by: Mike Bostock <[email protected]> * - trend as a (local) component - adopt toLocaleString * small --------- Co-authored-by: Mike Bostock <[email protected]>
- Loading branch information
Showing
9 changed files
with
135 additions
and
117 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as d3 from "npm:d3"; | ||
import {html} from "npm:htl"; | ||
|
||
export function trend( | ||
value /*: number */, | ||
{ | ||
format = "+d", | ||
positive = "green", | ||
negative = "red", | ||
base = "muted", | ||
positiveSuffix = " ↗︎", | ||
negativeSuffix = " ↘︎", | ||
baseSuffix = "" | ||
} = {} /* | ||
as { | ||
format: string | ((x: number) => string); | ||
positive: string; | ||
negative: string; | ||
base: string; | ||
positiveSuffix: string; | ||
negativeSuffix: string; | ||
baseSuffix: string; | ||
} | ||
*/ | ||
) /*: Node */ { | ||
if (typeof format === "string") format = d3.format(format); | ||
if (typeof format !== "function") throw new Error(`unsupported format ${format}`); | ||
return html`<span class="small ${value > 0 ? positive : value < 0 ? negative : base}">${format(value)}${ | ||
value > 0 ? positiveSuffix : value < 0 ? negativeSuffix : baseSuffix | ||
}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as d3 from "npm:d3"; | ||
import {html} from "npm:htl"; | ||
|
||
export function trend( | ||
value /*: number */, | ||
{ | ||
format = "+d", | ||
positive = "green", | ||
negative = "red", | ||
base = "muted", | ||
positiveSuffix = " ↗︎", | ||
negativeSuffix = " ↘︎", | ||
baseSuffix = "" | ||
} = {} /* | ||
as { | ||
format: string | ((x: number) => string); | ||
positive: string; | ||
negative: string; | ||
base: string; | ||
positiveSuffix: string; | ||
negativeSuffix: string; | ||
baseSuffix: string; | ||
} | ||
*/ | ||
) /*: Node */ { | ||
if (typeof format === "string") format = d3.format(format); | ||
if (typeof format !== "function") throw new Error(`unsupported format ${format}`); | ||
return html`<span class="small ${value > 0 ? positive : value < 0 ? negative : base}">${format(value)}${ | ||
value > 0 ? positiveSuffix : value < 0 ? negativeSuffix : baseSuffix | ||
}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters