Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis min axis max fix #95

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions charts_web/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Generated file. Do not edit.
//

import FlutterMacOS
import Foundation


func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
}
11 changes: 11 additions & 0 deletions charts_web/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/snoopy/fvm/versions/stable
FLUTTER_APPLICATION_PATH=/Users/snoopy/Documents/infinum/flutter-charts/charts_web
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json
12 changes: 12 additions & 0 deletions charts_web/macos/Flutter/ephemeral/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/snoopy/fvm/versions/stable"
export "FLUTTER_APPLICATION_PATH=/Users/snoopy/Documents/infinum/flutter-charts/charts_web"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
76 changes: 54 additions & 22 deletions example/lib/charts/scrollable_chart_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
final Random _rand = Random();
final double _difference = _rand.nextDouble() * 15;

targetMax = 3 + ((_rand.nextDouble() * _difference * 0.75) - (_difference * 0.25)).roundToDouble();
targetMax = 3 +
((_rand.nextDouble() * _difference * 0.75) - (_difference * 0.25))
.roundToDouble();
_values.addAll(List.generate(minItems, (index) {
return 2 + _rand.nextDouble() * _difference;
}));
Expand All @@ -56,7 +58,10 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
final targetArea = TargetAreaDecoration(
targetMax: targetMax + 2,
targetMin: targetMax,
colorOverTarget: Theme.of(context).colorScheme.error.withOpacity(_showBars ? 1.0 : 0.0),
colorOverTarget: Theme.of(context)
.colorScheme
.error
.withOpacity(_showBars ? 1.0 : 0.0),
targetAreaFillColor: Theme.of(context).colorScheme.error.withOpacity(0.2),
targetLineColor: Theme.of(context).colorScheme.error,
targetAreaRadius: BorderRadius.circular(12.0),
Expand All @@ -73,15 +78,20 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
barItemBuilder: (data) {
return BarItem(
color: targetArea.getTargetItemColor(
Theme.of(context).colorScheme.primary.withOpacity(_showBars ? 1.0 : 0.0), data.item),
Theme.of(context)
.colorScheme
.primary
.withOpacity(_showBars ? 1.0 : 0.0),
data.item),
radius: const BorderRadius.vertical(
top: Radius.circular(24.0),
),
);
},
),
behaviour: ChartBehaviour(
scrollSettings: _isScrollable ? ScrollSettings() : ScrollSettings.none(),
scrollSettings:
_isScrollable ? ScrollSettings() : ScrollSettings.none(),
onItemClicked: (item) {
print('Clciked');
setState(() {
Expand All @@ -100,13 +110,15 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
endWithChart: false,
lineWidth: 2.0,
axisStep: 2,
lineColor: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
lineColor:
Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
),
VerticalAxisDecoration(
endWithChart: false,
lineWidth: 2.0,
axisStep: 7,
lineColor: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.8),
lineColor:
Theme.of(context).colorScheme.primaryContainer.withOpacity(0.8),
),
GridDecoration(
showVerticalGrid: true,
Expand All @@ -116,25 +128,32 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
verticalAxisStep: 1,
horizontalAxisStep: 1,
textStyle: Theme.of(context).textTheme.caption,
gridColor: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
gridColor:
Theme.of(context).colorScheme.primaryContainer.withOpacity(0.2),
),
targetArea,
SparkLineDecoration(
fill: true,
lineColor: Theme.of(context).primaryColor.withOpacity(!_showBars ? 0.2 : 0.0),
lineColor: Theme.of(context)
.primaryColor
.withOpacity(!_showBars ? 0.2 : 0.0),
smoothPoints: _smoothPoints,
),
],
foregroundDecorations: [
ValueDecoration(
alignment: _showBars ? Alignment.bottomCenter : Alignment(0.0, -1.0),
textStyle: Theme.of(context).textTheme.button!.copyWith(
color: (_showBars ? Theme.of(context).colorScheme.onPrimary : Theme.of(context).colorScheme.primary)
color: (_showBars
? Theme.of(context).colorScheme.onPrimary
: Theme.of(context).colorScheme.primary)
.withOpacity(_isScrollable ? 1.0 : 0.0)),
),
SparkLineDecoration(
lineWidth: 2.0,
lineColor: Theme.of(context).primaryColor.withOpacity(!_showBars ? 1.0 : 0.0),
lineColor: Theme.of(context)
.primaryColor
.withOpacity(!_showBars ? 1.0 : 0.0),
smoothPoints: _smoothPoints,
),
BorderDecoration(
Expand All @@ -155,10 +174,13 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
border: Border.all(),
shape: BoxShape.circle,
),
child: Text('${_selected != null ? _values[_selected!].toStringAsPrecision(2) : '...'}'),
child: Text(
'${_selected != null ? _values[_selected!].toStringAsPrecision(2) : '...'}'),
),
),
backgroundColor: Theme.of(context).scaffoldBackgroundColor.withOpacity(_isScrollable ? 0.5 : 0.8),
backgroundColor: Theme.of(context)
.scaffoldBackgroundColor
.withOpacity(_isScrollable ? 0.5 : 0.8),
),
],
);
Expand All @@ -177,7 +199,9 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
children: [
Expanded(
child: SingleChildScrollView(
physics: _isScrollable ? ScrollPhysics() : NeverScrollableScrollPhysics(),
physics: _isScrollable
? ScrollPhysics()
: NeverScrollableScrollPhysics(),
controller: _controller,
scrollDirection: Axis.horizontal,
child: AnimatedChart(
Expand All @@ -191,13 +215,17 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
AnimatedContainer(
duration: Duration(milliseconds: 350),
decoration: BoxDecoration(
gradient: LinearGradient(begin: Alignment.centerRight, end: Alignment.centerLeft, colors: [
Colors.white,
Colors.white.withOpacity(0.0),
], stops: [
0.5,
1.0
]),
gradient: LinearGradient(
begin: Alignment.centerRight,
end: Alignment.centerLeft,
colors: [
Colors.white,
Colors.white.withOpacity(0.0),
],
stops: [
0.5,
1.0
]),
),
width: _fixedAxis ? 34.0 : 0.0,
height: MediaQuery.of(context).size.height * 0.4,
Expand All @@ -211,10 +239,14 @@ class _ScrollableChartScreenState extends State<ScrollableChartScreen> {
showValues: true,
endWithChart: false,
axisValue: (value) => '$value E',
legendFontStyle: Theme.of(context).textTheme.caption,
legendFontStyle:
Theme.of(context).textTheme.caption,
valuesAlign: TextAlign.center,
valuesPadding: const EdgeInsets.only(right: 8.0),
lineColor: Theme.of(context).colorScheme.primaryContainer.withOpacity(0.8),
lineColor: Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.8),
)
]
: [],
Expand Down
Loading
Loading