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:logger/logger.dart';
import 'package:intl/intl.dart';
class Cluster {
final String label;
final int id;
final String layerName;
static final NumberFormat format = NumberFormat("##.00");
List<Post> nodes;
Cluster(this.label, this.id, this.layerName, this.nodes);
......@@ -19,11 +23,11 @@ class Cluster {
break;
case "Percentage_Layer":
String trust = label.substring(0, label.indexOf(" "));
if (trust == "1.0")
trust = "100";
else
trust = trust.substring(2);
return "$trust% Trust";
trust = trust.substring(0, min(6, trust.length));
double val = double.parse(trust) * 100;
return "${format.format(val)}% Trust";
break;
case "Engagement_Layer":
return "${label.substring(0, label.indexOf("."))} comments";
......
import 'dart:math';
import 'package:circlegraph/bubble/bubblegraph.dart';
import 'package:circlegraph/circlegraph.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/theme/color_holder.dart';
import 'package:dashboard/ui/util/logged_in_appbar.dart';
import 'package:flutter/material.dart';
import 'package:enhanced_future_builder/enhanced_future_builder.dart';
class ClusterGraph extends StatefulWidget {
final List<Cluster> clusters;
......@@ -25,70 +15,113 @@ class ClusterGraph extends StatefulWidget {
class _ClusterGraphState extends State<ClusterGraph> {
final List<Cluster> clusters;
int postNodeCount = 10; // Nr of postNodes displayed
int page = 0;
int nodesPerPage = 50;
_ClusterGraphState(this.clusters);
void _previous() {
setState(() {
page--;
});
}
void _next() {
setState(() {
page++;
});
}
Widget build(BuildContext context) {
return SingleChildScrollView(
scrollDirection: Axis.vertical,
child: BubbleGraph(
clusters
.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,
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,
child: BubbleGraph(
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,
width: 160,
),
circlify: true,
backgroundColor: ColorHolder.color1,
),
)
.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