typing of Color is incorrect in ColorHelper constructor
See original GitHub issueDescribe the bug
in version 18 the following code worked:
this.data = ['No Data'];
this.colors = new ColorHelper({ domain: ['#ccc'] }, ScaleType.Ordinal, this.data, null);
<ngx-charts-legend
[data]="data"
[colors]="colors!"
...
in v19 the compiler now complains
error TS2345: Argument of type '{ domain: string[]; }' is not assignable to parameter of type 'string | Color'.
Type '{ domain: string[]; }' is missing the following properties from type 'Color': name, selectable, group
reviewing code for ColorHelper, none of the other properties matter. It appears that there are a set of default schemes named in color-sets.ts and on those objects, the name
member is also used but the other members are unused.
Perhaps a better type definition for Color
would be
export interface Color {
name?: string;
selectable?: boolean;
group?: ScaleType;
domain: string[];
}
or the constructor to ColorHelper
should take in a string | ColorDomain
type:
export interface ColorDomain {
domain: string[];
}
To Reproduce Steps to reproduce the behavior:
-
have working code in v18.0.1 using
this.data = ['No Data']; this.colors = new ColorHelper({ domain: ['#ccc'] }, ScaleType.Ordinal, this.data, null);
-
update to v19.0.1
-
build
Expected behavior Build success, or at least documentation on what these additional parameters are for and why they are added.
ngx-charts version
19.0.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13
Top Results From Across the Web
c# - Why does this color comparison fail? - Stack Overflow
It is Argb values of current instance (they are stored in one field of type long ). So, if Argb different, we have...
Read more >Tips for using color schemer somewhere? | CoffeeCup Software
I just purchased Color Schemer due to that great offer to existing customers. ... and it's interactive rather than typing a number off...
Read more >Introduction to use color utils in Power BI visual - Microsoft Learn
This article describes how to use color utils simplify applying of themes and palettes on visual's data points on Power BI visuals.
Read more >GroupAction class - hue_dart library - Dart API - Pub.dev
The average brightness of the group (off is brightness 0, if device does not ... the color mode in which the light is...
Read more >Color – three.js docs
//empty constructor - will default white const color1 = new THREE.Color(); //Hexadecimal ... Read-only flag to check if a given object is of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Ahmedsk143
check this one it’s working for me
import { Color, ScaleType } from '@swimlane/ngx-charts';
colorScheme: Color = { domain: ['#99CCE5', '#FF7F7F'], group: ScaleType.Ordinal, selectable: true, name: 'Customer Usage', };
I am getting same issue on v20.1.0