Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse types from Chart.ts #439

Merged
merged 2 commits into from
Mar 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions types/options.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import { Chart } from 'chart.js';
import { Chart, Color } from 'chart.js';


type Mode = 'x' | 'y' | 'xy' | 'xy';
type Mode = 'x' | 'y' | 'xy';

interface DragEffectOptions {
borderColor?: string;
export interface DragEffectOptions {
borderColor?: Color;
borderWidth?: number;
backgroundColor?: string;
backgroundColor?: Color;
animationDuration?: number;
}

interface XyValue {
x?: number;
y?: number;
export interface RangePoint {
x?: number | string;
y?: number | string;
}

interface ZoomOptions {
/**
* Container for zoop options
*/
export interface ZoomOptions {
/**
* Boolean to enable zooming
**/
*/
enabled: boolean;

/**
Expand All @@ -27,26 +30,29 @@ interface ZoomOptions {
drag: boolean | DragEffectOptions;


// Zooming directions. Remove the appropriate direction to disable
// Eg. 'y' would only allow zooming in the y direction
// A function that is called as the user is zooming and returns the
// available directions can also be used:
// mode: function({ chart }) {
// return 'xy';
// },
/**
* Zooming directions. Remove the appropriate direction to disable
* Eg. 'y' would only allow zooming in the y direction
* A function that is called as the user is zooming and returns the
* available directions can also be used:
* mode: function({ chart }) {
* return 'xy';
* },
*/
mode: Mode | { (char: Chart): Mode };

/**
* Format of min zoom range depends on scale type
*/
rangeMin?: XyValue;
* Format of min zoom range depends on scale type
*/
rangeMin?: RangePoint;

/**
* Format of max zoom range depends on scale type
*/
rangeMax?: XyValue;
rangeMax?: RangePoint;

/** Speed of zoom via mouse wheel
/**
* Speed of zoom via mouse wheel
* (percentage of zoom on a wheel event)
*/
speed?: number;
Expand Down Expand Up @@ -78,8 +84,10 @@ interface ZoomOptions {

}

// Container for pan options
interface PanOptions {
/**
* Container for pan options
*/
export interface PanOptions {
/**
* Boolean to enable panning
*/
Expand All @@ -100,12 +108,12 @@ interface PanOptions {
/**
* Format of min pan range depends on scale type
*/
rangeMin?: XyValue;
rangeMin?: RangePoint;

/**
* Format of max pan range depends on scale type
*/
rangeMax?: XyValue;
rangeMax?: RangePoint;


/**
Expand Down