Comments (3)
Hi @archie-sh,
Greetings from Syncfusion. We have analyzed your scenario with the provided information and the requested scenario regarding hiding of only the left most or right most axis label in the chart can also be achieved with the help of the onAxisLabelRender
and onActualRangeChanged
callback events available in the SfCartesianChart
. We have also created a simple sample and attached below in which we have used the above-mentioned events to hide the leftmost or rightmost axis label in the chart. Please refer the code snippet below for further reference.
// First initialize two string variable to store the visible minimum and maximum axis values
String axisMinimum;
String axisMaximum;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Syncfusion Flutter chart'),
),
body: SfCartesianChart(
onActualRangeChanged: (args) {
if (args.axisName == 'primayXAxis') {
// Storing the visible minimum and visible maximum values of the axis to use them for hiding the left and right most axis labels in the onAxisLabelRender event
axisMinimum = args.visibleMin.toInt().toString();
axisMaximum = args.visibleMax.toInt().toString();
}
},
onAxisLabelRender: (args) {
if (args.axisName == 'primayXAxis') {
// To hide only the left most axis label by checking the axis minimum value and setting the empty string for the label text.
if (args.text == axisMinimum) {
args.text = '';
}
// To hide only the right most axis label by checking the axis maximum value and setting the empty string for the label text.
if (args.text == axisMaximum) {
args.text = '';
}
}
},
primaryXAxis: NumericAxis(
edgeLabelPlacement: EdgeLabelPlacement.shift,
name: 'primayXAxis'
),
series: <ChartSeries<_SalesData, num>>[
LineSeries<_SalesData, num>(
dataSource: <_SalesData>[
_SalesData(2010, 35),
_SalesData(2011, 28),
_SalesData(2013, 34),
_SalesData(2014, 32),
_SalesData(2015, 40)
],
xValueMapper: (_SalesData sales, _) => sales.year,
yValueMapper: (_SalesData sales, _) => sales.sales,
// your configurations
)
]));
}
screenshots:
- Hiding the left most axis label in the chart.
- Hiding the right most axis label in the chart
The sample for reference can be found below.
sample.zip
Please check with the above sample and revert us if you still have further concerns.
Regards,
Sriram Kiran
from flutter-widgets.
Hi, thank you for taking the time to respond and for providing the sample, thats going above and beyond. I can confirm the solution works. I am closing the ticket.
from flutter-widgets.
@SriramKiranSenthilkumar, I agree with @archie-sh. That was a fantastic response. Thank you for being so thorough. The community really appreciates it!
from flutter-widgets.
Related Issues (20)
- tooltip only shows on const class HOT 4
- [syncfusion_flutter_pdfviewer] Annotations are incorrectly positioned when the PDF is edited using Firefox's PDF editor. HOT 3
- Table with pagination does not export all data HOT 2
- method 'markNeedsBuild' isn't defined for the class 'RenderConstrainedLayoutBuilder<Constraints, RenderObject>' HOT 9
- [syncfusion_flutter_calendar] no option to disable cell border on hover on web HOT 2
- ColumnSeries chart's column very small in size
- pdf: when i removed some pages from pdf, then save it. the new file's size is almost the same as the old file's.
- pdf module bug: when i removed some pages from pdf, then save it. the new file's size is almost the same as the old file's. HOT 7
- The method 'markNeedsBuild' isn't defined for the class HOT 7
- syncfusion flutter datagrid on Column Resize columns goes invisible HOT 2
- Pdf Viewer - Can't scroll to the very end when keyboard is opened HOT 1
- [syncfusion_flutter_calendar] drag&drop with certain time interval as step HOT 1
- change the color of filter popup checkbox color to match app theme. HOT 1
- datagrid filtered table with number that shows the number of rows filtered HOT 1
- Unable to customize the Radial chart size. HOT 1
- runtime error HOT 3
- under sfDataGrid how to concatenate two or more value in single row HOT 3
- Can customise hijri calendar?
- Logarithmic Axis Minimum/Maximum Not Being Respected HOT 2
- In DataGrid, support consecutive `KeyEvent` please. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-widgets.