Hi,
I have been trying to make a graph that tracks users progress over time. Part of the requirements for this graph is that a user can zoom in to a scale of a week a month 6 months or a year. Users also need to be able to pan through and pinch to zoom.
My first problem is I want to start with a week view, and then zoom out to month view etc if a user presses a button. To do this, I set visible minimum and visible maximum to be a week long. When I do that however, the graph only loads up to the last point within the currently viewable area. This means that the line stops early on the graph and doesn't reach the left boundary. When clicking on the button to cycle through timescales, this makes it very disorientating for the user, and it is difficult to understand.
The next problem is that once the user has zoomed by pinch or panned through, I am no longer able to change the visible range by changing the visibleMinimum and visibleMaximum values.
Is there a way of implementing these features? I have tried using zoomToSingleAxis along with panToDirection, but neither of these fit my use case.
Here is the code for the graph in my app:
SfCartesianChart(
primaryYAxis: NumericAxis(
majorGridLines: MajorGridLines(
dashArray: [20, 10], width: 3),
minimum: 0.0,
maximum: 11.0),
zoomPanBehavior: ZoomPanBehavior(
enablePinching: true,
enablePanning: true,
zoomMode: ZoomMode.x),
primaryXAxis: xAxis,
series: <ChartSeries>[
SplineSeries<GraphObject, DateTime>(
dataSource: state.dataList1,
xValueMapper: (GraphObject graphObject, _) =>
graphObject.xAxis,
yValueMapper: (GraphObject graphObject, _) =>
graphObject.yAxis.toDouble(),
splineType: SplineType.monotonic,
),
SplineSeries<GraphObject, DateTime>(
color: Colors.red,
dataSource: state.dataList2,
splineType: SplineType.monotonic,
xValueMapper: (GraphObject graphObject, _) =>
graphObject.xAxis,
yValueMapper: (GraphObject graphObject, _) =>
graphObject.yAxis,
),
])
Attachment:
app_examples_47020a81.zip