-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plot title additions #2337
Merged
Merged
Plot title additions #2337
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
81ba7f9
Add check to scale tick format
OAGr 5933ada
Added title to most plots, and xAxisTitle and yAxisTitle to relevant …
OAGr 23edd85
Adjusted color and font of Axis titles
OAGr e87eb2a
Small fixes, use custom tickFormat for SummaryTable
OAGr c46b6d4
Added changeset, fixed tests, minor cleaning
OAGr 273d70a
Adding back modified frDict definition, for tests to work
OAGr 789a4a0
Adjusted xAxisTitle to change position based on padding.bottom
OAGr 9659652
Implemented changes requested in CR
OAGr 5f0d434
Minor quickfix
OAGr 35aea89
Fixed tests
OAGr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,6 @@ | ||
--- | ||
"@quri/squiggle-lang": patch | ||
"@quri/squiggle-components": patch | ||
--- | ||
|
||
Added title to all plots, and to scales for xAxisLabel and yAxisLabel. Added validation for tickFormat. |
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 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,32 @@ | ||
"use client"; | ||
|
||
import { Component, PropsWithChildren } from "react"; | ||
|
||
type State = { | ||
error?: Error; | ||
}; | ||
|
||
export class ErrorBoundary extends Component<PropsWithChildren, State> { | ||
public state: State = {}; | ||
|
||
public static getDerivedStateFromError(error: Error): State { | ||
return { error }; | ||
} | ||
|
||
componentDidCatch() {} | ||
|
||
public render() { | ||
if (this.state.error) { | ||
return ( | ||
<div className="m-2 p-4 bg-red-300 rounded"> | ||
<header className="mb-2 font-semibold">Fatal Error</header> | ||
<div className="mb-2">{this.state.error.message}</div> | ||
<div className="mb-2">Try reloading the browser.</div> | ||
<pre className="text-xs overflow-auto">{this.state.error.stack}</pre> | ||
</div> | ||
); | ||
} | ||
|
||
return this.props.children; | ||
} | ||
} |
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 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,9 @@ | ||
import { FC } from "react"; | ||
|
||
export const PlotTitle: FC<{ title: string }> = ({ title }) => { | ||
return ( | ||
<div className="text-center font-semibold text-slate-700 text-sm"> | ||
{title} | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a slight discrepancy (4px) with the old behavior.
Before: https://www.squiggle-language.com/playground?v=dev#code=eNqrVkpJTUsszSlxzk9JVbJSqlCwVQiuzNUrzctMyy%2FK1TDSMTTQVKoFAAjgDIc%3D
After: https://squiggle-website-git-plot-additions-quantified-uncertainty.vercel.app/playground?v=dev#code=eNqrVkpJTUsszSlxzk9JVbJSqlCwVQiuzNUrzctMyy%2FK1TDSMTTQVKoFAAjgDIc%3D
In both versions, canvas is 84px tall:
So previously chart height itself was exactly as was requested, 50px, but it's 54px now.
Of course this doesn't matter much, but to avoid future confusion about what's right, I'd suggest:
suggestedPadding
outside ofdraw
functionconst height
based on it,const height = innerHeight + suggestedPadding.top + suggestedPadding.bottom
, then we'd be confident that they match and thatinnerHeight
is correctThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a messy area, thanks for explaining!
For one thing, I imagine we'll later just want the labels to be in HTML, which would change the constraints here.
We'd also want it underneath the samples toolbar, as discussed in my PR description.