Open NatoBoram opened 4 years ago
It looks like ngx-charts-chart
's legendOptions
has a very complicated type.
import { ColorHelper } from '@swimlane/ngx-charts';
export interface NgxLegendOptions {
title?: string;
position?: 'below' | 'right';
domain: string[];
colors: ColorHelper;
scaleType?: 'linear' | 'scaleLegend' | 'legend';
}
Seriously, having to guess all of this is time consuming! And I'm not even sure I'm right!
Found some other useful types.
export enum NgxLegendPosition {
below = 'below',
right = 'right',
}
export enum NgxScaleType {
linear = 'linear',
scaleLegend = 'scaleLegend',
legend = 'legend',
}
export interface NgxColourSet {
name?: string;
selectable?: boolean;
group?: string;
domain: string[];
}
export interface NgxLegendOptions {
title?: string;
position?: NgxLegendPosition;
domain: string[];
colors: ColorHelper;
scaleType?: NgxScaleType;
}
In ColorHelper
, the constructor is missing some types.
export class ColorHelper {
constructor(scheme: string | ColourSet, type: ScaleType, domain: string[], customColors?)
}
Hello @NatoBoram,
Don't worry about that, I have been submitting PR's to fix the library with the proper types. So far I have provide most of them but haven't applied that to every chart.
You can check those if you wish: #1249, #1251.
I am just waiting to get some of them reviewed and merged to continue submitting all the proper types because a single mistake can affect several charts.
Cheers!
Thanks @KingDarBoja. I suggest you separate your new features and charts from the typing fixes.
I've also created #1278 with minimal changes in hope to be useful to the project since I'm using it.
Is your feature request related to a problem? Please describe.
I'm trying to add a custom
ngx-charts-legend
somewhere. Problem is, I have no idea what the hell I'm supposed to write in its inputs.For reference, here's its inputs.
Here, every single property (except for
horizontal
) is of typeany
, which means we can put anything we want there. However, it is not the case, and it is quite difficult to figure out how to use the library when there's absolutely no type information available anywhere.data
seems to be of typestring[]
, andcolors
seems to be of typeColorHelper
, but there's no way to know more about it without hours of navigating this plate of spaghetti.Describe the solution you'd like
I would like for all
@Input()
across all the library to have types.More than that, all variables across the library should be typed.
Ideally, in
tsconfig.json
,noImplicitAny
should be set totrue
.Describe alternatives you've considered
One could add JSDocs comments, but TypeScript disallows specifying the type there since it's redundant.
Additional context
LegendEntryComponent
:ChartComponent
:ColorHelper
: