gnssview/lib/sky/chart_page.dart
2024-12-02 10:57:26 +08:00

253 lines
9.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// import 'dart:math';
// import 'package:fl_chart/fl_chart.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// import '../../models/config/model.dart';
// import 'skyPlotView.dart';
// class ChartPage extends StatelessWidget {
// ChartPage({super.key, required this.controller});
// final SkyController controller;
// List<BarChartGroupData> checkSVData = [];
// int lastValue = -10;
// double maxY = 0;
// int maxX = 10;
// double xLength = 0;
// @override
// Widget build(BuildContext context) {
// checkSVData.length = 0;
// xLength = 0;
// List<SvItem> svData = List.from(controller.svData)
// ..sort((a, b) => a.sn.compareTo(b.sn));
// for (int i = 0; i < svData.length; i++) {
// SvItem item = svData[i];
// String sys = item.name;
// // int index = controller.sVTypes.indexWhere((item) => item == sys);
// LegendItem legendItem = controller.legend[sys];
// if (legendItem.show) {
// maxY = max(maxY, item.l1.toDouble());
// maxY = max(maxY, item.l2.toDouble());
// maxX = max(maxX, item.sn);
// checkSVData.add(makeGroupData(
// item.sn, item.l1.toDouble(), item.l2.toDouble(), legendItem.color));
// xLength++;
// }
// }
// if (checkSVData.isNotEmpty) {
// if (controller.startIndex.value < checkSVData.length - 15) {
// checkSVData = checkSVData.sublist(
// controller.startIndex.value, controller.startIndex.value + 15);
// } else {
// checkSVData = checkSVData.sublist(
// controller.startIndex.value, checkSVData.length - 1);
// }
// }
// final size = MediaQuery.of(context).size;
// final orientation =
// MediaQuery.of(context).orientation == Orientation.portrait;
// return Container(
// width: size.width,
// decoration: const BoxDecoration(color: Colors.white),
// child: AspectRatio(
// aspectRatio: 1,
// child: Padding(
// padding: const EdgeInsets.all(10),
// child: Stack(
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
// children: [
// Expanded(
// child: BarChart(
// BarChartData(
// maxY: maxY, // 提示需要+ 20 因为 提示是根据柱状图位置进行计算的
// barTouchData: BarTouchData(
// touchTooltipData: BarTouchTooltipData(
// // tooltipBgColor: Colors.blueGrey,
// getTooltipItem: (
// BarChartGroupData group,
// int groupIndex,
// BarChartRodData rod,
// int rodIndex,
// ) {
// return BarTooltipItem(
// 'L1:${group.barRods[0].toY}\nL2:${group.barRods[1].toY}',
// const TextStyle(
// fontWeight: FontWeight.bold,
// decoration: TextDecoration.none,
// color: Colors.black,
// fontSize: 18,
// shadows: [
// Shadow(
// color: Colors.black26,
// blurRadius: 12,
// )
// ],
// ),
// );
// },
// ),
// touchCallback: (event, response) {
// if (event.isInterestedForInteractions &&
// response != null &&
// response.spot != null) {
// // setState(() {
// // touchedGroupIndex =
// // response.spot!.touchedBarGroupIndex;
// // });
// } else {
// // setState(() {
// // touchedGroupIndex = -100;
// // });
// }
// },
// ),
// titlesData: FlTitlesData(
// show: true,
// rightTitles: AxisTitles(
// sideTitles: SideTitles(showTitles: false),
// ),
// topTitles: AxisTitles(
// sideTitles: SideTitles(showTitles: false),
// ),
// bottomTitles: AxisTitles(
// sideTitles: SideTitles(
// showTitles: true,
// getTitlesWidget: bottomTitles,
// reservedSize: 42,
// ),
// ),
// leftTitles: AxisTitles(
// sideTitles: SideTitles(
// showTitles: true,
// reservedSize: 28,
// interval: 1,
// getTitlesWidget: leftTitles,
// ),
// ),
// ),
// borderData: FlBorderData(
// show: false,
// ),
// barGroups: checkSVData,
// gridData: FlGridData(show: false),
// ),
// ),
// ),
// if (orientation)
// const SizedBox(
// height: 50,
// ),
// ],
// ),
// Positioned(
// bottom: 0,
// left: 0,
// right: 0,
// height: size.height,
// child: Opacity(
// opacity: 0, // 设置 Slider 组件的透明度为 0使其不可见
// child: Slider(
// value: controller.startIndex.toDouble(),
// onChanged: (newvalue) => controller.updateSlider(newvalue),
// min: 0,
// max: xLength <= 5 ? 0 : xLength - 5,
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// );
// }
// Widget leftTitles(double value, TitleMeta meta) {
// const style = TextStyle(
// color: Color(0xff7589a2),
// fontWeight: FontWeight.bold,
// fontSize: 14,
// decoration: TextDecoration.none);
// String text;
// int intValue = (value).ceil();
// if (intValue % 10 == 0 && intValue <= maxY) {
// text = intValue.toString();
// } else {
// return Container();
// }
// return SideTitleWidget(
// axisSide: meta.axisSide,
// space: 0,
// child: Text(text, style: style),
// );
// }
// Widget bottomTitles(double value, TitleMeta meta) {
// // if (lastValue == value) {
// // return SideTitleWidget(
// // axisSide: meta.axisSide,
// // space: 16, //margin top
// // child: const Text(''),
// // );
// // }
// String text = "";
// int intValue = (value).ceil();
// if (intValue != lastValue) {
// text = intValue.toString();
// }
// lastValue = intValue;
// return SideTitleWidget(
// axisSide: meta.axisSide,
// space: 16, //margin top
// child: Text(
// text.toString(),
// style: const TextStyle(
// color: Color(0xff7589a2),
// fontWeight: FontWeight.bold,
// decoration: TextDecoration.none,
// fontSize: 14,
// ),
// ),
// );
// }
// final double width = 20;
// final Color leftBarColor = const Color.fromARGB(95, 101, 98, 98);
// final Color rightBarColor = const Color.fromRGBO(33, 150, 243, 1);
// BarChartGroupData makeGroupData(int x, double y1, double y2,
// [Color color = const Color.fromRGBO(33, 150, 243, 1)]) {
// return BarChartGroupData(
// barsSpace: -width,
// x: x,
// showingTooltipIndicators: [],
// barRods: [
// BarChartRodData(
// toY: y1,
// color: Colors.white,
// borderSide: BorderSide(color: leftBarColor, width: 1),
// borderRadius: const BorderRadius.all(
// Radius.circular(2),
// ),
// width: width,
// ),
// BarChartRodData(
// toY: y2,
// color: color,
// borderRadius: const BorderRadius.all(
// Radius.circular(2),
// ),
// width: width,
// ),
// ],
// );
// }
// }