Skip to content

@feds01/graphika


@feds01/graphika / basic.graph

basic.graph ​

Classes ​

default ​

Defined in: basic.graph.ts:220

Class that represent the basis graph drawing option

Constructors ​

Constructor ​
ts
new default(
   id, 
   options, 
   data
): default;

Defined in: basic.graph.ts:297

Parameters ​
ParameterType
idstring
optionsBasicGraphOptions
dataDataSource[]
Returns ​

default

Properties ​

PropertyModifierTypeDescriptionDefined in
axisManagerpublicdefaultSince v0.0.1 AxisManager object is a manager class for the Axis objects of this Graph object, The AxisManager contains the xAxis & yAxis objects, it also handles the synchronisation of scales & negative axis modes.basic.graph.ts:247
canvaspublicHTMLCanvasElementSince v0.0.1 A reference to the canvas element.basic.graph.ts:258
ctxpublicCanvasRenderingContext2DSince v0.0.1 The canvas context object, this is used to draw on the canvas element.basic.graph.ts:263
dataManagerpublicdefaultSince v0.0.1 DataManager object which contains the data for the lines the graph should plot, the object also contains various utility functions to fetch stats on the data. *basic.graph.ts:229
drawerpublicdefaultSince v0.0.1 Drawer object is the interface to use when dealing with the drawing of the graph, it contains the canvas element, the canvas context and the methods to draw on the canvas.basic.graph.ts:253
gridRectSizepublic{ x: number; y: number; }-basic.graph.ts:267
gridRectSize.xpublicnumber-basic.graph.ts:267
gridRectSize.ypublicnumber-basic.graph.ts:267
lengthspublicLengths-basic.graph.ts:286
optionspublicBasicGraphOptionsSince v0.0.1 Graph options, this contain x-labels, y-label, tittle, legends, points style, gridded, etc. More on graph options can be read in the documentation *basic.graph.ts:224
paddingpublicPadding-basic.graph.ts:266

Methods ​

calculateLengths() ​
ts
calculateLengths(): void;

Defined in: basic.graph.ts:630

Returns ​

void

calculatePadding() ​
ts
calculatePadding(): void;

Defined in: basic.graph.ts:657

Calculates the padding around the graph grid, taking into account font sizes of labels, title, legends and any other parameters that could affect the size that needs to be reserved around the area.

Returns ​

void

destroy() ​
ts
destroy(): void;

Defined in: basic.graph.ts:946

Cleanup resources used by the graph.

Call this method when the graph is no longer needed to remove event listeners and free up resources.

Returns ​

void

draw() ​
ts
draw(): void;

Defined in: basic.graph.ts:786

Method that draws the whole graph, computing all pre-requisites and then invoking draw on children components.

Returns ​

void

fontSize() ​
ts
fontSize(): number;

Defined in: basic.graph.ts:392

Returns ​

number

getLineLabels() ​
ts
getLineLabels(): string[];

Defined in: basic.graph.ts:427

Returns ​

string[]

Since ​

v0.0.1

This method is used to fetch all line labels that are present on this graph.

removeLineByLabel() ​
ts
removeLineByLabel(label): void;

Defined in: basic.graph.ts:403

Parameters ​
ParameterType
labelstring
Returns ​

void

Since ​

v0.0.1

This method is used to remove a line by a given 'label' which is present with every line that is present on the graph. If the developer does not specify a label, a random string is generated and that is used as a label instead.

Type Aliases ​

AnimationOptions ​

ts
type AnimationOptions = {
  duration?: number;
  easing?: EasingAnimationFn;
  enabled: boolean;
};

Defined in: basic.graph.ts:38

Animation options for the graph.

Properties ​

PropertyTypeDescriptionDefined in
duration?numberDuration of the animation in milliseconds.basic.graph.ts:42
easing?EasingAnimationFnEasing function for the animation.basic.graph.ts:44
enabledbooleanWhether to animate the lines when drawing.basic.graph.ts:40

BasicGraphOptions ​

ts
type BasicGraphOptions = {
  animation?: AnimationOptions;
  axisColour?: string;
  debug?: boolean;
  grid?: GridOptions;
  labelFont?: string;
  labelFontSize?: number;
  legend?: LegendOptions;
  padding?: number;
  scale?: {
     shorthandNumerics?: boolean;
     x?: AxisOptions;
     y?: AxisOptions;
  };
  title?: TitleOptions;
  tooltip?: TooltipOptions;
  x_label?: string;
  y_label?: string;
};

Defined in: basic.graph.ts:47

Properties ​

PropertyTypeDescriptionDefined in
animation?AnimationOptionsAnimation settings for the graph.basic.graph.ts:83
axisColour?stringColour of the axes.basic.graph.ts:64
debug?booleanDebug mode for the graph. Enables additional logging and visual aids for development.basic.graph.ts:89
grid?GridOptionsGrid options for the graph.basic.graph.ts:67
labelFont?string-basic.graph.ts:58
labelFontSize?number-basic.graph.ts:61
legend?LegendOptionsLegend options for the graph.basic.graph.ts:80
padding?numberPadding around the graph content.basic.graph.ts:49
scale?{ shorthandNumerics?: boolean; x?: AxisOptions; y?: AxisOptions; }Scale options for the graph axes.basic.graph.ts:73
scale.shorthandNumerics?boolean-basic.graph.ts:74
scale.x?AxisOptions-basic.graph.ts:75
scale.y?AxisOptions-basic.graph.ts:76
title?TitleOptionsTitle options for the graph.basic.graph.ts:70
tooltip?TooltipOptionsTooltip settings for interactive data display.basic.graph.ts:86
x_label?string-basic.graph.ts:52
y_label?string-basic.graph.ts:55

GridOptions ​

ts
type GridOptions = {
  gridded?: boolean;
  gridLineStyle?: string;
  optimiseSquareSize?: boolean;
  sharedAxisZero?: boolean;
  strict?: boolean;
};

Defined in: basic.graph.ts:29

Properties ​

PropertyTypeDefined in
gridded?booleanbasic.graph.ts:30
gridLineStyle?stringbasic.graph.ts:31
optimiseSquareSize?booleanbasic.graph.ts:32
sharedAxisZero?booleanbasic.graph.ts:33
strict?booleanbasic.graph.ts:34

TitleAlignment ​

ts
type TitleAlignment = "start" | "center" | "end";

Defined in: basic.graph.ts:103


TitleOptions ​

ts
type TitleOptions = {
  alignment?: TitleAlignment;
  colour?: string;
  content: string;
  draw?: boolean;
  fontFamily?: string;
  fontSize?: number;
  position?: TitlePosition;
};

Defined in: basic.graph.ts:92

Properties ​

PropertyTypeDefined in
alignment?TitleAlignmentbasic.graph.ts:96
colour?stringbasic.graph.ts:99
contentstringbasic.graph.ts:94
draw?booleanbasic.graph.ts:93
fontFamily?stringbasic.graph.ts:97
fontSize?numberbasic.graph.ts:98
position?TitlePositionbasic.graph.ts:95

TitlePosition ​

ts
type TitlePosition = "top";

Defined in: basic.graph.ts:102

Released under the ISC License.