Commit 359029c9 authored by Manuel Herold's avatar Manuel Herold

fixed formatting bugs

parent 3279a264
import 'dart:math';
import 'package:dashboard/data/post.dart'; import 'package:dashboard/data/post.dart';
import 'package:logger/logger.dart'; import 'package:intl/intl.dart';
class Cluster { class Cluster {
final String label; final String label;
final int id; final int id;
final String layerName; final String layerName;
static final NumberFormat format = NumberFormat("##.00");
List<Post> nodes; List<Post> nodes;
Cluster(this.label, this.id, this.layerName, this.nodes); Cluster(this.label, this.id, this.layerName, this.nodes);
...@@ -19,11 +23,11 @@ class Cluster { ...@@ -19,11 +23,11 @@ class Cluster {
break; break;
case "Percentage_Layer": case "Percentage_Layer":
String trust = label.substring(0, label.indexOf(" ")); String trust = label.substring(0, label.indexOf(" "));
if (trust == "1.0") trust = trust.substring(0, min(6, trust.length));
trust = "100";
else double val = double.parse(trust) * 100;
trust = trust.substring(2);
return "$trust% Trust"; return "${format.format(val)}% Trust";
break; break;
case "Engagement_Layer": case "Engagement_Layer":
return "${label.substring(0, label.indexOf("."))} comments"; return "${label.substring(0, label.indexOf("."))} comments";
......
import 'dart:math';
import 'package:circlegraph/bubble/bubblegraph.dart'; import 'package:circlegraph/bubble/bubblegraph.dart';
import 'package:circlegraph/circlegraph.dart'; import 'package:circlegraph/circlegraph.dart';
import 'package:dashboard/data/cluster.dart'; import 'package:dashboard/data/cluster.dart';
import 'package:dashboard/data/community.dart';
import 'package:dashboard/graphing/trustcolorcalculator.dart';
import 'package:dashboard/loading.dart';
import 'package:dashboard/querying/clustergetter.dart';
import 'package:dashboard/querying/communitygetter.dart';
import 'package:dashboard/ui/graphs/community/community_graph_view_page.dart';
import 'package:dashboard/ui/graphs/community/list/cluster_list.dart'; import 'package:dashboard/ui/graphs/community/list/cluster_list.dart';
import 'package:dashboard/ui/theme/color_holder.dart'; import 'package:dashboard/ui/theme/color_holder.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart';
class ClusterGraph extends StatefulWidget { class ClusterGraph extends StatefulWidget {
final List<Cluster> clusters; final List<Cluster> clusters;
...@@ -25,13 +15,62 @@ class ClusterGraph extends StatefulWidget { ...@@ -25,13 +15,62 @@ class ClusterGraph extends StatefulWidget {
class _ClusterGraphState extends State<ClusterGraph> { class _ClusterGraphState extends State<ClusterGraph> {
final List<Cluster> clusters; final List<Cluster> clusters;
int postNodeCount = 10; // Nr of postNodes displayed int postNodeCount = 10; // Nr of postNodes displayed
int page = 0;
int nodesPerPage = 50;
_ClusterGraphState(this.clusters); _ClusterGraphState(this.clusters);
void _previous() {
setState(() {
page--;
});
}
void _next() {
setState(() {
page++;
});
}
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SingleChildScrollView( return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (page > 0)
IconButton(
onPressed: _previous,
icon: Icon(Icons.chevron_left),
color: ColorHolder.color2,
iconSize: 30,
),
SizedBox(width: 16),
Text(
"Page ${page + 1}",
style: TextStyle(
fontSize: 20,
color: ColorHolder.color2,
),
),
SizedBox(width: 16),
IconButton(
onPressed: _next,
icon: Icon(Icons.chevron_right),
color: ColorHolder.color2,
iconSize: 30,
),
],
),
Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
child: BubbleGraph( child: BubbleGraph(
clusters clusters
.where(
(element) =>
clusters.indexOf(element) >= page * nodesPerPage &&
clusters.indexOf(element) < (page + 1) * nodesPerPage,
)
.map( .map(
(Cluster cluster) => CircleGraph( (Cluster cluster) => CircleGraph(
root: TreeNodeData( root: TreeNodeData(
...@@ -80,15 +119,9 @@ class _ClusterGraphState extends State<ClusterGraph> { ...@@ -80,15 +119,9 @@ class _ClusterGraphState extends State<ClusterGraph> {
) )
.toList(), .toList(),
), ),
),
),
],
); );
// return SingleChildScrollView(
// child: Wrap(
// children: [
// for (Community community in communities)
// getCommunityNodeWidget(community)
// ],
// ),
// );
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment