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,70 +15,113 @@ class ClusterGraph extends StatefulWidget { ...@@ -25,70 +15,113 @@ 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(
scrollDirection: Axis.vertical, children: [
child: BubbleGraph( Row(
clusters mainAxisAlignment: MainAxisAlignment.center,
.map( children: [
(Cluster cluster) => CircleGraph( if (page > 0)
root: TreeNodeData( IconButton(
onNodeClick: (node, data) => Navigator.push( onPressed: _previous,
context, icon: Icon(Icons.chevron_left),
MaterialPageRoute( color: ColorHolder.color2,
builder: (context) => ClusterList(data, 0), iconSize: 30,
), ),
), SizedBox(width: 16),
data: cluster, Text(
backgroundColor: ColorHolder.color1, "Page ${page + 1}",
child: Container( style: TextStyle(
constraints: BoxConstraints.expand(), fontSize: 20,
child: Stack( color: ColorHolder.color2,
children: [ ),
Align( ),
alignment: Alignment.center, SizedBox(width: 16),
child: Padding( IconButton(
padding: const EdgeInsets.only(top: 32.0), onPressed: _next,
child: Row( icon: Icon(Icons.chevron_right),
mainAxisSize: MainAxisSize.min, color: ColorHolder.color2,
children: [ iconSize: 30,
Icon( ),
Icons.group_work, ],
color: ColorHolder.color2, ),
), Expanded(
Text( child: SingleChildScrollView(
"${cluster.getDisplayLabel()}", scrollDirection: Axis.vertical,
style: TextStyle( child: BubbleGraph(
color: ColorHolder.color2, clusters
.where(
(element) =>
clusters.indexOf(element) >= page * nodesPerPage &&
clusters.indexOf(element) < (page + 1) * nodesPerPage,
)
.map(
(Cluster cluster) => CircleGraph(
root: TreeNodeData(
onNodeClick: (node, data) => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ClusterList(data, 0),
),
),
data: cluster,
backgroundColor: ColorHolder.color1,
child: Container(
constraints: BoxConstraints.expand(),
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.only(top: 32.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.group_work,
color: ColorHolder.color2,
),
Text(
"${cluster.getDisplayLabel()}",
style: TextStyle(
color: ColorHolder.color2,
),
),
],
), ),
), ),
], ),
), ],
), ),
), ),
], height: 160,
width: 160,
),
circlify: true,
backgroundColor: ColorHolder.color1,
), ),
), )
height: 160, .toList(),
width: 160, ),
), ),
circlify: true, ),
backgroundColor: ColorHolder.color1, ],
),
)
.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