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

Compute gradient color from bar height

parent 93fb581b
No related branches found
No related tags found
1 merge request!16Resolve "Compute gradient color from bar height"
Pipeline #4495 passed
This commit is part of merge request !16. Comments created here will be created in the context of that merge request.
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