Skip to content
Snippets Groups Projects
Commit 604b3b71 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch '22-compute-gradient-color-from-bar-height' into 'master'

Resolve "Compute gradient color from bar height"

Closes #22

See merge request !16
parents 93fb581b 0502b39a
No related branches found
No related tags found
1 merge request!16Resolve "Compute gradient color from bar height"
Pipeline #4498 passed
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=0.0.14 app.versionName=0.0.15
app.versionCode=14 app.versionCode=15
Gradients uniformisation on bars of same charts.
Uniformisation des dégradés de couleur entre les barres du même graphique.
...@@ -55,7 +55,7 @@ class CustomBarChart extends StatelessWidget { ...@@ -55,7 +55,7 @@ class CustomBarChart extends StatelessWidget {
required double value, required double value,
required Color barColor, required Color barColor,
required double barWidth}) { required double barWidth}) {
final gradient = this.getGradient(barColor); final gradient = this.getGradient(barColor, value, this.getMaxCountsValue());
final borderColor = barColor.darken(20); final borderColor = barColor.darken(20);
return BarChartGroupData( return BarChartGroupData(
...@@ -75,10 +75,12 @@ class CustomBarChart extends StatelessWidget { ...@@ -75,10 +75,12 @@ class CustomBarChart extends StatelessWidget {
); );
} }
LinearGradient getGradient(Color baseColor) { LinearGradient getGradient(Color baseColor, double value, double maxValue) {
double alignmentTopValue = value != 0.0 ? -2 * maxValue / value + 1 : 0;
return LinearGradient( return LinearGradient(
begin: Alignment.topLeft, begin: Alignment(-1, alignmentTopValue),
end: Alignment(0.8, 1), end: Alignment(1, 1),
colors: <Color>[ colors: <Color>[
baseColor.lighten(30), baseColor.lighten(30),
baseColor, baseColor,
......
...@@ -3,7 +3,7 @@ description: Display scrobbles data and charts ...@@ -3,7 +3,7 @@ description: Display scrobbles data and charts
publish_to: 'none' publish_to: 'none'
version: 0.0.14+14 version: 0.0.15+15
environment: environment:
sdk: '^3.0.0' sdk: '^3.0.0'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment