When i label the axes of line series chart then tooltip feature doesnt work and throws an error
































If i use the code below then flutter throws this error 


Container(
          color: Colors.black,
          alignment: Alignment.center,
          height: 500,
          width: MediaQuery.of(context).size.width,
          child: ClipRRect(
            borderRadius: BorderRadius.circular(40),
            child: data.isLoading?Center(child: CircularProgressIndicator(),): SfCartesianChart(
                title: ChartTitle(
                    text: 'Cases Over Time:',
                    textStyle: ChartTextStyle(
                        color: Colors.white,
                        fontFamily: 'CM',
                        fontSize: 20,
                        fontWeight: FontWeight.bold)),
                backgroundColor: Color.fromRGBO(3535351),
                zoomPanBehavior: ZoomPanBehavior(
                    enablePinching: true),
                /*     primaryXAxis: CategoryAxis(
                    majorGridLines: MajorGridLines(color: Colors.white),
                  ), */
                  primaryXAxis: CategoryAxis(
                    title: AxisTitle(
                        text: 'Dates-',
                        textStyle: ChartTextStyle(
                            color: Colors.deepOrange,
                            fontFamily: 'CM',
                            fontStyle: FontStyle.italic,
                            fontWeight: FontWeight.w300)) ),
               
                  primaryYAxis: CategoryAxis(
                    title: AxisTitle(
                        text: 'Cases-',
                        textStyle: ChartTextStyle(
                            color: Colors.deepOrange,
                            fontFamily: 'CM',
                            fontStyle: FontStyle.italic,
                            fontWeight: FontWeight.w300)) ),
                plotAreaBorderColor: Colors.amber,
                plotAreaBackgroundColor: Colors.grey,
                borderWidth: 10,
                tooltipBehavior: TooltipBehavior(enable: true,

                ),
              margin: EdgeInsets.fromLTRB(00400),
                palette: <Color>[Colors.amber, Colors.red, Colors.green],
                legend: Legend(isVisible: true,overflowMode: LegendItemOverflowMode.wrap,),
                series: <LineSeries<TimeDataString>>[
                  LineSeries<TimeDataString>(
                    
                    enableTooltip: true,
                      name: 'Confirmed cases',
                      dataSource: <TimeData>[...data.confirmedcasesTimeItems],
                      animationDuration: 5000,
                      xValueMapper: (TimeData data, _) => data.date,
                      yValueMapper: (TimeData data, _) => data.cases,
                      ),
                  LineSeries<TimeDataString>(
                    enableTooltip: true,
                      name: 'Deceased cases',
                      dataSource: <TimeData>[...data.deceasedcasesTimeItems],
                      animationDuration: 5000,
                      xValueMapper: (TimeData data, _) => data.date,
                      yValueMapper: (TimeData data, _) => data.cases,
                      ),
                  LineSeries<TimeDataString>(
                    enableTooltip: true,
                      name: 'Recovered cases',
                      dataSource: <TimeData>[...data.recoveredcasesTimeItems],
                      animationDuration: 5000,
                      xValueMapper: (TimeData data, _) => data.date,
                      yValueMapper: (TimeData data, _) => data.cases,
                      dataLabelSettings: DataLabelSettings(isVisible: false)),
                ]),
          ))

now from this code when i remove the title form primaryXaxis and

primaryYaxis and use below code snippet only then tooltip works fine.

primaryXAxis: CategoryAxis(
                    majorGridLines: MajorGridLines(color: Colors.white),


                  ),

Why this error is happening and how to fix this. And by this way i

cannot use axis title if i want to use tooltip and vice-versa

Someone help!!











-------- Exception caught by gesture library -----------------------------------
The following NoSuchMethodError was thrown while dispatching a pointer event:
Class 'CategoryAxis' has no instance getter 'labelFormat'. Receiver: Instance of 'CategoryAxis' Tried calling: labelFormat
When the exception was thrown, this was the stack
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 _getLabelValue
package:syncfusion_flutter_charts/…/utils/helper.dart:1167
#2 _TooltipPainter._calculateCartesianTooltipText
package:syncfusion_flutter_charts/…/user_interaction/tooltip_painter.dart:360
#3 _TooltipPainter._renderCartesianChartTooltip
package:syncfusion_flutter_charts/…/user_interaction/tooltip_painter.dart:286
#4 _TooltipPainter._renderTooltipView
package:syncfusion_flutter_charts/…/user_interaction/tooltip_painter.dart:154
...
Event: PointerUpEvent#f5a71(position: Offset(298.8, 324.8))
position: Offset(298.8, 324.8)
Target: RenderPointerListener#184da relayoutBoundary=up1
parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=351.4, 0.0<=h<=384.0)
size: Size(351.4, 384.0)
behavior: deferToChild
listeners: down, move, up, signal
--------------------------------------------------------------------------------
-------- Exception caught by gesture library -----------------------------------
Class 'CategoryAxis' has no instance getter 'labelFormat'. Receiver: Instance of 'CategoryAxis' Tried calling: labelFormat

































1 Reply

SK Sriram Kiran Senthilkumar Syncfusion Team May 29, 2020 02:11 PM UTC

Hi Satyam, 
  
Greetings from Syncfusion. We have analyzed your scenario and we found from the provided code snippet that you are using category axis for both x-axis and y-axis and currently, there is no support for category y-axis in our chart widget package. By setting the category axis as y-axis will throw build error and it is not possible to run the application so, kindly provide us with more information in detail on the scenario you are requesting. We have also created a sample from the provided code snippet and tried to replicate the issue, but the issue is not replicating at our end. So, we request you to try to replicate the reported issue in this sample and revert us along with the current chart widget package version you are using in your project so that it will be helpful in providing the solution sooner. 
  
Regards, 
Sriram Kiran. 


Loader.
Up arrow icon