-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add hint when add rows is used on vega lite chart #8499
Closed
Closed
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -85,6 +85,8 @@ export interface VegaLiteChartElement { | |
|
||
/** override the properties with a theme. Currently, only "streamlit" or None are accepted. */ | ||
vegaLiteTheme: string | ||
|
||
needsAddRows: boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you also add a comment here describing the property? |
||
} | ||
|
||
/** A mapping of `ArrowNamedDataSet.proto`. */ | ||
|
@@ -186,9 +188,10 @@ export class ArrowVegaLiteChart extends PureComponent<PropsWithHeight, State> { | |
|
||
const prevData = prevElement.data | ||
const { data } = element | ||
const addRowsHint = element.needsAddRows ?? false | ||
|
||
if (prevData || data) { | ||
this.updateData(this.defaultDataName, prevData, data) | ||
this.updateData(this.defaultDataName, prevData, data, addRowsHint) | ||
} | ||
|
||
const prevDataSets = getDataSets(prevElement) || {} | ||
|
@@ -198,13 +201,13 @@ export class ArrowVegaLiteChart extends PureComponent<PropsWithHeight, State> { | |
const datasetName = name || this.defaultDataName | ||
const prevDataset = prevDataSets[datasetName] | ||
|
||
this.updateData(datasetName, prevDataset, dataset) | ||
this.updateData(datasetName, prevDataset, dataset, addRowsHint) | ||
} | ||
|
||
// Remove all datasets that are in the previous but not the current datasets. | ||
for (const name of Object.keys(prevDataSets)) { | ||
if (!dataSets.hasOwnProperty(name) && name !== this.defaultDataName) { | ||
this.updateData(name, null, null) | ||
this.updateData(name, null, null, addRowsHint) | ||
} | ||
} | ||
|
||
|
@@ -260,7 +263,8 @@ export class ArrowVegaLiteChart extends PureComponent<PropsWithHeight, State> { | |
private updateData( | ||
name: string, | ||
prevData: Quiver | null, | ||
data: Quiver | null | ||
data: Quiver | null, | ||
addRowsHint: boolean | ||
): void { | ||
if (!this.vegaView) { | ||
throw new Error("Chart has not been drawn yet") | ||
|
@@ -293,7 +297,8 @@ export class ArrowVegaLiteChart extends PureComponent<PropsWithHeight, State> { | |
prevNumCols, | ||
data, | ||
numRows, | ||
numCols | ||
numCols, | ||
addRowsHint | ||
) | ||
) { | ||
if (prevNumRows < numRows) { | ||
|
@@ -502,7 +507,8 @@ function dataIsAnAppendOfPrev( | |
prevNumCols: number, | ||
data: Quiver, | ||
numRows: number, | ||
numCols: number | ||
numCols: number, | ||
addRowsHint: boolean | ||
): boolean { | ||
// Check whether dataframes have the same shape. | ||
|
||
|
@@ -525,6 +531,10 @@ function dataIsAnAppendOfPrev( | |
const c = numCols - 1 | ||
const r = prevNumRows - 1 | ||
|
||
if (!addRowsHint) { | ||
return false | ||
} | ||
|
||
// Check if the new dataframe looks like it's a superset of the old one. | ||
// (this is a very light check, and not guaranteed to be right!) | ||
if ( | ||
|
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 |
---|---|---|
|
@@ -40,5 +40,7 @@ message ArrowVegaLiteChart { | |
// override the properties with a theme. Currently, only "streamlit" or None are accepted. | ||
string theme = 6; | ||
|
||
bool needs_add_rows = 7; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you add a comment here describing the property? |
||
|
||
reserved 3; | ||
} |
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.
Is the proto field here even required? Couldn't we just always set it to false here since the proto change seems to be never set to something else than false?
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.
Yea, the value needs to be set. Practically, this will always be
false
, but I figured it's best to maintain the protobuf's members (theoretically, people can create a custom message, and we can honor it). See example.