ChartPainter constructor

ChartPainter(
  1. ChartStyle chartStyle,
  2. ChartColors chartColors, {
  3. required List<TrendLine> lines,
  4. required bool isTrendLine,
  5. required double selectY,
  6. DrawingToolManager? drawingToolManager,
  7. required dynamic datas,
  8. required dynamic scaleX,
  9. required dynamic scrollX,
  10. required dynamic isLongPass,
  11. required dynamic selectX,
  12. required dynamic xFrontPadding,
  13. dynamic isOnTap,
  14. dynamic isTapShowInfoDialog,
  15. required VerticalTextAlignment verticalTextAlignment,
  16. dynamic mainState,
  17. dynamic volHidden,
  18. dynamic secondaryState,
  19. StreamSink<InfoWindowEntity?>? sink,
  20. bool isLine = false,
  21. bool hideGrid = false,
  22. bool showNowPrice = true,
  23. int fixedLength = 2,
  24. List<int> maDayList = const [5, 10, 20],
  25. bool shouldShowCrossLine = false,
  26. dynamic onCrossLineTap(
    1. double
    )?,
})

Implementation

ChartPainter(
  this.chartStyle,
  this.chartColors, {
  required this.lines, //For TrendLine (保留兼容性)
  required this.isTrendLine, //For TrendLine (保留兼容性)
  required this.selectY, //For TrendLine (保留兼容性)
  this.drawingToolManager, // 新增绘图工具管理器
  required datas,
  required scaleX,
  required scrollX,
  required isLongPass,
  required selectX,
  required xFrontPadding,
  isOnTap,
  isTapShowInfoDialog,
  required this.verticalTextAlignment,
  mainState,
  volHidden,
  secondaryState,
  this.sink,
  bool isLine = false,
  this.hideGrid = false,
  this.showNowPrice = true,
  this.fixedLength = 2,
  this.maDayList = const [5, 10, 20],
  this.shouldShowCrossLine = false, // 新增:是否显示十字线
  Function(double)? onCrossLineTap, // 新增:十字线点击回调
}) : super(
        chartStyle,
        datas: datas,
        scaleX: scaleX,
        scrollX: scrollX,
        isLongPress: isLongPass,
        isOnTap: isOnTap,
        isTapShowInfoDialog: isTapShowInfoDialog,
        selectX: selectX,
        mainState: mainState,
        volHidden: volHidden,
        secondaryState: secondaryState,
        xFrontPadding: xFrontPadding,
        isLine: isLine,
        shouldShowCrossLine: shouldShowCrossLine, // 传递十字线显示状态
        onCrossLineTap: onCrossLineTap, // 传递十字线点击回调
      ) {
  selectPointPaint = Paint()
    ..isAntiAlias = true
    ..strokeWidth = 0.5
    ..color = this.chartColors.selectFillColor;
  selectorBorderPaint = Paint()
    ..isAntiAlias = true
    ..strokeWidth = 0.5
    ..style = PaintingStyle.stroke
    ..color = this.chartColors.selectBorderColor;
  nowPricePaint = Paint()
    ..strokeWidth = this.chartStyle.nowPriceLineWidth
    ..isAntiAlias = true;
}