-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
Expected behavior
Per the docs here you can use the Chart class's helpers member to perform helper function type things.
However, Chart.helpers doesn't exist when I run an npm install.
When I use the codepen link, Chart.helpers does exist. I'm not sure what the discrepancy is between
https://npmcdn.com/chart.js@latest/dist/chart.min.js and the npm version chart.js@latest but something is off.
Package.json has it listed at 3.8.0.
I copied/pasted the example code and it still wont work.
For what its worth, I am using this with ng2-charts, however a direct class import should still show the full implementation.
Curious if I'm doing something wrong.
Current behavior
Chart.helpers doesn't exist.
Reproducible sample
https://codepen.io/pen?template=BapRepQ
Optional extra steps/info to reproduce
Full source from the node_modules v3.8.0 package for the Chart class after pulling it locally:
export declare class Chart<
TType extends ChartType = ChartType,
TData = DefaultDataPoint<TType>,
TLabel = unknown
> {
readonly platform: BasePlatform;
readonly id: string;
readonly canvas: HTMLCanvasElement;
readonly ctx: CanvasRenderingContext2D;
readonly config: ChartConfiguration<TType, TData, TLabel>;
readonly width: number;
readonly height: number;
readonly aspectRatio: number;
readonly boxes: LayoutItem[];
readonly currentDevicePixelRatio: number;
readonly chartArea: ChartArea;
readonly scales: { [key: string]: Scale };
readonly attached: boolean;
readonly legend?: LegendElement<TType>; // Only available if legend plugin is registered and enabled
readonly tooltip?: TooltipModel<TType>; // Only available if tooltip plugin is registered and enabled
data: ChartData<TType, TData, TLabel>;
options: ChartOptions<TType>;
constructor(item: ChartItem, config: ChartConfiguration<TType, TData, TLabel>);
clear(): this;
stop(): this;
resize(width?: number, height?: number): void;
ensureScalesHaveIDs(): void;
buildOrUpdateScales(): void;
buildOrUpdateControllers(): void;
reset(): void;
update(mode?: UpdateMode): void;
render(): void;
draw(): void;
isPointInArea(point: Point): boolean;
getElementsAtEventForMode(e: Event, mode: string, options: InteractionOptions, useFinalPosition: boolean): InteractionItem[];
getSortedVisibleDatasetMetas(): ChartMeta[];
getDatasetMeta(datasetIndex: number): ChartMeta;
getVisibleDatasetCount(): number;
isDatasetVisible(datasetIndex: number): boolean;
setDatasetVisibility(datasetIndex: number, visible: boolean): void;
toggleDataVisibility(index: number): void;
getDataVisibility(index: number): boolean;
hide(datasetIndex: number, dataIndex?: number): void;
show(datasetIndex: number, dataIndex?: number): void;
getActiveElements(): ActiveElement[];
setActiveElements(active: ActiveDataPoint[]): void;
destroy(): void;
toBase64Image(type?: string, quality?: unknown): string;
bindEvents(): void;
unbindEvents(): void;
updateHoverStyle(items: InteractionItem[], mode: 'dataset', enabled: boolean): void;
notifyPlugins(hook: string, args?: AnyObject): boolean | void;
static readonly defaults: Defaults;
static readonly overrides: Overrides;
static readonly version: string;
static readonly instances: { [key: string]: Chart };
static readonly registry: Registry;
static getChart(key: string | CanvasRenderingContext2D | HTMLCanvasElement): Chart | undefined;
static register(...items: ChartComponentLike[]): void;
static unregister(...items: ChartComponentLike[]): void;
}
As you can see there is no helpers member on this class.
Possible solution
No response
Context
No response
chart.js version
3.8.0
Browser name and version
N/A (issue occurs in code)
Link to your project
No response