question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

typing of Color is incorrect in ColorHelper constructor

See original GitHub issue

Describe 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:

  1. have working code in v18.0.1 using

     this.data = ['No Data'];
     this.colors = new ColorHelper({ domain: ['#ccc'] }, ScaleType.Ordinal, this.data, null);
    
  2. update to v19.0.1

  3. 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:13

github_iconTop GitHub Comments

5reactions
osamaalnuimicommented, Feb 21, 2022

@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', };

3reactions
seniordev09commented, Mar 14, 2022

I am getting same issue on v20.1.0

error TS2322: Type '{ domain: string[]; }' is not assignable to type 'string | Color'.
  Type '{ domain: string[]; }' is not assignable to type 'Color'.
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found