Is there any way to give gradient color to normal color property in flutter? - android-studio

I am using Bar Chart of fl_chart plugin. I want to give gradient color to bar graph. Below is the line where I want give color.
BarChartRodData(y: 12, color: Color(0xFF639ed1),width: 12)
But it is not possible to set gradient color to the ##color## property unless it is colors.
Is there any way to set gradient color to color property?? Please help me..

If you pass just one color, the solid color will be used, or if you pass more than one color, we use gradient mode to draw. then the gradientFrom, gradientTo and gradientColorStops
For an example ,
final List<Color> color = <Color>[];
color.add(Colors.blue[50]);
color.add(Colors.blue[100]);
color.add(Colors.blue);
final List<double> stops = <double>[];
stops.add(0.0);
stops.add(0.5);
stops.add(1.0);
Please refer https://pub.dev/documentation/fl_chart/latest/fl_chart/BarChartRodData-class.html for BarChartRodData class variables

Related

How to manually set a diverging color range

I am using Altair for Python and my current code uses a redyellowblue color scheme which uses the middle color (yellow) accordingly to my domainMid parameter.
color=alt.Color('Spline_WW_Diff_Trend:Q', scale=alt.Scale(scheme='redyellowblue',reverse=True, domain=[-3.57,2.270], domainMid=0, clamp=True), legend=alt.Legend(title="Trend"))
Which gives me:
I need to replace the yellow color with the white color. I've switched scheme to range and tried different combinations of Scale parameters, but it doesn't respect my domainMid.
Example:
color=alt.Color('Spline_WW_Diff_Trend:Q', scale=alt.Scale(range=['#D4322C', 'white', '#4A74B4'],reverse=True, domain=[-3.57,2.270], domainMid=0, clamp=True), legend=alt.Legend(title="Trend"))
This gives me:
You can notice that the first column (which is all value 0) is showing reddish and not white (as it was supposed to be).
How can I have the same result as in the color scheme (picture one), but, with white instead of yellow?
Edit:
The same goes for.
range=['blue', 'lightblue', 'white', 'pink', 'red']
The mid color is light-blue, not white.
Edit 05/12/2022:
Just to clarify, I would like to achieve this same color scheme:
.
This heatmap was created in R, by using the RdYlBu color pallete (the one with 11 colors) and overwrite the middle (6th color) with white. Then, they increased the number of colors in the pallete to 99, to make the fade look more fluid. Does anyone has any idea on how to achieve that in Altair?
The easiest approach would be to set range='diverging', or to use one of the built-in diverging color schemes. For example:
import altair as alt
import pandas as pd
import numpy as np
df = pd.DataFrame({'x': np.arange(-10, 20)})
alt.Chart(df).mark_rect().encode(
x='x:O',
color=alt.Color('x:Q',
scale=alt.Scale(domainMid=0, scheme='redblue'))
)
If it's important to you that the center value is exactly white, you could use a condition to override the colormap for this value. For example:
alt.Chart(df).mark_rect().encode(
x='x:O',
color=alt.condition(
'datum.x == 0',
alt.value('white'),
alt.Color('x:Q', scale=alt.Scale(domainMid=0, scheme='redblue')))
)

How to adjust style of table cell border?

When I add a cell to a table, I can manipulate its thickness (borderBottomSize), its color (borderBottomColor) but not its style (dashed, dotted, longdashed, ...).
When I read the code, the PhpOffice\PhpWord\Style\Cell extends the PhpOffice\PhpWord\Style\Border.
And the border class has the attribute borderBottomStyle.
But how to configure that?
I also looked into the PhpOffice\PhpWord\Style\Line, there I can find some "dashStyles", but none of them are working...
My question: How to change style of border (from strong line to for example dotted)?
You can define the style of the border by using the cell style property borderStyle. By default, it's set to solid, but you can use other values like dashed, dotted, double, etc. Sadly, this feature is not documented so I don't know all the available styles.
Don't forget to add a border size as well, otherwise no border will be rendered.
Example for a dotted cell:
$dottedCell = $tableRow->addCell($cellWidth, ['borderStyle' => 'dotted', 'borderSize' => 6]);

Blue color table border using docx4j

I'm using docx4j to create a docx file. I want my table border to be blue colored but it is only showing black.how to do this?
Here is my code:
table.setTblPr(new TblPr());
CTBorder border = new CTBorder();
border.setColor("FFF");
border.setSz(new BigInteger("0"));
border.setSpace(new BigInteger("0"));
border.setVal(STBorder.SINGLE);
TblBorders borders = new TblBorders();
borders.setBottom(border);
borders.setLeft(border);
borders.setRight(border);
borders.setTop(border);
borders.setInsideH(border);
borders.setInsideV(border);
table.getTblPr().setTblBorders(borders);
You need to set the color attribute of the border in question. Your example code appears to have you setting a colour of 'FFF' which obviously won't work if it needs to be blue! I would suggest trying a straight blue in hex and going from there. For example a (very) standard blue would be:
CTBorder border = new CTBorder();
border.setColor("0000FF");

d3.js color range and lighter color range

I would like to have two color ranges, the second one must consist off the same colors, but lighter.
rangeLength=10
color = d3.scale.linear().domain([1,rangeLength]).range(['red', 'blue']);
colorLigher= d3.scale.linear().domain([1,rangeLength]).range(['red'.lighter(10), 'blue'.lighter(10)]);
Obviously doesn't work, as 'red' is a string.
Thanks in advance
You can use the brighter() function (see the documentation):
length=10
color = d3.scale.linear().domain([1,length]).range(['red', 'blue']);
colorLighter= d3.scale.linear().domain([1,length])
.range([d3.rgb('red').brighter(), d3.rgb('blue').brighter()]);

HighCharts: Color of label according to the color of pie slice

Title of this questions says everything. I only found out how to change the color of connectors. If I delete the color: option, they´re all grey. I tried to put in the field with stored colors in hex, with no result, stayed black.
In dataLabels.formatter you have access to this.point.color. So simple set useHTML: true for dataLabels, and create spans with specified colors.
the formatter function gives you a callback object, which has a color property that can be set with the color of your choice
formatter: (format) ->
format.color = #point.color

Resources