Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 0.3.0

- Added Line Color Option
- This is a fork of spider_chart from cnsumner

## 0.2.0

- Color parameter is now optional and alternative color swatch parameter introduced
- Color swatch is useful for app theme matching. Blue color swatch is provided by default if neither custom colors nor color swatch are specified
- Color swatch is useful for app theme matching. Blue color swatch is provided by default if neither custom colors nor color swatch are specified
- Max value now optional and is automatically calculated from data points if not provided

## 0.1.8
Expand Down
211 changes: 209 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[![Pub](https://img.shields.io/pub/v/spider_chart.svg)](https://pub.dartlang.org/packages/spider_chart)
[![Gitlab pipeline status](https://img.shields.io/gitlab/pipeline/cnsumner/flutter-spider-chart.svg)](https://gitlab.com/cnsumner/flutter-spider-chart)

# spider_chart

Expand Down Expand Up @@ -36,3 +34,212 @@ Center(
),
)
```

```dart
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:spider_chart/spider_chart.dart';

class SpiderChartWithIndicatorText extends StatefulWidget {
const SpiderChartWithIndicatorText({
Key? key,
this.width,
this.height,
this.data,
this.data2,
this.data3,
this.data4,
this.dataName,
this.data2Name,
this.data3Name,
this.data4Name,
}) : super(key: key);

final double? width;
final double? height;
final List<double>? data;
final List<double>? data2;
final List<double>? data3;
final List<double>? data4;
final String? dataName;
final String? data2Name;
final String? data3Name;
final String? data4Name;

@override
State<SpiderChartWithIndicatorText> createState() =>
_SpiderChartWithIndicatorTextState();
}

class _SpiderChartWithIndicatorTextState
extends State<SpiderChartWithIndicatorText> {
List<SpiderChart> list = [];
int _current = 0;
final CarouselController _controller = CarouselController();
final colorList = [
const Color(0xff62ACD6),
const Color(0xffE69138),
const Color(0xff4EA8A8),
const Color(0xff38761D),
const Color(0xff6499E8),
];
List<String> names = [
'Performance',
'Power',
'Quality',
'Service',
'Cost',
];

@override
void initState() {
// TODO: implement initState
super.initState();
get();
}

get() {
print('Data :${widget.data}');
print('name :${widget.dataName}');

if (widget.data != null && widget.data!.length == 5) {
list.add(SpiderChart(
data: widget.data!,
colorSwatch: Colors.blue,
labels: names,
lineColor: Colors.blueAccent,
maxValue: 10,
));
}
if (widget.data2 != null && widget.data2!.length == 5) {
list.add(SpiderChart(
data: widget.data2!,
colorSwatch: Colors.orange,
labels: names,
maxValue: 10,
lineColor: Colors.orangeAccent,
));
}
if (widget.data3 != null && widget.data3!.length == 5) {
list.add(SpiderChart(
data: widget.data3!,
colorSwatch: Colors.deepPurple,
labels: names,
maxValue: 10,
lineColor: Colors.deepPurpleAccent,
));
}
if (widget.data4 != null && widget.data4!.length == 5) {
list.add(SpiderChart(
data: widget.data4!,
colorSwatch: Colors.green,
labels: names,
lineColor: Colors.greenAccent,
maxValue: 10,
));
}

print(list);
}

getTextName(int index) {
switch (index) {
case 0:
return widget.dataName ?? '';

case 1:
return widget.data2Name ?? '';

case 2:
return widget.data3Name ?? '';

case 3:
return widget.data4Name ?? '';

default:
return '';
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text(
'Spider',
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.blue,
),
body: Column(
children: [
CarouselSlider(
carouselController: _controller,
options: CarouselOptions(
pageSnapping: true,
autoPlay: true,
enlargeCenterPage: true,
aspectRatio: 2.0,
onPageChanged: (index, reason) {
setState(() {
_current = index;
});
},
height: widget.height ??
MediaQuery.of(context).size.longestSide * 0.4,
),
items: list.map((i) {
return Builder(
builder: (BuildContext context) {
return Container(
width: widget.width,
margin: const EdgeInsets.symmetric(horizontal: 5.0),
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20))),
child: Padding(
padding: EdgeInsets.symmetric(
vertical:
MediaQuery.of(context).size.shortestSide * 0.1),
child: i,
));
},
);
}).toList(),
),
Text(
getTextName(_current),
style: TextStyle(
fontSize: MediaQuery.of(context).size.shortestSide * 0.05,
fontWeight: FontWeight.w600),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(
list.length,
(index) => GestureDetector(
onTap: () {
print(index);
_controller.animateToPage(index);
},
child: Container(
width: 12.0,
height: 12.0,
margin: const EdgeInsets.symmetric(
vertical: 8.0, horizontal: 4.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: (Theme.of(context).brightness ==
Brightness.dark
? Colors.white
: Colors.black)
.withOpacity(_current == index ? 0.9 : 0.4)),
),
))),
],
),
);
}
}

```
34 changes: 17 additions & 17 deletions example/integration_test/screenshot.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// ignore_for_file: avoid_print
// // ignore_for_file: avoid_print

import 'dart:io';
import 'package:integration_test/integration_test_driver_extended.dart';
// import 'dart:io';
// import 'package:integration_test/integration_test_driver_extended.dart';

Future<void> main() async {
try {
await integrationDriver(
onScreenshot: (String screenshotName, List<int> screenshotBytes) async {
final File image = await File('screenshots/$screenshotName.png')
.create(recursive: true);
image.writeAsBytesSync(screenshotBytes);
return true;
},
);
} catch (e) {
print('Error occured: $e');
}
}
// Future<void> main() async {
// try {
// await integrationDriver(
// onScreenshot: (String screenshotName, List<int> screenshotBytes) async {
// final File image = await File('screenshots/$screenshotName.png')
// .create(recursive: true);
// image.writeAsBytesSync(screenshotBytes);
// return true;
// },
// );
// } catch (e) {
// print('Error occured: $e');
// }
// }
Loading