Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-chartjs-2

Package Overview
Dependencies
Maintainers
4
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-chartjs-2 - npm Package Compare versions

Comparing version 4.3.1 to 5.0.0

6

dist/chart.d.ts

@@ -1,5 +0,3 @@

import type { ForwardedRef, ChartProps } from './types';
export declare const Chart: <TType extends keyof import("chart.js").ChartTypeRegistry = keyof import("chart.js").ChartTypeRegistry, TData = import("chart.js/types/utils").DistributiveArray<import("chart.js").ChartTypeRegistry[TType]["defaultDataPoint"]>, TLabel = unknown>(props: ChartProps<TType, TData, TLabel> & {
ref?: ForwardedRef<import("./types").ChartJSOrUndefined<TType, TData, TLabel>> | undefined;
}) => JSX.Element;
import type { TypedChartComponent } from './types.js';
export declare const Chart: TypedChartComponent;
//# sourceMappingURL=chart.d.ts.map

@@ -1,5 +0,5 @@

export type { ChartProps } from './types';
export * from './chart';
export * from './typedCharts';
export { getDatasetAtEvent, getElementAtEvent, getElementsAtEvent, } from './utils';
export type { ChartProps } from './types.js';
export * from './chart.js';
export * from './typedCharts.js';
export { getDatasetAtEvent, getElementAtEvent, getElementsAtEvent, } from './utils.js';
//# sourceMappingURL=index.d.ts.map
import React, { forwardRef, useRef, useEffect } from 'react';
import { Chart as Chart$1, LineController, BarController, RadarController, DoughnutController, PolarAreaController, BubbleController, PieController, ScatterController } from 'chart.js';
const defaultDatasetIdKey = 'label';
const defaultDatasetIdKey = "label";
function reforwardRef(ref, value) {
if (typeof ref === 'function') {
if (typeof ref === "function") {
ref(value);

@@ -13,3 +13,6 @@ } else if (ref) {

function setOptions(chart, nextOptions) {
Object.assign(chart.options, nextOptions);
const options = chart.options;
if (options && nextOptions) {
Object.assign(options, nextOptions);
}
}

@@ -24,4 +27,3 @@ function setLabels(currentData, nextLabels) {

// given the new set, find it's current match
const currentDataset = currentData.datasets.find((dataset)=>dataset[datasetIdKey] === nextDataset[datasetIdKey]
);
const currentDataset = currentData.datasets.find((dataset)=>dataset[datasetIdKey] === nextDataset[datasetIdKey]);
// There is no original to update, so simply add new one

@@ -54,3 +56,3 @@ if (!currentDataset || !nextDataset.data || addedDatasets.includes(currentDataset)) {

*/ function getDatasetAtEvent(chart, event) {
return chart.getElementsAtEventForMode(event.nativeEvent, 'dataset', {
return chart.getElementsAtEventForMode(event.nativeEvent, "dataset", {
intersect: true

@@ -65,3 +67,3 @@ }, false);

*/ function getElementAtEvent(chart, event) {
return chart.getElementsAtEventForMode(event.nativeEvent, 'nearest', {
return chart.getElementsAtEventForMode(event.nativeEvent, "nearest", {
intersect: true

@@ -76,3 +78,3 @@ }, false);

*/ function getElementsAtEvent(chart, event) {
return chart.getElementsAtEventForMode(event.nativeEvent, 'index', {
return chart.getElementsAtEventForMode(event.nativeEvent, "index", {
intersect: true

@@ -153,6 +155,5 @@ }, false);

renderChart();
return ()=>destroyChart()
;
return ()=>destroyChart();
}, []);
return(/*#__PURE__*/ React.createElement("canvas", Object.assign({
return /*#__PURE__*/ React.createElement("canvas", Object.assign({
ref: canvasRef,

@@ -162,3 +163,3 @@ role: "img",

width: width
}, props), fallbackContent));
}, props), fallbackContent);
}

@@ -169,18 +170,17 @@ const Chart = /*#__PURE__*/ forwardRef(ChartComponent);

Chart$1.register(registerables);
return(/*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ React.createElement(Chart, Object.assign({}, props, {
return /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ React.createElement(Chart, Object.assign({}, props, {
ref: ref,
type: type
}))
));
})));
}
const Line = /* #__PURE__ */ createTypedChart('line', LineController);
const Bar = /* #__PURE__ */ createTypedChart('bar', BarController);
const Radar = /* #__PURE__ */ createTypedChart('radar', RadarController);
const Doughnut = /* #__PURE__ */ createTypedChart('doughnut', DoughnutController);
const PolarArea = /* #__PURE__ */ createTypedChart('polarArea', PolarAreaController);
const Bubble = /* #__PURE__ */ createTypedChart('bubble', BubbleController);
const Pie = /* #__PURE__ */ createTypedChart('pie', PieController);
const Scatter = /* #__PURE__ */ createTypedChart('scatter', ScatterController);
const Line = /* #__PURE__ */ createTypedChart("line", LineController);
const Bar = /* #__PURE__ */ createTypedChart("bar", BarController);
const Radar = /* #__PURE__ */ createTypedChart("radar", RadarController);
const Doughnut = /* #__PURE__ */ createTypedChart("doughnut", DoughnutController);
const PolarArea = /* #__PURE__ */ createTypedChart("polarArea", PolarAreaController);
const Bubble = /* #__PURE__ */ createTypedChart("bubble", BubbleController);
const Pie = /* #__PURE__ */ createTypedChart("pie", PieController);
const Scatter = /* #__PURE__ */ createTypedChart("scatter", ScatterController);
export { Bar, Bubble, Chart, Doughnut, Line, Pie, PolarArea, Radar, Scatter, getDatasetAtEvent, getElementAtEvent, getElementsAtEvent };
//# sourceMappingURL=index.js.map

@@ -1,26 +0,27 @@

import type { ChartProps, ChartJSOrUndefined } from './types';
export declare const Line: <TData = (number | import("chart.js").ScatterDataPoint | null)[], TLabel = unknown>(props: Omit<ChartProps<"line", TData, TLabel>, "type"> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<"line", TData, TLabel>> | undefined;
/// <reference types="react" />
import type { ChartProps, ChartJSOrUndefined } from './types.js';
export declare const Line: <TData = (number | import("chart.js/dist/chunks/helpers.core.js").ad | null)[], TLabel = unknown>(props: Omit<ChartProps<"line", TData, TLabel>, "type"> & {
ref?: import("./types.js").ForwardedRef<ChartJSOrUndefined<"line", TData, TLabel>> | undefined;
}) => JSX.Element;
export declare const Bar: <TData = number[], TLabel = unknown>(props: Omit<ChartProps<"bar", TData, TLabel>, "type"> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<"bar", TData, TLabel>> | undefined;
export declare const Bar: <TData = (number | [number, number] | null)[], TLabel = unknown>(props: Omit<ChartProps<"bar", TData, TLabel>, "type"> & {
ref?: import("./types.js").ForwardedRef<ChartJSOrUndefined<"bar", TData, TLabel>> | undefined;
}) => JSX.Element;
export declare const Radar: <TData = (number | null)[], TLabel = unknown>(props: Omit<ChartProps<"radar", TData, TLabel>, "type"> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<"radar", TData, TLabel>> | undefined;
ref?: import("./types.js").ForwardedRef<ChartJSOrUndefined<"radar", TData, TLabel>> | undefined;
}) => JSX.Element;
export declare const Doughnut: <TData = number[], TLabel = unknown>(props: Omit<ChartProps<"doughnut", TData, TLabel>, "type"> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<"doughnut", TData, TLabel>> | undefined;
ref?: import("./types.js").ForwardedRef<ChartJSOrUndefined<"doughnut", TData, TLabel>> | undefined;
}) => JSX.Element;
export declare const PolarArea: <TData = number[], TLabel = unknown>(props: Omit<ChartProps<"polarArea", TData, TLabel>, "type"> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<"polarArea", TData, TLabel>> | undefined;
ref?: import("./types.js").ForwardedRef<ChartJSOrUndefined<"polarArea", TData, TLabel>> | undefined;
}) => JSX.Element;
export declare const Bubble: <TData = import("chart.js").BubbleDataPoint[], TLabel = unknown>(props: Omit<ChartProps<"bubble", TData, TLabel>, "type"> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<"bubble", TData, TLabel>> | undefined;
export declare const Bubble: <TData = import("chart.js/dist/chunks/helpers.core.js").a9[], TLabel = unknown>(props: Omit<ChartProps<"bubble", TData, TLabel>, "type"> & {
ref?: import("./types.js").ForwardedRef<ChartJSOrUndefined<"bubble", TData, TLabel>> | undefined;
}) => JSX.Element;
export declare const Pie: <TData = number[], TLabel = unknown>(props: Omit<ChartProps<"pie", TData, TLabel>, "type"> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<"pie", TData, TLabel>> | undefined;
ref?: import("./types.js").ForwardedRef<ChartJSOrUndefined<"pie", TData, TLabel>> | undefined;
}) => JSX.Element;
export declare const Scatter: <TData = (number | import("chart.js").ScatterDataPoint | null)[], TLabel = unknown>(props: Omit<ChartProps<"scatter", TData, TLabel>, "type"> & {
ref?: import("./types").ForwardedRef<ChartJSOrUndefined<"scatter", TData, TLabel>> | undefined;
export declare const Scatter: <TData = (number | import("chart.js/dist/chunks/helpers.core.js").ad | null)[], TLabel = unknown>(props: Omit<ChartProps<"scatter", TData, TLabel>, "type"> & {
ref?: import("./types.js").ForwardedRef<ChartJSOrUndefined<"scatter", TData, TLabel>> | undefined;
}) => JSX.Element;
//# sourceMappingURL=typedCharts.d.ts.map
import type { CanvasHTMLAttributes, MutableRefObject, ReactNode } from 'react';
import type { Chart, ChartType, ChartData, ChartOptions, DefaultDataPoint, Plugin, UpdateMode } from 'chart.js';
export declare type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
export type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
export interface ChartProps<TType extends ChartType = ChartType, TData = DefaultDataPoint<TType>, TLabel = unknown> extends CanvasHTMLAttributes<HTMLCanvasElement> {

@@ -52,4 +52,4 @@ /**

*/
export declare type ChartJSOrUndefined<TType extends ChartType = ChartType, TData = DefaultDataPoint<TType>, TLabel = unknown> = Chart<TType, TData, TLabel> | undefined;
export declare type TypedChartComponent<TDefaultType extends ChartType = ChartType, TOmitType = false> = TOmitType extends true ? <TData = DefaultDataPoint<TDefaultType>, TLabel = unknown>(props: Omit<ChartProps<TDefaultType, TData, TLabel>, 'type'> & {
export type ChartJSOrUndefined<TType extends ChartType = ChartType, TData = DefaultDataPoint<TType>, TLabel = unknown> = Chart<TType, TData, TLabel> | undefined;
export type TypedChartComponent<TDefaultType extends ChartType = ChartType, TOmitType = false> = TOmitType extends true ? <TData = DefaultDataPoint<TDefaultType>, TLabel = unknown>(props: Omit<ChartProps<TDefaultType, TData, TLabel>, 'type'> & {
ref?: ForwardedRef<ChartJSOrUndefined<TDefaultType, TData, TLabel>>;

@@ -56,0 +56,0 @@ }) => JSX.Element : <TType extends ChartType = ChartType, TData = DefaultDataPoint<TType>, TLabel = unknown>(props: ChartProps<TType, TData, TLabel> & {

import type { MouseEvent } from 'react';
import type { ChartType, ChartData, DefaultDataPoint, ChartDataset, ChartOptions, Chart } from 'chart.js';
import type { ForwardedRef } from './types';
import type { ForwardedRef } from './types.js';
export declare function reforwardRef<T>(ref: ForwardedRef<T>, value: T): void;

@@ -15,3 +15,3 @@ export declare function setOptions<TType extends ChartType = ChartType, TData = DefaultDataPoint<TType>, TLabel = unknown>(chart: Chart<TType, TData, TLabel>, nextOptions: ChartOptions<TType>): void;

*/
export declare function getDatasetAtEvent(chart: Chart, event: MouseEvent<HTMLCanvasElement>): import("chart.js").InteractionItem[];
export declare function getDatasetAtEvent(chart: Chart, event: MouseEvent<HTMLCanvasElement>): import("chart.js/dist/chunks/helpers.core.js").aE[];
/**

@@ -23,3 +23,3 @@ * Get single dataset element from mouse click event

*/
export declare function getElementAtEvent(chart: Chart, event: MouseEvent<HTMLCanvasElement>): import("chart.js").InteractionItem[];
export declare function getElementAtEvent(chart: Chart, event: MouseEvent<HTMLCanvasElement>): import("chart.js/dist/chunks/helpers.core.js").aE[];
/**

@@ -31,3 +31,3 @@ * Get all dataset elements from mouse click event

*/
export declare function getElementsAtEvent(chart: Chart, event: MouseEvent<HTMLCanvasElement>): import("chart.js").InteractionItem[];
export declare function getElementsAtEvent(chart: Chart, event: MouseEvent<HTMLCanvasElement>): import("chart.js/dist/chunks/helpers.core.js").aE[];
//# sourceMappingURL=utils.d.ts.map
{
"name": "react-chartjs-2",
"version": "4.3.1",
"type": "module",
"version": "5.0.0",
"description": "React components for Chart.js",

@@ -25,3 +26,6 @@ "author": "Jeremy Ayerst",

"types": "./dist/index.d.ts",
"main": "./dist/index.cjs",
"exports": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"publishConfig": {

@@ -34,8 +38,6 @@ "directory": "package"

"peerDependencies": {
"chart.js": "^3.5.0",
"chart.js": "^3.5.0 || ^4.0.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"readme": "",
"module": "./dist/index.js",
"scripts": {}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc