Is it possible to zoom vertical axis on Flutter Charts? - flutter

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.

Related

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 define minimum and maximum axis values in a flutter chart?

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
),

How can I ensure that labels align with GeoJSON

I have a very large map project which uses labels (and only labels from mapbox. That is, I don't get any boundaries or terrain from mapbox.)
I bring those vector tiles into Leaflet Using mapbox-gl-leaflet.
Generally, everything works great. However as soon as the map is taller than it is wide, the labels no longer align with the countries (which have been drawn as polygons using GeoJSON). Here is a pic of what happens and the relevant code is below.map with labels unaligned
map with labels not alignted
Any thoughts or insights would be helpful. Here is the code that brings in the tiles:
settings.globalVariables.labelTiles = L.mapboxGL({
accessToken: myAccessToken,
style: 'mapbox://styles/markslawton/ckgsqyzhi0diy19rwi98mlt4g',
pane: 'labels',
}).addTo(settings.globalVariables.map);
Here is the code that creates the map:
Window.map = settings.globalVariables.map = new L.map('map', {
zoomControl: false,
zoomDelta: settings.map.zoomDelta,
zoomSnap: settings.map.zoomSnap,
minZoom: settings.map.minZoom,
maxZoom: settings.map.maxZoom,
dragging: true,
trackResize: true,
attributionControl: false,
// maxBounds:[[-90,-180],[90,180]]
});
I'm not 100% sure, but I suspect the issue is with the north/south bounds of your map. Mapbox is constrained to the Web Mercator projection, which tops out at around 85º/-85º latitude. Judging from your image here, you are trying to show latitudes well north of there.
You probably need to constrain the bounds of your map with tighter bounds, or increase the minimum zoom, so this situation doesn't arise.

Leaflet disable vertical dragging out of bounds

Is it possible to only have vertical bounds in leaflet to remove grey bands above and below the leaflet map?
Grey bands around map
I still want to keep horizontal wrap but just want to remove the grey areas.
you can simply use the minZoom option, and set it to 3, that's what I do ;)
this.map.setView(new L.LatLng(31.585692323629303, 35.19333585601518), 2);
L.tileLayer(`https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png`, {
maxZoom: 20,
minZoom: 3,
attribution: 'HOT'
}).addTo(this.map);
in my case using angular, hope it help

How to draw border around the chart area in Google Charts?

I need a border around just the chart area and not the whole chart. I can't find what property to set. This is in the Google Visualization API.
The appropriate option is undocumented. You need to set the chartArea.backgroundColor.stroke and chartArea.backgroundColor.strokeWidth options. The stroke option controls the color of the border, and takes any valid HTML color string. The strokeWidth option controls the width of the border, and takes an integer for the width in pixels:
chartArea: {
backgroundColor: {
stroke: '#4322c0',
strokeWidth: 3
}
}