更新快检报告
This commit is contained in:
@@ -14,10 +14,12 @@
|
||||
// class QcTimeSeriesChart extends StatelessWidget {
|
||||
// final List<QcTimeSeriesPoint> dataPoints;
|
||||
// final double yMin;
|
||||
// final double yMax;
|
||||
// final double yMax; // 注意:这个值在使用时会自动加 padding
|
||||
// final int xSegmentCount;
|
||||
// final double? baseValue; // 基准值,可选
|
||||
// final String? baseLabel; // 基准值标签,可选
|
||||
// final double yAxisPadding; // Y轴顶部留白,默认为20
|
||||
// final double yAxisMargin; // Y轴上下边距,默认为2
|
||||
|
||||
// const QcTimeSeriesChart({
|
||||
// Key? key,
|
||||
@@ -27,16 +29,21 @@
|
||||
// this.xSegmentCount = 11,
|
||||
// this.baseValue,
|
||||
// this.baseLabel,
|
||||
// this.yAxisPadding = 20.0, // 默认为20
|
||||
// this.yAxisMargin = 2.0, // Y轴上下边距,默认为2
|
||||
// }) : super(key: key);
|
||||
|
||||
// // 添加一个 getter 来获取实际使用的 yMax(自动加 padding)
|
||||
// double get _actualYMax => yMax + yAxisPadding;
|
||||
|
||||
// int get _dataPointCount => dataPoints.length;
|
||||
|
||||
// List<double> _generateYAxisTicks() {
|
||||
// if (yMin >= yMax) {
|
||||
// if (yMin >= _actualYMax) {
|
||||
// return [0, 20, 40, 60, 80, 100];
|
||||
// }
|
||||
|
||||
// double step = (yMax - yMin) / 5;
|
||||
// double step = (_actualYMax - yMin) / 5;
|
||||
// List<double> ticks = [];
|
||||
|
||||
// for (int i = 0; i <= 5; i++) {
|
||||
@@ -114,7 +121,7 @@
|
||||
// Widget build(BuildContext context) {
|
||||
// // final yTicks = _generateYAxisTicks();
|
||||
// final double xMax = _dataPointCount.toDouble();
|
||||
// final double yRange = yMax - yMin;
|
||||
// final double yRange = _actualYMax - yMin;
|
||||
// final double yInterval = yRange > 0 ? yRange / 5 : 20.0;
|
||||
|
||||
// final tickIndices = _getTickIndices();
|
||||
@@ -229,8 +236,8 @@
|
||||
// LineChartData(
|
||||
// minX: 1,
|
||||
// maxX: xMax + 0.5,
|
||||
// minY: yMin - 2,
|
||||
// maxY: yMax + 2,
|
||||
// minY: yMin - yAxisMargin,
|
||||
// maxY: _actualYMax + yAxisMargin,
|
||||
// gridData: FlGridData(show: false),
|
||||
// extraLinesData: ExtraLinesData(
|
||||
// horizontalLines: horizontalLines,
|
||||
@@ -333,7 +340,7 @@
|
||||
// // 使用 Positioned 来绘制最大值和最小值的标签
|
||||
// if (minMaxData['minIndex'] != -1 || minMaxData['maxIndex'] != -1)
|
||||
// _buildMinMaxLabels(
|
||||
// context, constraints, minMaxData, xMax, yMin, yMax),
|
||||
// context, constraints, minMaxData, xMax, yMin, _actualYMax),
|
||||
// ],
|
||||
// );
|
||||
// },
|
||||
@@ -360,11 +367,11 @@
|
||||
// double chartHeight = constraints.maxHeight - topPadding - bottomPadding;
|
||||
|
||||
// // X轴范围:1 到 xMax
|
||||
// // Y轴范围:yMin - 2 到 yMax + 2
|
||||
// // Y轴范围:yMin - yAxisMargin 到 yMax + yAxisMargin
|
||||
// double xMin = 1;
|
||||
// double xMaxValue = xMax;
|
||||
// double yMinValue = yMin - 2;
|
||||
// double yMaxValue = yMax + 2;
|
||||
// double yMinValue = yMin - yAxisMargin;
|
||||
// double yMaxValue = yMax + yAxisMargin;
|
||||
|
||||
// double xRange = xMaxValue - xMin;
|
||||
// double yRange = yMaxValue - yMinValue;
|
||||
@@ -400,14 +407,12 @@
|
||||
// children: [
|
||||
// // SVG图片作为背景
|
||||
// SvgPicture.asset(
|
||||
// 'assets/img/icon/location.svg', // 替换为你的SVG图片路径
|
||||
// // width: 28.rpx,
|
||||
// // height: 40.rpx,
|
||||
// 'assets/img/icon/location.svg',
|
||||
// fit: BoxFit.contain,
|
||||
// color: stringToColor("#d69dd2"),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: EdgeInsets.only(bottom: 12.rpx), // 调整这个值来控制向上移动的距离
|
||||
// padding: EdgeInsets.only(bottom: 12.rpx),
|
||||
// child: Text(
|
||||
// '${minMaxData['minValue'].toStringAsFixed(0)}',
|
||||
// style: TextStyle(
|
||||
@@ -453,23 +458,12 @@
|
||||
// children: [
|
||||
// // SVG图片作为背景
|
||||
// SvgPicture.asset(
|
||||
// 'assets/img/icon/location.svg', // 替换为你的SVG图片路径
|
||||
// // width: 28.rpx,
|
||||
// // height: 40.rpx,
|
||||
// 'assets/img/icon/location.svg',
|
||||
// fit: BoxFit.contain,
|
||||
// color: stringToColor("#FF9F66"),
|
||||
// ),
|
||||
// // 文字覆盖在SVG上
|
||||
// // Text(
|
||||
// // '${minMaxData['maxValue'].toStringAsFixed(0)}',
|
||||
// // style: TextStyle(
|
||||
// // color: Colors.white,
|
||||
// // fontSize: AppConstants().smaller_text_fontSize,
|
||||
// // // fontWeight: FontWeight.bold,
|
||||
// // ),
|
||||
// // ),
|
||||
// Padding(
|
||||
// padding: EdgeInsets.only(bottom: 12.rpx), // 调整这个值来控制向上移动的距离
|
||||
// padding: EdgeInsets.only(bottom: 12.rpx),
|
||||
// child: Text(
|
||||
// '${minMaxData['maxValue'].toStringAsFixed(0)}',
|
||||
// style: TextStyle(
|
||||
@@ -512,6 +506,7 @@ class QcTimeSeriesChart extends StatelessWidget {
|
||||
final double? baseValue; // 基准值,可选
|
||||
final String? baseLabel; // 基准值标签,可选
|
||||
final double yAxisPadding; // Y轴顶部留白,默认为20
|
||||
final double yAxisMargin; // Y轴上下边距,默认为2
|
||||
|
||||
const QcTimeSeriesChart({
|
||||
Key? key,
|
||||
@@ -522,6 +517,7 @@ class QcTimeSeriesChart extends StatelessWidget {
|
||||
this.baseValue,
|
||||
this.baseLabel,
|
||||
this.yAxisPadding = 20.0, // 默认为20
|
||||
this.yAxisMargin = 2.0, // Y轴上下边距,默认为2
|
||||
}) : super(key: key);
|
||||
|
||||
// 添加一个 getter 来获取实际使用的 yMax(自动加 padding)
|
||||
@@ -618,6 +614,10 @@ class QcTimeSeriesChart extends StatelessWidget {
|
||||
final tickIndices = _getTickIndices();
|
||||
final minMaxData = _findMinMax();
|
||||
|
||||
// 计算实际显示的Y轴范围
|
||||
final double actualMinY = yMin - yAxisMargin;
|
||||
final double actualMaxY = _actualYMax + yAxisMargin;
|
||||
|
||||
// 将数据点分割成多个连续段
|
||||
List<List<FlSpot>> lineSegments = [];
|
||||
List<FlSpot> currentSegment = [];
|
||||
@@ -727,8 +727,8 @@ class QcTimeSeriesChart extends StatelessWidget {
|
||||
LineChartData(
|
||||
minX: 1,
|
||||
maxX: xMax + 0.5,
|
||||
minY: yMin - 2,
|
||||
maxY: _actualYMax + 2,
|
||||
minY: actualMinY,
|
||||
maxY: actualMaxY,
|
||||
gridData: FlGridData(show: false),
|
||||
extraLinesData: ExtraLinesData(
|
||||
horizontalLines: horizontalLines,
|
||||
@@ -776,6 +776,19 @@ class QcTimeSeriesChart extends StatelessWidget {
|
||||
reservedSize: 60.rpx,
|
||||
interval: yInterval,
|
||||
getTitlesWidget: (value, meta) {
|
||||
// 不显示最小值和最大值
|
||||
// 判断是否是实际显示范围的最小值或最大值
|
||||
if (value == actualMinY || value == actualMaxY) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
// 检查值是否为整数(避免显示小数)
|
||||
double roundedValue = value.roundToDouble();
|
||||
if ((value - roundedValue).abs() > 0.01) {
|
||||
// 如果不是整数,不显示
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: Text(
|
||||
@@ -858,11 +871,11 @@ class QcTimeSeriesChart extends StatelessWidget {
|
||||
double chartHeight = constraints.maxHeight - topPadding - bottomPadding;
|
||||
|
||||
// X轴范围:1 到 xMax
|
||||
// Y轴范围:yMin - 2 到 yMax + 2
|
||||
// Y轴范围:yMin - yAxisMargin 到 yMax + yAxisMargin
|
||||
double xMin = 1;
|
||||
double xMaxValue = xMax;
|
||||
double yMinValue = yMin - 2;
|
||||
double yMaxValue = yMax + 2;
|
||||
double yMinValue = yMin - yAxisMargin;
|
||||
double yMaxValue = yMax + yAxisMargin;
|
||||
|
||||
double xRange = xMaxValue - xMin;
|
||||
double yRange = yMaxValue - yMinValue;
|
||||
|
||||
Reference in New Issue
Block a user