-
-
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
Performance Issue with getTitles with large range between flSpots. #67
Comments
me too. |
Hi guys, I know your problem, but not sure what could we do, |
Hey Iman, Thanks for taking the time to respond. Unfortunately this would not be ideal in my case, which is that I wish to implement a PNL graph. Depending on the user (and their currencies), values can range in the 1000s or 10,000,000s. While I do understand that your current implementation of line charts does not support a large range in values, it may be something you wish to consider implementing in the future as this issue is bound to prop up for others. For example, any finance app that supports a low value currency that wishes to use your line chart will need it to support large range of values. Perhaps you could implement a way to set an interval between y-axis titles so that getTitles isn't called on every incremental integer? Do put the word out if you decide to work on it. Outside of that, thanks for all the work you've done on this package :). |
Your welcome, and it's my pleasure to read your text, |
You're welcome and thanks for your response! I have not tested it for the x-axis but but it looks to me like it would work the same way when getTitles() is called for titles of the x-axis too. I fear the same issue may result if the graph needs to plot points with a large range of x values as well. |
Ok, I will check it too, |
added interval field in the SideTitles class, fixed issue #67
Fixed problem in 0.3.1, you can now set the |
Hello,
I am having a similar issue to that described in #54.
For example, the following:
FlSpot(1,-1000000) ,
FlSpot(1, 1000000)],
minY = -1000000,
leads to 1,000,000+ calls to the function that getTitles in the FlTitlesData() widget points too. This results in my app becoming completely non-responsive for a while until all these calls have completed.
Here's the code for my line chart:
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
height: 18,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: SizedBox(
width: MediaQuery.of(context).size.width * .95,
height: MediaQuery.of(context).size.height * .8,
child: FlChart(
chart: LineChart(
LineChartData(
lineTouchData: const LineTouchData(enabled: false),
lineBarsData: [
LineChartBarData(
spots: getSpots(),
isCurved: false,
barWidth: 8,
colors: [
Colors.indigo,
],
belowBarData: BelowBarData(
show: true,
colors: [Colors.deepPurple.withOpacity(0.2)],
),
dotData: FlDotData(
show: false,
),
),
],
minY: widget.minY,
titlesData: FlTitlesData(
bottomTitles: SideTitles(
showTitles: true,
textStyle: TextStyle(
fontSize: 10,
color: Colors.purple,
fontWeight: FontWeight.bold),
getTitles: (value) {
return value.toStringAsFixed(0);
}),
leftTitles: SideTitles(
showTitles: true,
getTitles: (value) {
return getLeftTitle(value); //This function gets called 1,000,000+ times
},
),
),
),
),
),
),
),
],
);
Map<double, String> leftTileValues = {};
String getLeftTitle(double value) {
return widget.leftTileValues[value]; //it doesn't seem to matter what I do here, this function is called 1,000,000+ times.
}
Here, the getLeftListTile(value) function gets called 1,000,000 + times.
Since my FlSpots are created dynamically, and minY and maxY values are determined at runtime, I am not using a switch to return the titles as you do in the examples provided. Instead, I created a Map<double,String> with 10 entries that are spaced evenly between the range of FlSpots. In other words (maxY - minY).
Is there a better way for me to dynamically create 10 titles evenly spaced between a large range of values over the Y axis (set an interval for Y axis titles) or is this a bug?
The text was updated successfully, but these errors were encountered: