Skip to content

GChart

type: GDataSource
required: true

The data source for the chart. This is where the chart gets its data from.

type: GPointViewPort
required: false
default: GPointViewPort(autoScaleStrategy: const GPointViewPortAutoScaleStrategyLatest())

The viewport which controls the visible points range along the x axis on the chart.
The visible range of all panels, x axes and graphs are synchronized so there is only one instance.
Set to your own instance to customize its behavior.

type: GBackground
required: false
default: GBackground()

The background component which draws the background of the chart.
The default will draw a colored rectangle. extend the GBackground class to customize the background drawing.

type: GSplitter
required: false
default: GSplitter()

The splitter component which being used to resize panels. all panels share the same splitter instance.
Set to your own instance to customize.

type: GCrosshair
required: false
default: GCrosshair()

The crosshair component which draws crosshair lines on the chart when mouse is hovered over the chart area.
Set to your own instance to customize.

type: GPointerScrollMode
required: false
default: GPointerScrollMode.zoom

Defines the behavior of the chart when mouse wheel is scrolled over the chart area.
See the enum values for more details.

type: bool
required: false
default: true

This is for disable hit test on all components in the chart globally.
When it is set to true, whether a component can be hit by mouse events is determined by the component’s own hitTestMode property.
When it is set to false, the hitTestMode property of all components will be ignored.

type: Rect
required: false
default: const Rect.fromLTWH(0, 0, 500, 500)

This is for read only. the size of the chart area will be always calculated from size of parent GChartWidget widget.

type: Size
required: false
default: const Size(200, 200)

The minimum size of the chart area.

type: void Function(GChart chart, Canvas canvas, Rect area)
required: false
default: null

The pre-render callback which is called right before rendering.

type: void Function(GChart chart, Canvas canvas, Rect area)
required: false
default: null

The post-render callback which is called right after rendering.

values: none, zoom, move

void addPanel(GPanel panel)

Adds a panel to the chart.

void removePanel(GPanel panel)

Removes a panel from the chart.

Future<Image> saveAsImage()

Export the chart as an image.

void autoScaleViewports({
bool resetPointViewPort = true,
bool resetValueViewPort = true,
bool animation = true,
})

Reset the scale of the viewports use their own auto scale strategy.

(GPanel, GGraph, GOverlayMarker?)? hitTestPanelGraphs({
required Offset position,
})

Get hit test result of the panel graphs at the given position.
When it hits a graph, it will return the panel, graph with a null marker.
When it hits a marker, it will return the panel, graph and the marker.

void repaint({bool layout = true})

Redraw the chart. call this method when you updated the chart data or properties that requires a re-paint.