-
Notifications
You must be signed in to change notification settings - Fork 129
feat: improve canvas chart legend #7223
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
base: main
Are you sure you want to change the base?
Conversation
Code Review Agent Run #109c17Actionable Suggestions - 2
Review Details
|
function updateFieldConfig(property: keyof FieldConfig, value: any) { | ||
if (typeof markConfig !== "string") { | ||
const updatedConfig: FieldConfig = { | ||
...markConfig, | ||
[property]: value, | ||
}; | ||
onChange(updatedConfig); | ||
} else if (property === "field") { | ||
onChange({ | ||
field: value, | ||
type: "nominal", | ||
}); | ||
} | ||
} |
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.
The updateFieldConfig
function has been refactored to handle both string and object types for markConfig
, but the implementation creates a potential issue when property
is not 'field' and markConfig
is a string. This case isn't handled, which could lead to unexpected behavior.
Code suggestion
Check the AI-generated fix before applying
function updateFieldConfig(property: keyof FieldConfig, value: any) { | |
if (typeof markConfig !== "string") { | |
const updatedConfig: FieldConfig = { | |
...markConfig, | |
[property]: value, | |
}; | |
onChange(updatedConfig); | |
} else if (property === "field") { | |
onChange({ | |
field: value, | |
type: "nominal", | |
}); | |
} | |
} | |
function updateFieldConfig(property: keyof FieldConfig, value: any) { | |
if (typeof markConfig !== "string") { | |
const updatedConfig: FieldConfig = { | |
...markConfig, | |
[property]: value, | |
}; | |
onChange(updatedConfig); | |
} else if (property === "field") { | |
onChange({ | |
field: value, | |
type: "nominal", | |
}); | |
} else { | |
// Handle case where property is not 'field' but markConfig is a string | |
console.warn(`Cannot update ${property} when markConfig is a string`); | |
} | |
} |
Code Review Run #109c17
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
interface NominalFieldConfig { | ||
sort?: ChartSortDirection; | ||
limit?: number; | ||
showNull?: boolean; | ||
labelAngle?: number; | ||
legendOrientation?: ChartLegend; | ||
} | ||
|
||
interface QuantitativeFieldConfig { | ||
zeroBasedOrigin?: boolean; // Default is false | ||
} | ||
|
||
export interface FieldConfig | ||
extends NominalFieldConfig, | ||
QuantitativeFieldConfig { | ||
field: string; | ||
type: "quantitative" | "ordinal" | "nominal" | "temporal"; | ||
showAxisTitle?: boolean; // Default is false | ||
timeUnit?: string; // For temporal fields | ||
} |
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.
The FieldConfig
interface has been refactored into separate interfaces with specific properties, but zeroBasedOrigin
is now only in QuantitativeFieldConfig
which may cause issues when used with non-quantitative field types.
Code suggestion
Check the AI-generated fix before applying
@@ -63,12 +63,13 @@
+
+interface QuantitativeFieldConfig {
-+ zeroBasedOrigin?: boolean; // Default is false
+}
+
+export interface FieldConfig
+ extends NominalFieldConfig,
+ QuantitativeFieldConfig {
+ field: string;
+ type: "quantitative" | "ordinal" | "nominal" | "temporal";
+ showAxisTitle?: boolean; // Default is false
++ zeroBasedOrigin?: boolean; // Default is false
+ timeUnit?: string; // For temporal fields
Code Review Run #109c17
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
Add multiple improvements to chart legends -
Checklist: