SfCartesianChart class
Renders the cartesian type chart
Widget build(BuildContext context) {
return Center(
child:SfCartesianChart(
title: ChartTitle(text: 'Flutter Chart'),
legend: Legend(isVisible: true),
series: getDefaultData(),
tooltipBehavior: TooltipBehavior(enable: true),
)
);
}
static List<LineSeries<SalesData, num>> getDefaultData() {
final dynamic chartData = <SalesData>[
SalesData(DateTime(2005, 0, 1), 'India', 1.5, 21, 28, 680, 760),
SalesData(DateTime(2006, 0, 1), 'China', 2.2, 24, 44, 550, 880),
SalesData(DateTime(2007, 0, 1), 'USA', 3.32, 36, 48, 440, 788),
SalesData(DateTime(2008, 0, 1), 'Japan', 4.56, 38, 50, 350, 560),
SalesData(DateTime(2009, 0, 1), 'Russia', 5.87, 54, 66, 444, 566),
SalesData(DateTime(2010, 0, 1), 'France', 6.8, 57, 78, 780, 650),
SalesData(DateTime(2011, 0, 1), 'Germany', 8.5, 70, 84, 450, 800)
];
return <LineSeries<SalesData, num>>[
LineSeries<SalesData, num>(
enableToolTip: isTooltipVisible,
dataSource: chartData,
xValueMapper: (SalesData sales, _) => sales.numeric,
yValueMapper: (SalesData sales, _) => sales.sales1,
width: lineWidth ?? 2,
enableAnimation: false,
markerSettings: MarkerSettings(
isVisible: isMarkerVisible,
height: markerWidth ?? 4,
width: markerHeight ?? 4,
shape: DataMarkerType.Circle,
borderWidth: 3,
borderColor: Colors.red),
dataLabelSettings: DataLabelSettings(
visible: isDataLabelVisible, position: CartesianLabelPosition.Auto)),
LineSeries<SalesData, num>(
enableToolTip: isTooltipVisible,
dataSource: chartData,
enableAnimation: false,
width: lineWidth ?? 2,
xValueMapper: (SalesData sales, _) => sales.numeric,
yValueMapper: (SalesData sales, _) => sales.sales2,
markerSettings: MarkerSettings(
isVisible: isMarkerVisible,
height: markerWidth ?? 4,
width: markerHeight ?? 4,
shape: DataMarkerType.Circle,
borderWidth: 3,
borderColor: Colors.black),
dataLabelSettings: DataLabelSettings(
isVisible: isDataLabelVisible, position: CartesianLabelPosition.Auto))
];
}
Constructors
-
SfCartesianChart({Key key, Color backgroundColor: Colors.transparent, bool enableSideBySideSeriesPlacement: true, Color borderColor: Colors.transparent, double borderWidth: 0, Color plotAreaBackgroundColor, Color plotAreaBorderColor: const Color.fromRGBO(219, 219, 219, 1), double plotAreaBorderWidth: 0.7, String plotAreaBackgroundImageUrl, ChartTooltipCallback onTooltipRender, ChartActualRangeChangedCallback onActualRangeChanged, ChartAxisLabelRenderCallback onAxisLabelRender, ChartDatalabelRenderCallback onDataLabelRender, ChartLegendRenderCallback onLegendItemRender, ChartTrackballCallback onTrackballPositionChanging, ChartCrosshairCallback onCrosshairPositionChanging, ChartZoomingCallback onZooming, ChartZoomingCallback onZoomStart, ChartZoomingCallback onZoomEnd, ChartZoomingCallback onZoomReset, ChartPointTapCallback onPointTapped, ChartAxisLabelTapCallback onAxisLabelTapped, ChartLegendTapCallback onLegendTapped, ChartSelectionCallback onSelectionChanged, bool isTransposed: false, List<
CartesianChartAnnotation> annotations, List<Color> palette: const[Color.fromRGBO(53, 92, 125, 1), Color.fromRGBO(192, 108, 132, 1), Color.fromRGBO(246, 114, 128, 1), Color.fromRGBO(248, 177, 149, 1), Color.fromRGBO(116, 180, 155, 1), Color.fromRGBO(0, 168, 181, 1), Color.fromRGBO(73, 76, 162, 1), Color.fromRGBO(255, 205, 96, 1), Color.fromRGBO(255, 240, 219, 1), Color.fromRGBO(238, 238, 238, 1)] , ChartAxis primaryXAxis, ChartAxis primaryYAxis, EdgeInsets margin, TooltipBehavior tooltipBehavior, ZoomPanBehavior zoomPanBehavior, Legend legend, SelectionType selectionType, ActivationMode selectionGesture, bool enableMultiSelection, CrosshairBehavior crosshairBehavior, TrackballBehavior trackballBehavior, dynamic series, List<IndexesModel> initialSelectedDataIndexes, ChartTitle title, List<ChartAxis> axes })
Properties
-
annotations
→ List<
CartesianChartAnnotation> -
Customizes the annotations. Annotations are used to mark the specific area of interest
in the plot area with texts, shapes, or images. [...]
final
-
axes
→ List<
ChartAxis> -
Customizes the additional axes in the chart. [...]
final
- backgroundColor → Color
-
Background color of the chart. [...]
final
- borderColor → Color
-
Color of the chart border. [...]
final
- borderWidth → double
-
Width of the chart border. [...]
final
- crosshairBehavior → CrosshairBehavior
-
Customizes the crosshair in chart. [...]
final
- enableMultiSelection → bool
-
Enables or disables the multiple data points or series selection. [...]
final
- enableSideBySideSeriesPlacement → bool
-
Enables or disables the placing of series side by side. [...]
final
-
initialSelectedDataIndexes
→ List<
IndexesModel> -
Data points or series can be selected while performing interaction on the chart.
It can also be selected at the initial rendering using this property. [...]
final
- isTransposed → bool
-
By setting this, the orientation of x-axis is set to vertical and orientation of
y-axis is set to horizontal. [...]
final
- legend → Legend
-
Customizes the legend in the chart. [...]
final
- margin → EdgeInsets
-
Margin for chart. [...]
final
- onActualRangeChanged → ChartActualRangeChangedCallback
-
Occurs when the visible range of an axis is changed, i.e. value changes for minimum,
maximum, and interval. Here, you can get the actual and visible range of an axis. [...]
final
- onAxisLabelRender → ChartAxisLabelRenderCallback
-
Occurs while rendering the axis labels. Text and text styles such as color, font size,
and font weight can be customized. [...]
final
- onAxisLabelTapped → ChartAxisLabelTapCallback
-
Occurs when tapping the axis label. Here, you can get the appropriate axis that is
tapped and the axis label text. [...]
final
- onCrosshairPositionChanging → ChartCrosshairCallback
-
Occurs when tapping the axis label. Here, you can get the appropriate axis that is
tapped and the axis label text. [...]
final
- onDataLabelRender → ChartDatalabelRenderCallback
-
Occurs when tapping the axis label. Here, you can get the appropriate axis that is
tapped and the axis label text. [...]
final
- onLegendItemRender → ChartLegendRenderCallback
-
Occurs when the legend item is rendered. Here, you can get the legend’s text,
shape, series index, and point index of circular series. [...]
final
- onLegendTapped → ChartLegendTapCallback
-
Occurs when the legend item is rendered. Here, you can get the legend’s text,
shape, series index, and point index of circular series. [...]
final
- onPointTapped → ChartPointTapCallback
-
Occurs when tapping the series point. Here, you can get the series, series index
and point index. [...]
final
- onSelectionChanged → ChartSelectionCallback
-
Occurs while selection changes. Here, you can get the series, selected color,
unselected color, selected border color, unselected border color, selected border
width, unselected border width, series index, and point index. [...]
final
- onTooltipRender → ChartTooltipCallback
-
Occurs while tooltip is rendered. You can customize the position and header.
Here, you can get the text, header, point index, series, x and y-positions. [...]
final
- onTrackballPositionChanging → ChartTrackballCallback
-
Occurs while the trackball position is changed. Here, you can customize the text of
the trackball. [...]
final
- onZoomEnd → ChartZoomingCallback
-
Occurs when the zooming action is completed. Here, you can get the axis, current
zoom factor, current zoom position, previous zoom factor, and previous zoom position. [...]
final
- onZooming → ChartZoomingCallback
-
Widget build(BuildContext context) { return Container( child: SfCartesianChart( zoomPanBehavior: ZoomPanBehavior(enableSelectionZooming: true), onZooming: (ZoomingArgs args) => zoom(args), )); } dynamic zoom(ZoomingArgs args) { print(args.currentZoomPosition); }
final - onZoomReset → ChartZoomingCallback
-
Occurs when zoomed state is reset. Here, you can get the axis, current zoom factor,
current zoom position, previous zoom factor, and previous zoom position. [...]
final
- onZoomStart → ChartZoomingCallback
-
Occurs when zooming action begins. You can customize the zoom factor and zoom
position of an axis. Here, you can get the axis, current zoom factor, current
zoom position, previous zoom factor, and previous zoom position. [...]
final
-
palette
→ List<
Color> -
Color palette for chart series. If the series color is not specified, then the series
will be rendered with appropriate palette color. Ten colors are available by default. [...]
final
- plotAreaBackgroundColor → Color
-
Background color of the plot area. [...]
final
- plotAreaBackgroundImageUrl → String
-
Background image for chart. [...]
final
- plotAreaBorderColor → Color
-
Border color of the plot area. [...]
final
- plotAreaBorderWidth → double
-
Border width of the plot area. [...]
final
- primaryXAxis → ChartAxis
-
Customizes the primary x-axis in chart. [...]
final
- primaryYAxis → ChartAxis
-
Customizes the primary y-axis in chart. [...]
final
- selectionGesture → ActivationMode
-
Gesture for activating the selection. Selection can be activated in tap,
double tap, and long press. [...]
final
- selectionType → SelectionType
-
Mode of selecting the data points or series. [...]
final
-
series
→ List<
ChartSeries> -
Customizes the series in chart. [...]
final
- title → ChartTitle
-
Customizes the chart title [...]
final
- tooltipBehavior → TooltipBehavior
-
Customizes the tooltip in chart. [...]
final
- trackballBehavior → TrackballBehavior
-
Customizes the trackball in chart. [...]
final
- zoomPanBehavior → ZoomPanBehavior
-
Customizes the zooming and panning settings. [...]
final
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- key → Key
-
Controls how one widget replaces another widget in the tree. [...]
final, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
createState(
) → State< StatefulWidget> - Creates the mutable state for this widget at a given location in the tree. [...]
-
createElement(
) → StatefulElement -
Creates a
StatefulElement
to manage this widget's location in the tree. [...]inherited -
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children. [...]@protected, inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node. [...]
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toDiagnosticsNode(
{String name, DiagnosticsTreeStyle style }) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep. [...]
inherited
-
toString(
{DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a string representation of this node and its descendants. [...]
inherited
-
toStringShallow(
{String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a one-line detailed description of the object. [...]
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited