How to define minimum and maximum axis values in a flutter chart? - flutter

I have a bubble chart (ScatterPlotChart) like the one below and I would like to change the values 0 on the x-axis and 0 on the y-axis to another value. I would like to change maximum values too.
I've been going through the documentation and examples that appear at Flutter Gallery Charts but I can't find how to change these values.
I'm using charts_flutter (as charts) and the code where I define the ticks of the axes is as follows:
charts.ScatterPlotChart (
seriesList,
primaryMeasureAxis: charts.NumericAxisSpec (
tickProviderSpec: new charts.BasicNumericTickProviderSpec (desiredMaxTickCount: 2,),
),
domainAxis: charts.NumericAxisSpec (
tickProviderSpec: new charts.BasicNumericTickProviderSpec (desiredTickCount: 2,),
),
...
Is it possible to change the minimum and maximum values of the x and y axes in flutter graphs?

You need to add zeroBound: false on the BasicNumericTickProviderSpec. Something like:
tickProviderSpec: new charts.BasicNumericTickProviderSpec(
desiredTickCount: 2,
zeroBound: false
),

Related

show multiple axis to highcharts chart and present axis to left

Trying to create a chart as show below
Tried to get most of it working fiddle is in
https://jsfiddle.net/BlackLabel/j1pz28y3/
But only axis is the issue. Unable to get multiple axis for different chart and also axis on the left rather than right please help me by pointing to some demo
You need to set yAxis.opposite to false. Your image shows only two axis (first one for the line and flag series, the second one for the column), so here is the example config basing on the image:
yAxis: [{
opposite: false,
height: '60%'
}, {
opposite: false,
top: '65%',
height: '40%',
offset: 0
}],
Demo:
https://jsfiddle.net/BlackLabel/at8Lyod4/
API Reference:
https://api.highcharts.com/highstock/yAxis.opposite

Flutter SfCharts label padding

How can I add padding to the labels, or position them further away from the plotting area? It currently looks like this, but I want to increase the red space:
I am using the SfCartesianChart from the flutter_syncfusion_charts package.
I suggest you use the majorTickLines property in the axis, using this you can achieve your requirement by setting the size of the tick and setting the color as transparent. I have attached the code snippet below for your reference.
Code snippet:
primaryYAxis: NumericAxis(
majorTickLines:
const MajorTickLines(size: 15, color: Colors.transparent)),
UG: https://help.syncfusion.com/flutter/cartesian-charts/axis-customization#tick-lines-customization

How to get the FlSpot touched in fl_charts

I have a LineChart where the default behaviour is that a tooltip with the y value shows up when you touch the chart.
How would i be able to get the x and y values of the point touched on the chart to save it in a variable for example.
It has to be in this property of the LineChart:
lineTouchData: LineTouchData(enabled: true),

Is it possible to zoom vertical axis on Flutter Charts?

I am trying to familiarize with charts in Flutter, using github.com/google/charts package.
I want to make a chart (bar, line, scatter or any other.. this, for example) where I can zoom and pan not only the x-axis, but also the vertical y-axis (abscissa).
The zoom in x-axis is working adding the behavior behaviors: [new charts.PanAndZoomBehavior(),] :
#override
Widget build(BuildContext context) {
return new charts.BarChart(
seriesList,
animate: animate,
behaviors: [new charts.PanAndZoomBehavior(),
],
domainAxis: new charts.OrdinalAxisSpec(
viewport: new charts.OrdinalViewport('2018', 4)),
);
}
the x-axis zoom is not centered, as asked in this question, but it's ok to me.
A first step would be disable the auto-fit of the vertical axis is adjusting the range between 0 and the max value of the data that appear in that moment in the chart.
Any idea how to enable zoom gesture on the y-axis or at least disable the auto-fit of y-axis (fix the range of y-axis)?
It is quite similar to what you did in domainAxis.
You could just add an axisSpec to the primaryMeasureAxis (y-axis).
like this,
primaryMeasureAxis: charts.NumericAxisSpec(
viewport: charts.NumericExtents(4, 8)),
But this doesn't work properly in bar charts.
As of my experience, the bar chart will go below the x-axis. It hasn't be fixed yet.
It works well with line chart though.

Google Scatter Charts, Different Point Size

I am using Google Scatter Chart APIs to try to plot a punch card chart like the one Github has. I don't know how to change the marker size of each point shown. Is it possible in this API?
Yes, this is possible, though not if using the new Material Design scatter plot (created with new google.charts.Scatter()). If using the normal Scatter Plot though (created with new google.visualization.ScatterChart()), you do this by passing a style parameter for each point along with your data.
So for instance, if each point is usually defined [x, y], instead you would define it as [x, y, point_style].
An example of point_style would be 'point { size: 12; shape-type: circle; fill-color: #FFFFFF; color: #CCCCCC }';
Thus a sample data point would be [10, 5, 'point { size: 12; shape-type: circle; fill-color: #FFFFFF; color: #CCCCCC }']
Finally, you need to make sure you've added a style column to your set of data columns, like so:
var data = new google.visualization.DataTable();
data.addColumn('number', x_axis_title);
data.addColumn('number', y_axis_title);
data.addColumn( {'type': 'string', 'role': 'style'} ); // Defines point style
If you've done these things --- added a style data column and defined a style for each individual point --- then your custom styles will appear on the chart.
You can also define a pointSize and pointShape in the graph's options if you want to set them for all points at once, but you can't define individual points that way, so the above method is better if you want more granular control.