Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Did x axis and y axis sort? #39

Open
ChloeSu opened this issue Sep 10, 2020 · 1 comment
Open

Did x axis and y axis sort? #39

ChloeSu opened this issue Sep 10, 2020 · 1 comment

Comments

@ChloeSu
Copy link

ChloeSu commented Sep 10, 2020

Hi
I create a line chart but I could not let the x axis and y axis sort same time.

image

if I sort the data for y axis, the graph will show ...
image

my line chart code...

LineChart(
            chartPadding: new EdgeInsets.fromLTRB(50, 35, 50, 35),
            lines: [
              new Line<FuelListDetailList, String, double>(
                data: consumption,
                xFn: (list) => list.record_date,
                yFn: (list) => list.liters_per_km,
                xAxis: xAxis,
                yAxis: new ChartAxis(
                  tickLabelerStyle: new TextStyle(
                      color: Colors.blue, fontWeight: FontWeight.bold),
                  paint: const PaintOptions.stroke(color: Colors.blue),
                ),
                marker: const MarkerOptions(
                  paint: const PaintOptions.fill(color: Colors.blue),
                ),
                stroke: const PaintOptions.stroke(color: Colors.blue),
                legend: new LegendItem(
                  paint: const PaintOptions.fill(color: Colors.blue),
                  text: ")",
                ),
              ),

              // price line
              new Line<FuelListDetailList, String, double>(
                data: price,
                xFn: (list) => list.record_date,
                yFn: (list) => list.total_price,
                xAxis: xAxis,
                yAxis: new ChartAxis(
                  opposite: true,
                  paint: const PaintOptions.stroke(color: Colors.green),
                  tickLabelerStyle: new TextStyle(
                      color: Colors.green, fontWeight: FontWeight.bold),
                ),
                marker: const MarkerOptions(
                  paint: const PaintOptions.fill(color: Colors.green),
                  shape: MarkerShapes.square,
                ),
                stroke: const PaintOptions.stroke(color: Colors.green),
                legend: new LegendItem(
                  paint: const PaintOptions.fill(color: Colors.green),
                  text: 'price',
                ),
              ),
            ],
          ),

or can I fixed the y axis value like this...?
image

@ChloeSu
Copy link
Author

ChloeSu commented Sep 10, 2020

oh... sorry
I noticed the closed issue after I posted this.

I found I can set tickGenerator: IntervalTickGenerator.byN(num) and span from issue #21

and could not sort at the same time from issue #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant