Git Product home page Git Product logo

Comments (6)

luckforyou avatar luckforyou commented on May 2, 2024 14

@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.

manujbahl avatar manujbahl commented on May 2, 2024 2

@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.

lorrainekan avatar lorrainekan commented on May 2, 2024

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:

abstract class TickFormatterSpec<D> {

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.

huang-weilong avatar huang-weilong commented on May 2, 2024

Is there an example to implement X-axis using string labels?

from charts.

amani27 avatar amani27 commented on May 2, 2024

@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.

What is the num year and where does this value come from inside the _formaterYear method?

from charts.

osamaasifoak avatar osamaasifoak commented on May 2, 2024

@huang-weilong @manujbahl @lorrainekan

You saved my day thanks for helping us 💯

from charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.