Skip to content

@feds01/graphika


@feds01/graphika / basic.graph

basic.graph

Classes

default

Defined in: basic.graph.ts:215

Class that represent the basis graph drawing option

Constructors

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

Defined in: basic.graph.ts:275

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:237
canvaspublicHTMLCanvasElementSince v0.0.1 A reference to the canvas element.basic.graph.ts:248
ctxpublicCanvasRenderingContext2DSince v0.0.1 The canvas context object, this is used to draw on the canvas element.basic.graph.ts:253
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:224
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:243
gridRectSizepublic{ x: number; y: number; }-basic.graph.ts:257
gridRectSize.xpublicnumber-basic.graph.ts:257
gridRectSize.ypublicnumber-basic.graph.ts:257
lengthspublicLengths-basic.graph.ts:264
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:219
paddingpublicPadding-basic.graph.ts:256

Methods

calculateLengths()
ts
calculateLengths(): void;

Defined in: basic.graph.ts:540

Returns

void

calculatePadding()
ts
calculatePadding(): void;

Defined in: basic.graph.ts:562

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

draw()
ts
draw(): void;

Defined in: basic.graph.ts:670

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:345

Returns

number

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

Defined in: basic.graph.ts:377

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:356

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:36

Animation options for the graph.

Properties

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

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;
  x_label?: string;
  y_label?: string;
};

Defined in: basic.graph.ts:45

Properties

PropertyTypeDescriptionDefined in
animation?AnimationOptionsAnimation settings for the graph.basic.graph.ts:81
axisColour?stringColour of the axes.basic.graph.ts:62
debug?booleanDebug mode for the graph. Enables additional logging and visual aids for development.basic.graph.ts:84
grid?GridOptionsGrid options for the graph.basic.graph.ts:65
labelFont?string-basic.graph.ts:56
labelFontSize?number-basic.graph.ts:59
legend?LegendOptionsLegend options for the graph.basic.graph.ts:78
padding?numberPadding around the graph content.basic.graph.ts:47
scale?{ shorthandNumerics?: boolean; x?: AxisOptions; y?: AxisOptions; }Scale options for the graph axes.basic.graph.ts:71
scale.shorthandNumerics?boolean-basic.graph.ts:72
scale.x?AxisOptions-basic.graph.ts:73
scale.y?AxisOptions-basic.graph.ts:74
title?TitleOptionsTitle options for the graph.basic.graph.ts:68
x_label?string-basic.graph.ts:50
y_label?string-basic.graph.ts:53

GridOptions

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

Defined in: basic.graph.ts:27

Properties

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

TitleAlignment

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

Defined in: basic.graph.ts:98


TitleOptions

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

Defined in: basic.graph.ts:87

Properties

PropertyTypeDefined in
alignment?TitleAlignmentbasic.graph.ts:91
colour?stringbasic.graph.ts:94
contentstringbasic.graph.ts:89
draw?booleanbasic.graph.ts:88
fontFamily?stringbasic.graph.ts:92
fontSize?numberbasic.graph.ts:93
position?TitlePositionbasic.graph.ts:90

TitlePosition

ts
type TitlePosition = "top";

Defined in: basic.graph.ts:97

Released under the ISC License.