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

Can't use decimal values in Radar Chart #19

Open
arielramos opened this issue Jan 4, 2023 · 0 comments
Open

Can't use decimal values in Radar Chart #19

arielramos opened this issue Jan 4, 2023 · 0 comments

Comments

@arielramos
Copy link

arielramos commented Jan 4, 2023

Hi, it seems that when I send Double variables the chart is not compiling well, is there something that I'm missing or it is kust that the library only receive int values?

// Automatic FlutterFlow imports
import '../../backend/backend.dart';
import '../../flutter_flow/flutter_flow_theme.dart';
import '../../flutter_flow/flutter_flow_util.dart';
import '../widgets/index.dart'; // Imports other custom widgets
import '../../flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:flutter_radar_chart/flutter_radar_chart.dart';

class Radar5Eses extends StatefulWidget {
const Radar5Eses({
Key? key,
this.width,
this.height,
required this.seiri,
required this.seiton,
required this.seiso,
required this.seiketsu,
required this.shitsuke,
}) : super(key: key);

final double? width;
final double? height;
final double seiri;
final double seiton;
final double seiso;
final double seiketsu;
final double shitsuke;

@OverRide
_Radar5EsesState createState() => _Radar5EsesState();
}

class _Radar5EsesState extends State {
bool darkMode = false;
bool useSides = false;
double numberOfFeatures = 5;
@OverRide
Widget build(BuildContext context) {
const ticks = [5, 4, 3, 2, 1];
var features = ["SEIRI", "SEITON", "SEISO", "SEIKETSU", "SHITSUKE"];
var data = [
[
widget.seiri.round(),
widget.seiton.round(),
widget.seiso.round(),
widget.seiketsu.round(),
widget.shitsuke.round()
]
];

features = features.sublist(0, numberOfFeatures.floor());
data = data
    .map((graph) => graph.sublist(0, numberOfFeatures.floor()))
    .toList();

return Scaffold(
  appBar: AppBar(
    title: Text('Gráfico de Radar'),
  ),
  body: Container(
    color: darkMode ? Colors.black : Colors.white,
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 8.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              darkMode
                  ? Text(
                      'Modo claro',
                      style: TextStyle(color: Colors.white),
                    )
                  : Text(
                      'Modo oscuro',
                      style: TextStyle(color: Colors.black),
                    ),
              Switch(
                value: this.darkMode,
                onChanged: (value) {
                  setState(() {
                    darkMode = value;
                  });
                },
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 8.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              useSides
                  ? Text(
                      'Poligonal',
                      style: darkMode
                          ? TextStyle(color: Colors.white)
                          : TextStyle(color: Colors.black),
                    )
                  : Text(
                      'Circular',
                      style: darkMode
                          ? TextStyle(color: Colors.white)
                          : TextStyle(color: Colors.black),
                    ),
              Switch(
                value: this.useSides,
                onChanged: (value) {
                  setState(() {
                    useSides = value;
                  });
                },
              ),
            ],
          ),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 8.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: <Widget>[
              Text(
                'Niveles',
                style: TextStyle(
                    color: darkMode ? Colors.white : Colors.black),
              ),
              Expanded(
                child: Slider(
                  value: this.numberOfFeatures,
                  min: 3,
                  max: 5,
                  divisions: 3,
                  onChanged: (value) {
                    setState(() {
                      numberOfFeatures = value;
                    });
                  },
                ),
              ),
            ],
          ),
        ),
        Expanded(
          child: darkMode
              ? RadarChart.dark(
                  ticks: ticks,
                  features: features,
                  data: data,
                  reverseAxis: true,
                  useSides: useSides,
                )
              : RadarChart.light(
                  ticks: ticks,
                  features: features,
                  data: data,
                  reverseAxis: true,
                  useSides: useSides,
                ),
        ),
      ],
    ),
  ),
);

}
}

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