Sfcartesian column and spline series

Dear Support,

I am using Cartesian column and spline series. In PrimaryXaxis label showing both axis values from column series and spline. below is my code. Could you please help me to show only column series label in PrimaryXaxis label.

Many thanks in advance


SfCartesianChart(
plotAreaBorderWidth: 0,
primaryXAxis: CategoryAxis(
isVisible: true,
arrangeByIndex: true,
minorGridLines: const MinorGridLines(width: 0),
majorTickLines: const MajorTickLines(width: 0),
minorTickLines: const MinorTickLines(width: 0),
majorGridLines: const MajorGridLines(width: 0),
axisLine: const AxisLine(width: 0),
interval: 1),
primaryYAxis: NumericAxis(
isVisible: false,
majorGridLines: const MajorGridLines(width: 0),
axisLine: const AxisLine(width: 0),
interval: 1,
maximum: 13,
rangePadding: ChartRangePadding.normal),
series: [
ColumnSeries(
dataSource: ChartDataList,
enableTooltip: false,
xValueMapper: (ChartData data, _) => (data.title),
yValueMapper: (ChartData data, _) => (data.chartValue),
pointColorMapper: (ChartData data, _) => data.Colors,
borderRadius: const BorderRadius.all(Radius.circular(30)),
dataLabelSettings: DataLabelSettings(
isVisible: true,
builder: (dynamic data, dynamic point, dynamic series, int pointIndex, int seriesIndex) {
ChartData imageData = data;
return Container(
height: 30,
width: 30,
padding: const EdgeInsets.all(5),
decoration: const BoxDecoration(
boxShadow: [
BoxShadow(
offset: Offset(5, 5),
color: Color.fromRGBO(0, 0, 0, 0.05),
spreadRadius: 5,
blurRadius: 5,
),
],
shape: BoxShape.circle,
color: Colors.white,
),
child: imageData.Icon,
);
},
),
),
SplineSeries(
isVisible: Response != null ? true : false,
name: "mark",
legendItemText: "mark",
dataSource: ChartDataList,
xValueMapper: (ChartData data, _) => (data.title),
yValueMapper: (ChartData data, _) => (data.markValue),
color: const Color(0xFF7C7C7C),
enableTooltip: true,
dashArray: const [5, 5],
markerSettings: const MarkerSettings(
isVisible: false,
shape: DataMarkerType.circle,
),
),
],
),

1 Reply

SK Sriram Kiran Senthilkumar Syncfusion Team September 19, 2022 05:37 AM UTC

Hi Fazil,


Greetings from Syncfusion.

We have checked your query at our end, and we would like to let you know that you can use the axisLabelFormatter callback property of CategoryAxis to format the axis labels rendered on the x-axis. For your case, we have used it to format the axis labels of the x-axis to render only the first series axis labels. Please check the code snippet below for reference.

SfCartesianChart(

      primaryXAxis: CategoryAxis(

        axisLabelFormatter: (args) {

          /// Here, we have taken substring from incoming axis label text from first index

          /// till the index before "," (comma) and returned it to render in the x-axis.

          final String text = args.text.substring(0, args.text.indexOf(RegExp(r',')));

          return ChartAxisLabel(text, args.textStyle);

        },

      )

     // Your configurations

)


Icon

Description automatically generated with medium confidence


We have also attached the sample in which we have achieved your requirement and appended the user guide documentation for axisLabelFormatter below for reference.

https://help.syncfusion.com/flutter/cartesian-charts/callbacks#axislabelformatter


Please check and get back to us if you require further assistance.


Regards,
Sriram Kiran


Attachment: f177585_7cd757db.zip

Loader.
Up arrow icon