Closed hughess closed 11 months ago
Latest commit: d30f7a3a345fe481b651765d50e124f2aa5bbedd
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
evidence-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 23, 2023 5:41pm |
Name | Link |
---|---|
Latest commit | d30f7a3a345fe481b651765d50e124f2aa5bbedd |
Latest deploy log | https://app.netlify.com/sites/evidence-development-workspace/deploys/6495d90fa96a2c000888a653 |
Deploy Preview | https://deploy-preview-964--evidence-development-workspace.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
This is great. Only prop I thought might be missing is sizeFmt for the bubble chart tooltips?
Do we want to customize the fmt function that we also expose to users to use in js so that it uses the same underlying function that accepts both string and format code.
We should add this to the docs
Ah yes, missed that one - thanks!
I didn't realize the format function was already in preprocess. I was initially going to do another PR after this one to expose that function, but that's perfect - I'll swap that out for the new function.
Will update the Number Formatting page in the docs as well.
There's one other remaining issue here, which is date formatting - there's a few pieces to this:
I'm going to take a look into these, but depending on their complexity, we might be better off releasing component formatting only for numbers as a starting place.
There is actually a workaround for custom date formatting as well - using custom format tags works, it's just the Excel codes directly in the function that don't work.
Reading it again, I think we should try to simplify the number formatting docs.
I feel like the first line should say something like:
The easiest way to adjust formats is using component props. You can pass in excel style format codes, or one of a list of predefined format tags.
(Then an example using an excel format tag in a Value component)
And then sections with detail on:
Got it working!
Oh thats so sick with HMR
Update on the date issue:
getFormatObjectFromString
function to accept an optional valueType
parameter. Where possible, I've passed this in from the columnSummary
in components to guarantee that we're using the correct value typefmt
function since it won't have access to the columnSummary
The last unresolved piece which is likely a separate issue is this timezone shift I noticed - I believe it was when manually creating dates in a duckdb query, but will confirm.
I've just added changes to the docs in this branch.
With this new way of using formatting, the terminology becomes a bit confusing - we were using "format tags" to describe everything, but now I think we need different terms. Here's what is in this version:
usd
, mydate
) --> Format / Format Nameusd
, eur
, etc.) --> Built-in Formatsmydate
, mynum
, etc.) --> Custom Formats$#,##0
, etc.) --> Excel-style Formats{fmt(400, 'usd')}
) --> Format FunctionWith these changes, tag only applies to SQL Format Tags and everything else is referenced as a format (which can be built-in, custom, or Excel-style).
There are 3 ways to use formats in Evidence post this PR:
And Evidence supports these types of formats:
In my mind, the "tag" is specifically the bit you append to the SQL column name.
So my take would be slightly different, but similar:
Example | Name | Concept |
---|---|---|
xFmt |
format prop | method |
fmt(400, 'usd') |
format function | method |
sales_usd0 |
appended format tag | method |
$#,##0 |
format code | format specifier |
mydate |
(custom) format tag | format specifier |
usd0 |
(built in) format tag | format specifier |
WDYT? I think it means we have less concepts?
Also as side note, I think custom format tags are now much less important, as you can pass in an excel code directly to components: I might demote them in importance as a result.
Edit: so the P1 concepts we want people to understand in 30s:
everything else is advanced use
Agreed on the custom format importance. Those P1 items make sense to me.
After opening up component props, the word "tag" doesn't seem to fit as well (I used to think of the primary usage as "tagging" a column name with a format, so for me the tag included the underscore _usd
). I think I'd find it hard to distinguish between "tag" and "code" as a new user (or at least it would require a bit of explanation).
I like your usage of format code to cover the excel case.
In your layout of the terms, I would swap out the word "tag" for "name" everywhere except "column tags" - I think that would be easier for me to understand as a new user.
Your tag point is a good one.
I don't love "format name" though. I think name implies human readable, whereas this usd0
is more of a shorthand for the format code.
Some other possible words
None of them are perfect
That’s true. Format id is another option to throw into that list
@ItsMeBrianD I've included JSDoc on the 2 new functions that got added in this PR - let me know what you think
@ItsMeBrianD anything else we need to do before merging this one?
This seems like a good place to start with JSDoc, this looks good to me
Description
This PR adds formatting control to components. It adds a new function to take a string and return an Evidence formatting object, as well as props for each component to accept formats from users.
Closes #709
Setting a Format
The new format props accept a string. The format can be in any one of the categories below:
New Props
Charts:
xFmt
yFmt
sizeFmt
(for BubbleChart)valueFmt
(for Sankey and Funnel Charts)Tables
In the
Column
component:fmt
Value Component
fmt
BigValue Component
fmt
comparisonFmt
Annotations
In ReferenceLine:
valueFmt
override was initially considered, but is not included in this PRLimitations
Checklist