-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problems with tick step values on X axis #1267
Comments
Please check your description. Your reproducible code is not formatted correctly. |
@imaNNeo Hello, I'm also facing the same problem. This is the reproducible code: import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
class ScatterChartSample extends StatelessWidget {
const ScatterChartSample({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Scatter Chart Sample"),
),
body: ScatterChart(
ScatterChartData(
scatterSpots: [
ScatterSpot(0.00001, 0.09, radius: 6),
ScatterSpot(0.00002, 0.0800005, radius: 6),
ScatterSpot(0.00001, 0.0745675, radius: 6),
ScatterSpot(0.00007, 0.036897, radius: 6),
],
minX: 0,
maxX: 0.0001,
minY: 0,
maxY: 0.1,
),
),
);
}
}
void main() => runApp(const MaterialApp(home: ScatterChartSample())); |
I think it's not a bug but by design. I found the following line to accept only 1 decimal place: fl_chart/lib/src/utils/utils.dart Line 240 in 5d81d61
Would be great if it accepts more decimal places. |
Thank you @mai-nakagawa |
Fixed in 0.64.0 |
I am having problem setting tick step for 0.05 in X axis in LineChart. Tick step is displayed 0.1. Value which should be 0.05 displayed as 0.1.
My code:
`// Automatic FlutterFlow imports
import '../../flutter_flow/flutter_flow_theme.dart';
import '../../flutter_flow/flutter_flow_util.dart';
import '../widgets/index.dart'; // Imports other custom widgets
import '../actions/index.dart'; // Imports custom actions
import '../../flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:fl_chart/fl_chart.dart';
class MyData {
final double x;
final double y;
MyData(this.x, this.y);
}
class LinearGraphWidget extends StatefulWidget {
const LinearGraphWidget({
Key? key,
this.width,
this.height,
required this.duomenys,
required this.name,
}) : super(key: key);
final double? width;
final double? height;
final List duomenys;
final String name;
@OverRide
_LinearGraphWidgetState createState() => _LinearGraphWidgetState();
}
class _LinearGraphWidgetState extends State {
duomenu_konvertavimas(){
double force;
double displacement;
List data=[];
for (int i = 0; i < widget.duomenys.length; i++) {
displacement = double.parse(widget.duomenys[i]['displacement']);
force = double.parse(widget.duomenys[i]['force']);
data.add(FlSpot(force,displacement));
}
return data;
}
Widget topTitleWidgets(double value, TitleMeta meta) {
if (value % 1 != 0) {
return Container();
}
const style = TextStyle(
fontSize: 8,
);
return SideTitleWidget(
axisSide: meta.axisSide,
child: Text(value.toDouble().toString(), style: style),
);
}
Widget rightTitleWidgets(double value, TitleMeta meta) {
final style = TextStyle(
}
Widget leftTitleWidgets(double value, TitleMeta meta) {
final style = TextStyle(
}
@OverRide
Widget build(BuildContext context){
return AspectRatio(
aspectRatio: 1.5,
child: LineChart(
LineChartData(
minX: 0,
maxX: 0.5,
minY: 0,
maxY: 6,
lineBarsData: [
LineChartBarData(
// spots: duomenu_konvertavimas(),
isCurved: false,
spots: reverseSpots(duomenu_konvertavimas(), 0, 6),
barWidth: 1,
dotData: FlDotData(
show: true,
getDotPainter: (spot, percent, barData, index) =>
FlDotCirclePainter(
radius: 1,
color: Colors.transparent,
}
}
double reverseY(double y, double minX, double maxX) {
return (maxX + minX) - y;
}
List reverseSpots(List inputSpots, double minY, double maxY) {
return inputSpots.map((spot) {
return spot.copyWith(y: (maxY + minY) - spot.y);
}).toList();
}
`
The text was updated successfully, but these errors were encountered: