bezier-chart
bezier-chart copied to clipboard
y value not correctly shown compared to y axis labels
Please see the screenshot below:
As you can see, the first data point has value of 44.5, which is exactly the middle between 44 and 45, hence AB should equal BC. As seen on the screenshot however this is not the case.
Below is the code you can use to reproduce it. I use the master
branch right from the github:
Widget sample3(BuildContext context) {
final fromDate = DateTime(2019, 08, 1);
final toDate = DateTime.now();
final date1 = DateTime.now().subtract(Duration(days: 2));
final date2 = DateTime.now().subtract(Duration(days: 3));
return Center(
child: Container(
color: Colors.red,
//height: MediaQuery.of(context).size.height / 2,
//width: MediaQuery.of(context).size.width,
child: BezierChart(
fromDate: fromDate,
bezierChartScale: BezierChartScale.WEEKLY,
toDate: toDate,
onIndicatorVisible: (val) {
print("Indicator Visible :$val");
},
onDateTimeSelected: (datetime) {
print("selected datetime: $datetime");
},
selectedDate: toDate,
//this is optional
footerDateTimeBuilder: (DateTime value, BezierChartScale scaleType) {
final newFormat = intl.DateFormat('dd/MMM', "bg_BG");
return newFormat.format(value);
},
bubbleLabelDateTimeBuilder:
(DateTime value, BezierChartScale scaleType) {
final newFormat = intl.DateFormat('EEE d', "bg_BG");
return "${newFormat.format(value)}\n";
},
series: [
BezierLine(
label: "Duty",
onMissingValue: (dateTime) {
return 44.5;
},
data: [
DataPoint<DateTime>(value: 44.5, xAxis: fromDate),
DataPoint<DateTime>(value: 40, xAxis: date1),
DataPoint<DateTime>(value: 43.5, xAxis: date2),
],
),
],
config: BezierChartConfig(
displayDataPointWhenNoValue: false,
verticalIndicatorStrokeWidth: 3.0,
pinchZoom: false,
verticalIndicatorColor: Colors.black26,
showVerticalIndicator: true,
verticalIndicatorFixedPosition: false,
backgroundColor: Colors.red,
displayYAxis: true,
stepsYAxis: 1,
),
), // bc
),
);
}
I am having this issue too, see that the 0 is below the x line, will this be fixed or is there any workaround to fix this?
Any sample code reproduce the issue?
On Mon, Apr 6, 2020, 3:58 AM Allyanora [email protected] wrote:
I am having this issue too, will this be fixed or is there any workaround to fix this?
https://user-images.githubusercontent.com/907444/78247990-7e6aeb80-74f4-11ea-9d59-2055d49d8b4d.jpg
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/aeyrium/bezier-chart/issues/44#issuecomment-609665496, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFL3UGANF4GJ3GXZVMZ5OTRLGKR5ANCNFSM4IMXDPZQ .
I only changed a bit the code from Sample 6 from the example.
- I displayed only one of the charts instead of two on the page.
- Increased the height:
child: Container(
color: Colors.red,
height: MediaQuery.of(context).size.height - 200,
width: MediaQuery.of(context).size.width,
- and from the _buildChart function I displayed the y axis from BezierChartConfig config , and returned 0 from the onMissing value function. (and I changed the data array a bit)
BezierLine(
label: "Flight",
lineColor: Colors.black26,
onMissingValue: (dateTime) {
return 0;
},
data: [
DataPoint<DateTime>(value: 0, xAxis: date1),
DataPoint<DateTime>(value: 3, xAxis: date2),
DataPoint<DateTime>(value: 4, xAxis: date5),
DataPoint<DateTime>(value: 5, xAxis: date6),
],
),
],
config: BezierChartConfig(
displayYAxis: true,
verticalIndicatorStrokeWidth: 3.0,
verticalIndicatorColor: Colors.black26,
showVerticalIndicator: true,
verticalIndicatorFixedPosition: false,
backgroundGradient: gradient,
footerHeight: 35.0,
),