Comments (6)
@huang-weilong @manujbahl @lorrainekan
HI,
I used tickFormatterSpec
property on the chart, and set tickFormatterSpec
with the function you want to generate String from the given num, the code belows
good luck.
domainAxis: new charts.NumericAxisSpec(
// viewport: new charts.NumericExtents(2017, 2021),
tickProviderSpec: new charts.BasicNumericTickProviderSpec(
zeroBound: false,
dataIsInWholeNumbers: false,
desiredTickCount: 10,
),
tickFormatterSpec: charts.BasicNumericTickFormatterSpec(
_formaterYear,
),
renderSpec: charts.GridlineRendererSpec( // 交叉轴刻度水平线
tickLengthPx: 0,
labelOffsetFromAxisPx: 12,
)
),
String _formaterYear(num year) {
int value = year.toInt();
return '$value 年';
}
This page https://juejin.im/post/5c14891ef265da61616e956b maybe like my code.
However , i cannot see the define of function DomainFormatterSpec
it let me very egg pain. so i implement it my self.
from charts.
@lorrainekan is there a formatter for the bar charts as well. My bar chart has about 20 domains and the labels overlap causing a weird visual.
from charts.
You can format the ticks on domain or measure axis by implementing a custom tick formatter and a corresponding tick formatter spec, then setting it on the axis spec.
Tick formatter interface:
Tick formatter spec interface:
Setting custom tick formatter spec on axis:
https://google.github.io/charts/flutter/example/axes/custom_axis_tick_formatters
You can set a non zero bound measure axis:
https://google.github.io/charts/flutter/example/axes/nonzero_bound_measure_axis
from charts.
Is there an example to implement X-axis using string labels?
from charts.
@huang-weilong @manujbahl @lorrainekan
HI,
I usedtickFormatterSpec
property on the chart, and settickFormatterSpec
with the function you want to generate String from the given num, the code belowsgood luck.
domainAxis: new charts.NumericAxisSpec( // viewport: new charts.NumericExtents(2017, 2021), tickProviderSpec: new charts.BasicNumericTickProviderSpec( zeroBound: false, dataIsInWholeNumbers: false, desiredTickCount: 10, ), tickFormatterSpec: charts.BasicNumericTickFormatterSpec( _formaterYear, ), renderSpec: charts.GridlineRendererSpec( // 交叉轴刻度水平线 tickLengthPx: 0, labelOffsetFromAxisPx: 12, ) ),
String _formaterYear(num year) { int value = year.toInt(); return '$value 年'; }
This page https://juejin.im/post/5c14891ef265da61616e956b maybe like my code.
However , i cannot see the define of functionDomainFormatterSpec
it let me very egg pain. so i implement it my self.
What is the num year and where does this value come from inside the _formaterYear method?
from charts.
You saved my day thanks for helping us 💯
from charts.
Related Issues (20)
- BarChart doesn’t display single horizontal bar when value is in the millions
- StaticOrdinalTickProviderSpec should have a desiredTickCount.
- How to add bar value as label
- How to show duplicate domainFn on the X-Axis of a BarChart in Flutter Charts
- "Null check operator used on a null value" on legend with measures HOT 1
- Label does not show outside of pie chart when there are multiple small slices
- Negative series points are drawn outside the bounds of the domain axis
- Issue with series area
- Operand of null-aware operation Flutter 3.0.5
- charts InitialSelection seems not working for Combo charts
- Legend with "bottom" position has width limited by chartArea
- Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null. - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' HOT 1
- flutter - How to add Image or Widget inside charts_flutter
- How to show y value at timeserieschart when user tap specific point?
- 📣 This project is no longer maintained HOT 35
- The pie chart disappear when I use 'arcRendererDecorators' HOT 3
- How to add a legend item visibility listener HOT 1
- The getter 'index' isn't defined for the class '_
- A value of type 'BaseTouchResponse?' can't be assigned to a variable of type 'BarTouchResponse'
- How to center label in top of barchart?
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 charts.