CanvasBaseGraphComponent class abstract

Inheritance
Implementers

Constructors

CanvasBaseGraphComponent.new(RenderComponent parent, String id, {double maxLabelWidthX = 50, double maxLabelWidthY = 20, String labelFormatX(double label) = _defaultLabelFormat, String labelFormatY(double label) = _defaultLabelFormat, double textMargin = 15, double aspectRatio = 1.5, double gridLineWidth = 1, String gridLineStrokeStyle = '#d7d7d7', String labelFillStyle = '#aaaaaa', String labelFontStyle = '14px sans-serif', String captionBgColor = '#2d2d2d', String captionFgColor = 'white', String captionFontFamily = 'sans-serif', bool drawGridY = false})

Properties

aspectRatio double
The width/height ratio of this canvas. The canvas height, everytime it is redrawn, changes based on the canvas clientWidth. The height follows the width depending on the ratio: height = width/aspectRatio.
finalinherited
baseInnerElement → Element?
no setterinherited
baseInnerHtml String
Unlike RenderComponent, setting the baseInnerHtml does not update baseInnerElement, because this component is not designed +to be rendered independently. You need to reprint the component to the parent's component (update its baseInnerHtml with this component string asString), and re-attach it with _attachToRenderComponent again.
getter/setter pairinherited
captionBgColor String
The caption background color.
finalinherited
captionFgColor String
The caption foreground color (the text color).
finalinherited
captionFontFamily String
The caption font family.
finalinherited
ctx → CanvasRenderingContext2D
no setter
drawGridY bool
Whether to draw Y grid lines.
finalinherited
elem → Element
Returns the DOM Element of this component by doing querySelector('$id').
no setterinherited
gridLineStrokeStyle String
The line stroke style for the canvas grid.
finalinherited
gridLineWidth double
The line width used to draw canvas grid.
finalinherited
gridMaxPxX double
The maximum coordinate of the grid, in pixel. The grid starts at (gridMinPxX,gridMinPxY) and ends in (gridMaxPxX, gridMaxPxY).
getter/setter pair
gridMaxPxY double
The maximum coordinate of the grid, in pixel. The grid starts at (gridMinPxX,gridMinPxY) and ends in (gridMaxPxX, gridMaxPxY).
getter/setter pair
gridMinPxX double
The minimum coordinate of the grid, in pixel. The grid starts at (gridMinPxX,gridMinPxY) and ends in (gridMaxPxX, gridMaxPxY).
getter/setter pair
gridMinPxY double
The minimum coordinate of the grid, in pixel. The grid starts at (gridMinPxX,gridMinPxY) and ends in (gridMaxPxX, gridMaxPxY).
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
htmlElem → HTMLElement
no setterinherited
id String
Setting the component with new ID is basically not recommended. It will change the real HTML ID of this element rendered in DOM too, and will throw ComponentDuplicateIdException when the new ID already exists.
getter/setter pairinherited
labelFillStyle String
The label texts color style.
finalinherited
labelFontStyle String
The labels font style.
finalinherited
labelFormatX String Function(double label)
The formatting function used to display the labels in X axis. If none is specified, it by default uses NumberFormat.compact to format label values into string. You might want to override this for example if you want the label to be a date.
final
labelFormatY String Function(double label)
The formatting function used to display the labels in Y axis. If none is specified, it by default uses NumberFormat.compact to format label values into string. You might want to override this for example if you want the label to be a date.
final
mathMlElem → MathMLElement
no setterinherited
maxLabelWidthX double
The maximum width for label texts in X axis.
final
maxLabelWidthY double
The maximum width for label texts in Y axis.
final
parent RenderComponent
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
svgElem → SVGElement
no setterinherited
textMargin double
The distance between label text to the grid.
finalinherited

Methods

addOnChangeTo(Element node, void onChange(Event)) → void
Creates an onChange event on node (has to be an Element or Document type). Call this in loadEventHandlers.
inherited
addOnClickTo(Element node, void onClick(Event)) → void
Creates an onClick event on node (has to be an Element or Document type). Call this in loadEventHandlers.
inherited
addSubscription(StreamSubscription subs) → void
A generic method to add an event subscription which will also get cancelled when unloadEventHandlers is called.
inherited
addSubscriptions(Iterable<StreamSubscription> subs) → void
A generic method to add (bulk) event subscriptions which will also get cancelled when unloadEventHandlers is called.
inherited
assertDuplicateId(String id) → void
inherited
assertElementAttached() → void
inherited
calcGridMaxPxX() double
calcGridMaxPxY() double
calcGridMinPxX() double
calcGridMinPxY() double
calculateMinMaxGrid() → void
clearDrawing() → void
clearPoints() → void
inherited
contains(Node node) bool
Contains checks whether a node is contained in this component. Can only be used by StringComponent if the component has been attached.
inherited
drawDataPoints() → void
inherited
drawGrid([bool drawY = false]) → void
inherited
drawLabels() → void
inherited
getApproxTextHeight() double
The exact font height is retrieved from TextMetrics.fontBoundingBoxAscent. However, not all browsers support this property, and if this property returns null, the height can be approximated by getting the width of character 'M'. This is no magic, see also: https://stackoverflow.com/a/13318387/9113939.
getCalculatedMinWidth() double
Gets the calculated minimum width of the graph.
getLabelCountX() int
Gets how many labels the graph should display in X axis.
getLabelCountY() int
Gets how many labels the graph should display in Y axis.
hideCaption() → void
Hides the caption if it's already shown.
isRendered() bool
Check if the component is rendered at DOM or not.
inherited
lerp(num x, num x1, num x2, num y1, num y2) double
Linear interpolate x between two points (x1, y1) and (x2, y2).
inherited
loadEventHandlers() → void
Loads this component event handlers. Call super to check whether this component has been attached. If it hasn't, it will throw ComponentNotRenderedException.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onComponentAttached() → void
Called when this component has been attached to a parent RenderComponent.
inherited
queryByClass(String elemClass) → NodeList
Does elem.querySelectorAll(.elemClass) to select all element that have matched class.
inherited
queryById(String id) → Element?
Does elem.querySelector(#id) to select an element under this component.
inherited
redraw() → void
toString() String
Returns this component representation as HTML string that you can use inside other component's baseInnerHtml.
inherited
unloadEventHandlers() → void
Unloads this component event handlers. Call super to check whether this component has been attached. If it hasn't, it will throw ComponentNotRenderedException.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

svgViewBoxWidth → const int
The default SVG viewbox width. The SVG height will be calculated by width/aspectRatio.