Skip to content
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

feat(D3 plugin): add color property to scatter and bar data #265

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins/d3/renderer/hooks/useShapes/bar-x.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export function BarXSeriesShapes(args: Args) {
.attr('y', (d) => d.y)
.attr('height', (d) => d.height)
.attr('width', (d) => d.width)
.attr('fill', item.color)
.attr('fill', (d) => d.data.color || item.color)
.on('mousemove', (e, point) => {
const [x, y] = pointer(e, svgContainer);
onSeriesMouseMove?.({
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/d3/renderer/hooks/useShapes/scatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function ScatterSeriesShape(props: ScatterSeriesShapeProps) {
.enter()
.append('circle')
.attr('class', b('point'))
.attr('fill', series.color || '')
.attr('fill', (d) => d.color || series.color || '')
.attr('r', (d) => d.radius || DEFAULT_SCATTER_POINT_RADIUS)
.attr('cx', (d) => getCxAttr({point: d, xAxis, xScale}))
.attr('cy', (d) => getCyAttr({point: d, yAxis, yScale}))
Expand Down
1 change: 0 additions & 1 deletion src/types/widget-data/bar-x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type BarXSeriesData<T = any> = BaseSeriesData<T> & {
y?: number;
/** Corresponding value of axis category */
category?: string;

/** Data label value of the bar-x column. If not specified, the y value is used. */
label?: string | number;
};
Expand Down
2 changes: 2 additions & 0 deletions src/types/widget-data/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export type BaseSeriesData<T = any> = {
* Here you can add additional data for your own event callbacks and formatter callbacks
*/
custom?: T;
/** Individual color for the data chunk (point in scatter, segment in pie, bar etc) */
color?: string;
};

export type BaseTextStyle = {
Expand Down
2 changes: 0 additions & 2 deletions src/types/widget-data/pie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export type PieSeriesData<T = any> = BaseSeriesData<T> & {
value: number;
/** The name of the pie segment (used in legend, tooltip etc). */
name: string;
/** Individual color for the pie segment. */
color?: string;
/** Initial visibility of the pie segment. */
visible?: boolean;
/** Initial data label of the pie segment. If not specified, the value is used. */
Expand Down