Skip to content

Commit e34face

Browse files
committed
new click feature testing setup + gradle bump
1 parent 7629314 commit e34face

6 files changed

Lines changed: 131 additions & 7 deletions

File tree

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ group 'com.warioddly.graphify'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.7.10'
5+
ext.kotlin_version = '2.1.0'
66
repositories {
77
google()
88
mavenCentral()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:7.3.0'
12+
classpath 'com.android.tools.build:gradle:8.7.0'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.8.10'
2+
ext.kotlin_version = '2.1.0'
33
repositories {
44
google()
55
mavenCentral()

example/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pluginManagement {
2323

2424
plugins {
2525
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
26-
id "com.android.application" version "8.1.0" apply false
26+
id "com.android.application" version "8.7.0" apply false
2727
}
2828

2929
include ":app"

example/lib/main.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:graphify_example/charts/shang_hai_index.dart';
1818
import 'package:graphify_example/charts/stacked_area_chart.dart';
1919
import 'package:graphify_example/charts/tangential_polar_bar_chart.dart';
2020
import 'package:graphify_example/charts/world_population.dart';
21+
import 'package:graphify_example/test_chart_click.dart';
2122
import 'package:url_launcher/url_launcher_string.dart';
2223

2324
void main() {
@@ -28,6 +29,7 @@ class MyApp extends StatelessWidget {
2829
const MyApp({super.key});
2930

3031
static const charts = {
32+
"Chart Click Test": TestChartClick(),
3133
"Basic Line Chart": BasicLineChart(),
3234
'Basic Area Chart': BasicAreaChart(),
3335
'Stacked Area Chart': StackedAreaChart(),
@@ -90,13 +92,15 @@ class MyApp extends StatelessWidget {
9092
ListTile(
9193
title: const Text("Open Source Code"),
9294
onTap: () {
93-
launchUrlString("https://github.com/warioddly/graphify");
95+
launchUrlString(
96+
"https://github.com/warioddly/graphify");
9497
},
9598
),
9699
ListTile(
97100
title: const Text("Pub.dev"),
98101
onTap: () {
99-
launchUrlString("https://pub.dev/packages/graphify");
102+
launchUrlString(
103+
"https://pub.dev/packages/graphify");
100104
},
101105
),
102106
],

example/lib/test_chart_click.dart

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import 'dart:developer';
2+
3+
import 'package:flutter/material.dart';
4+
import 'package:graphify/graphify.dart';
5+
6+
class TestChartClick extends StatefulWidget {
7+
const TestChartClick({super.key});
8+
9+
@override
10+
State<TestChartClick> createState() => _TestChartClickState();
11+
}
12+
13+
class _TestChartClickState extends State<TestChartClick> {
14+
late final GraphifyController _controller;
15+
final List<Map<String, dynamic>> _clickEvents = [];
16+
String _status = 'Ready to test clicks';
17+
18+
@override
19+
void initState() {
20+
super.initState();
21+
_controller = GraphifyController();
22+
_controller.chartClickedEvent.listen((data) {
23+
setState(() {
24+
_clickEvents.add(data);
25+
_status = 'Click received: ${data['name'] ?? 'Unknown'}';
26+
});
27+
28+
log('TEST: Chart click received: $data');
29+
});
30+
}
31+
32+
@override
33+
void dispose() {
34+
_controller.dispose();
35+
super.dispose();
36+
}
37+
38+
@override
39+
Widget build(BuildContext context) {
40+
return Column(
41+
children: [
42+
Container(
43+
width: double.infinity,
44+
padding: const EdgeInsets.all(16),
45+
child: Text(
46+
_status,
47+
style: const TextStyle(fontWeight: FontWeight.bold),
48+
textAlign: TextAlign.center,
49+
),
50+
),
51+
Expanded(
52+
flex: 1,
53+
child: Container(
54+
padding: const EdgeInsets.all(8),
55+
child: Expanded(
56+
child: ListView.builder(
57+
itemCount: _clickEvents.length,
58+
itemBuilder: (context, index) {
59+
final event = _clickEvents[index];
60+
return Card(
61+
child: ListTile(
62+
title: Text('Event ${index + 1}'),
63+
subtitle: Text(
64+
'Name: ${event['name'] ?? 'N/A'}\n'
65+
'Value: ${event['value'] ?? 'N/A'}\n'
66+
'Series: ${event['seriesName'] ?? 'N/A'}\n'
67+
'Index: ${event['dataIndex'] ?? 'N/A'}',
68+
),
69+
),
70+
);
71+
},
72+
),
73+
),
74+
),
75+
),
76+
Expanded(
77+
flex: 2,
78+
child: Container(
79+
margin: const EdgeInsets.all(8),
80+
decoration: BoxDecoration(
81+
border: Border.all(color: Colors.grey),
82+
borderRadius: BorderRadius.circular(8),
83+
),
84+
child: GraphifyView(
85+
controller: _controller,
86+
initialOptions: const {
87+
"tooltip": {
88+
"trigger": "axis",
89+
"axisPointer": {"type": "shadow"}
90+
},
91+
"legend": {
92+
"data": ["Sales", "Marketing"]
93+
},
94+
"xAxis": {
95+
"type": "category",
96+
"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
97+
},
98+
"yAxis": {"type": "value"},
99+
"series": [
100+
{
101+
"name": "Sales",
102+
"type": "bar",
103+
"data": [120, 200, 150, 80, 70, 110, 130],
104+
"itemStyle": {"color": "#5470c6"}
105+
},
106+
{
107+
"name": "Marketing",
108+
"type": "bar",
109+
"data": [60, 100, 75, 40, 35, 55, 65],
110+
"itemStyle": {"color": "#91cc75"}
111+
}
112+
]
113+
},
114+
),
115+
),
116+
),
117+
],
118+
);
119+
}
120+
}

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ packages:
104104
path: ".."
105105
relative: true
106106
source: path
107-
version: "1.2.0"
107+
version: "1.2.1"
108108
integration_test:
109109
dependency: "direct dev"
110110
description: flutter

0 commit comments

Comments
 (0)