syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.55k stars 756 forks source link

Label is unstanble #1997

Closed tuceturan closed 2 weeks ago

tuceturan commented 1 month ago

Bug description

In the TabView inside charts, labels are unstable. When switching between pages, the x-axis sometimes disappears and sometimes reappears. Can you help

Steps to reproduce

1-I used tab controler is not changed 2-When click tab ı use setstate is not change

Code sample

Scaffold( appBar: AppBar( // excludeHeaderSemantics: true, toolbarHeight: 3, backgroundColor: Color(0xFF007ACF), automaticallyImplyLeading: false, bottom: PreferredSize( preferredSize: Size.fromHeight(45), child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [ TabBar( onTap: (int index) { setState(() { _currentIndex = index; _showLogScale = true; }); _psdHelper.resetRangeControllers(); }, indicator: const UnderlineTabIndicator( borderSide: BorderSide(width: 5.0, color: Colors.white), ), unselectedLabelColor: Colors.black, // / labelColor: Colors.blue, indicatorColor: Colors.transparent, indicatorWeight: 0.1, isScrollable: true, tabs: _psdHelper.getTabs([ TranslateLanguage.of(context)!.trans("learn_psd"), TranslateLanguage.of(context)!.trans("hf_psd"), TranslateLanguage.of(context)!.trans("hr_psd"), ])), ]), ), flexibleSpace: InkWell( child: Container( margin: EdgeInsets.only(left: (langCode == "es") ? 543 : 480), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: (_currentIndex == 0) ? setZoomSelector( context, _psdHelper.rangeControllerLearn, _psdHelper.zoomPanLearn, _psdHelper.iLearn) : (_currentIndex == 1) ? setZoomSelector( context, _psdHelper.rangeControllerHf, _psdHelper.zoomPanHf, _psdHelper.iHf) : setZoomSelector( context, _psdHelper.rangeControllerHr, _psdHelper.zoomPanHr, _psdHelper.iHr))), ), ), body: TabBarView( physics: const NeverScrollableScrollPhysics(), children: _psdHelper.getCardViewSamples([ Column(children: [ Container( height: 545, margin: EdgeInsets.only( left: 5, ), child: _buildSplineLearnAreaChart()), _setRangeSlider(0) ]), Column( children: [ Container(height: 545, child: _buildSplineChart()),

                ],
              ),
              Column(
                children: [
                  Container(
                      height: 545, child: _buildSplineChart(isHf: false)),
                  _setRangeSlider(2)
                ],
              ),
            ])),
      )

        SfCartesianChart _buildSplineChart({bool isHf = true}) {
List<double?> _seriesMinMax = _psdHelper.calculateHighPsdMaxMin(
    _showLogScale!, isHf, widget.amtReport!.highFrequencyResolutionPsd);

RangeController rangeControllerHighPsd =
    (isHf) ? _psdHelper.rangeControllerHf! : _psdHelper.rangeControllerHr!;
int fftLength = _psdHelper.calculateLengthHighPsd(
    widget.amtReport!.amtTest!.minsstime!,
    widget.amtReport!.amtTest!.subSamplingIndex!,
    isHf: isHf);
double freqMult =
    5000 / (widget.amtReport!.amtTest!.subSamplingIndex! + 1) / fftLength;

if (!isHf)
  freqMult = (1250 / (widget.amtReport!.amtTest!.subSamplingIndex! + 1.0)) /
      (fftLength);
TrackballBehavior _trackball = TrackballBehavior(
    enable: true,
    markerSettings: TrackballMarkerSettings(
      markerVisibility: TrackballVisibilityMode.visible,
      height: 10,
      width: 10,
      borderWidth: 1,
    ),
    hideDelay: 2.0 * 1000,
    activationMode: ActivationMode.singleTap,
    tooltipAlignment: ChartAlignment.center,
    tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
    tooltipSettings: InteractiveTooltip(canShowMarker: true),
    shouldAlwaysShow: true,
    builder: (BuildContext context, TrackballDetails trackballDetails) {
      return Padding(
          padding: EdgeInsets.zero,
          child: Container(
              alignment: Alignment.topRight,
              height: 120,
              width: (langCode == "es") ? 370 : 330,
              margin: EdgeInsets.only(
                  left: (langCode == "es")
                      ? MediaQuery.of(context).size.width - 500
                      : MediaQuery.of(context).size.width - 400,
                  bottom: 250),
              decoration: BoxDecoration(
                color:
                    const Color.fromRGBO(57, 86, 134, 0.7490196078431373),
                borderRadius: const BorderRadius.all(Radius.circular(6.0)),
              ),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Padding(
                        padding: const EdgeInsets.fromLTRB(5, 5, 0, 0),
                        child: Center(
                            child:
                                _psdHelper.getGroupingTemplateWidgetsHfHr(
                                    trackballDetails,
                                    isHf: isHf)))
                  ])));
    });
return SfCartesianChart(
  // key: (isHf) ? widget.hFKey : widget.hRKey,
  zoomPanBehavior: (isHf) ? _psdHelper.zoomPanHf : _psdHelper.zoomPanHr,
  onZoomEnd: (_zoomPanHf) {
    if (isHf)
      _psdHelper.iHf = 0;
    else
      _psdHelper.iHr = 0;
  },
  trackballBehavior: _trackball,
  primaryXAxis: NumericAxis(
      majorGridLines: const MajorGridLines(width: 0),
      minimum: 0,
      maximum: fftLength * freqMult,
      visibleMinimum: double.parse(rangeControllerHighPsd.start.toString()),
      visibleMaximum: double.parse(rangeControllerHighPsd.end.toString()),
      enableAutoIntervalOnZooming: true,
      interval: (rangeControllerHighPsd.end < 501)
          ? _psdHelper.maxFreq
          : (rangeControllerHighPsd.end < 1001)
              ? _psdHelper.maxFreq! * 4
              : _psdHelper.maxFreq! * 10,
      rangePadding: ChartRangePadding.round,
      decimalPlaces: 0,
      plotBands: plotBands(freqMult),
      rangeController: (isHf)
          ? _psdHelper.rangeControllerHf
          : _psdHelper.rangeControllerHr),
  primaryYAxis: NumericAxis(
      labelFormat: '{value}',
      minimum: _seriesMinMax[0],
      // maximum: _seriesMinMax[1] + 0.5 * _seriesMinMax[1],
      axisLabelFormatter: (AxisLabelRenderDetails args) {
        String txt = "";
        int index = (isHf) ? _psdHelper.iHf : _psdHelper.iHr;
        switch (index) {
          case 0: //D-phase mean
            txt = "0";
            break;
          case 1: //D-phase mean
            txt = "1E-05";
            break;
          case 4: //D-phase mean
            txt = "0.0001";
            break;
          case 7: //D-phase mean
            txt = "0.001";
            break;
          case 10: //D-phase mean
            txt = "0.01";
            break;
          default:
            txt = "";
            break;
        }
        if (isHf)
          _psdHelper.iHf++;
        else
          _psdHelper.iHr++;
        return ChartAxisLabel(
            txt, TextStyle(color: const Color.fromRGBO(104, 104, 104, 1)));
      },
      majorTickLines: const MajorTickLines(size: 0)),
  series: _setSeriesHfHr(isHf: isHf),
  tooltipBehavior: TooltipBehavior(
    enable: true,
    header: '',
    canShowMarker: false,
  ),
);

}

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Screenshot_20240726-165946 1 Screenshot_20240726-170009 1

Stack Traces

not stable labels

On which target platforms have you observed this bug?

Android

Flutter Doctor output

Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.22631.3880], locale tr-TR) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [X] Visual Studio - develop Windows apps X Visual Studio not installed; this is necessary to develop Windows apps. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2023.1) [√] Connected device (4 available) [√] Network resources

ghost commented 1 month ago

Hi @tuceturan,

We have checked the reported issue and tried to replicate it in SfCartesianChart with old chart version 23.2.7 and in latest chart version 26.2.5+1 by setting the primaryYAxis as NumericAxis. We have tested the following scenarios, and it was working fine at our end.

However, we were unable to reproduce the reported issue at our end. We kindly request you replicate the reported issue in the sample attached below and provide us with more details regarding the specific scenario in which you encounter with a screen recording. This will help us to assist you more effectively.

Regards, Lokesh P.

tabbar_view.zip

tuceturan commented 1 month ago

Thank you for reply I'm using 21.1.41 version The problem has that version?

ghost commented 1 month ago

Hi @tuceturan,

We have also checked with the specified chart version 21.1.41, but we were unable to reproduce the reported issue. We kindly request that you share more details in which scenario the mentioned issue was occurred. To assist you further, we kindly request that you replicate the reported issue in the sample attached below and provide us with more details, including a screen recording of the specific scenario in which you encountered the issue.

Regards, Lokesh P.

y_axis_label_disappear.zip