Using a LinearGradient as fill color when building shapes in the Angular Kendo Drawing API - angular-kendo

I'm attempting to build a rectangle with a linear gradient fill using code similar to:
const gradient = new LinearGradient({
stops: [
new GradientStop({
color: "gray",
offset: 0,
opacity: 0
}),
new GradientStop({
offset: 0.5,
color: "orange",
opacity: 0.8
})]
});
const geometry = new GeomRectangle([0, 0], [100, 25]);
const rect = new Rect(geometry, {
stroke: { color: "black", width: 1 },
fill: { color: gradient, opacity: 1 } <- Compile error wants string
});
However, in the TypeScript FillOptions definition, color is defined as string. I can't find an example in the Kendo docs that describe how this might work. I'd be grateful for any insights.

You can pass the gradient directly to the "fill" option of both a Path or a Rect:
const gradient = new LinearGradient({
name: "LG1",
stops: [
{
offset: 0,
color: "gray",
opacity: 0
}, {
offset: 0.5,
color: "orange",
opacity: 0.8
}
]
});
// Create the square border by drawing a straight path
const path = new Path({
stroke: {
color: "#9999b6",
width: 2
},
fill: gradient
});
const anotherRect = new RectGeometry(
new Point(100, 100),
new Size(50, 50)
);
const drawingRect = new Rect(anotherRect, {
stroke: {
color: "#9999b6",
width: 2
},
fill: gradient
});
EXAMPLE

Related

How to make a colored circle pointer with white center in Apache eCharts?

I'm trying to re-create this example picture using Apache eCharts:
This is what my Apache eCharts version looks like so far:
As you can see, I have almost finished re-creating it.
The only part I can't figure out is how to make the small circle pointer to be a colored circle with white center. The color of the pointer should match the color of axis line it is on.
Currently mine is grey, which doesn't look good.
Here is my code:
const gaugeOption = {
series: [
{
data: gaugeData,
type: 'gauge',
startAngle: 180,
endAngle: 0,
min: 0,
max: 100,
splitNumber: 3,
pointer: {
icon: 'circle',
length: '12%',
width: 50,
offsetCenter: [0, '-90%'],
itemStyle: {
color: '#FFFFFF',
borderColor: 'auto', // This doesn't work :(
borderWidth: 5,
shadowColor: 'rgba(10, 31, 68, 0.5)',
shadowBlur: 2,
shadowOffsetY: 1,
},
},
axisLine: {
show: true,
roundCap: true,
lineStyle: {
width: 9,
color: [
[0.5, '#e76262'],
[0.54],
[0.66, '#f9cf4a'],
[0.7],
[0.83, '#eca336'],
[0.87],
[1, '#3ece80'],
],
},
},
axisTick: {
length: 2,
lineStyle: {
color: '#8a94a6',
width: 2,
},
},
splitLine: {
show: false,
},
axisLabel: {
show: false,
},
title: {
show: false,
},
detail: {
rich: {
header: {
fontSize: 36,
fontWeight: 700,
fontFamily: 'Open Sans',
color: '#0a1f44',
},
subHeader: {
fontSize: 16,
fontWeight: 400,
fontFamily: 'Open Sans',
color: '#8a94a6',
},
},
formatter: ['{header|{value}}', '{subHeader|15-30-2022}'].join('\n'),
offsetCenter: [0, '-20%'],
valueAnimation: true,
},
},
],
}
EDIT:
I have also tried specifying the colors directly as per below. It makes no difference. The border or the circle pointer remains a grey color:
pointer: {
icon: 'circle',
length: '12%',
width: 50,
offsetCenter: [0, '-90%'],
itemStyle: {
color: '#FFFFFF',
borderColor: [
[0.5, '#e76262'],
[0.66, '#f9cf4a'],
[0.83, '#eca336'],
[1, '#3ece80'],
],
borderWidth: 5,
shadowColor: 'rgba(10, 31, 68, 0.5)',
shadowBlur: 2,
shadowOffsetY: 1,
},
},
The only way I can change it's color is to set it to a single static color, but that is not what I want, it should adapt to the color of the axis beneath it.
Set borderColor to a variable. Then change this variable when the gauge value is changed, depending on its new position.
You'll also have to use setOption() to make the change effective on the chart.
//update your variable however you want
myBorderColor = '#f00';
//then make the change to the chart
myChart.setOption({
series: [
{
pointer: {
itemStyle : {
borderColor: myBorderColor
},
},
},
],
});

Flutter User ColorFiltered to dark image with matrix

I want in flutter to user ColorFiltered, so i can make jpg image dark here is my code but i didn't get the right result, i don't understand matrix and how to change color this code was from internet, please any idea will be welcome.
ColorFiltered(
child: ColorFiltered(
child: Image.asset(
'myimage.jpg',
fit: BoxFit.fill,
),
colorFilter: ColorFilter.matrix(
[
//R G B A Const
-1, 0, 0, 0, 190, //
0, -1, 0, 0, 255, //
0, 0, -1, 0, 255, //
0, 0, 0, 1, 0, //
],
),
),
colorFilter: ColorFilter.mode(
Colors.white,
BlendMode.darken,
),
)
If you just want to make your image darker the better solution is probably just putting a transparent black Container over your image with a Stack widget:
Stack(children: <Widget>[
Image.network('https://picsum.photos/250?image=9'),
Positioned.fill(
child: Opacity(
opacity: 0.5,
child: Container(
color: const Color(0xFF000000),
),
),
),
]),
If you really want to use ColorFiltered let me know but you can do something like this:
ColorFiltered(
child: Image.network('https://picsum.photos/250?image=9'),
colorFilter: const ColorFilter.mode(
Color(0xFF3D3D3D),
BlendMode.darken,
),
),
Keep in mind that ColorFiltered will not just add a new grey layer over the image. It transforms every pixel of the image separately.
As per the documentation:
This widget applies a function independently to each pixel of child's content, according to the ColorFilter specified.
there is the result based on my search and a little refactoring :
static ColorFilter brightnessAdjust(double value) {
if (value >= 0.0) {
value = value * 255;
} else {
value = value * 100;
}
List<double> matrix;
if (value == 0) {
matrix = identityMatrix;
} else {
matrix = [
1,
0,
0,
0,
value,
0,
1,
0,
0,
value,
0,
0,
1,
0,
value,
0,
0,
0,
1,
0
];
}
return ColorFilter.matrix(matrix);
}
positive value to lighten and negative value to darken (-1 to 1), zero no change anything

how to make multi color gauge in flutter?

How to make this type of gauge in flutter application?
Image
check this library :- fl_chart
it has all the charts and graph and you can customise it as you want
you can use this package :
syncfusion_flutter_gauges
then import this package in your dart file:
import 'package:syncfusion_flutter_gauges/gauges.dart';
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfRadialGauge(),
),
);
}
Normal radial slider
To create a normal radial slider, we need to disable the labels and ticks properties in the RadialAxis class and set the axis range values in the minimum and maximum properties based on our design needs.
To show 100 percent progress, we need to define the axis’s minimum value as 0 and maximum value as 100 as in the following code example.
SfRadialGauge(
axes: <RadialAxis>[
RadialAxis(minimum: 0,
maximum: 100,
showLabels: false,
showTicks: false,
axisLineStyle: AxisLineStyle(
cornerStyle: CornerStyle.bothCurve,
color: Colors.white30,
thickness: 25),
)
]
)
The range pointer will be the track and the marker pointer will be the thumb for the radial slider. You can also set a gradient for the range pointer as shown in the following code example.
SfRadialGauge(
axes: <RadialAxis>[
RadialAxis(
pointers: <GaugePointer>[
RangePointer(
value: 50,
cornerStyle: CornerStyle.bothCurve,
width: 25,
sizeUnit: GaugeSizeUnit.logicalPixel,
gradient: const SweepGradient(
colors: <Color>[
Color(0xFFCC2B5E),
Color(0xFF753A88)
],
stops: <double>[0.25, 0.75]
)),
MarkerPointer(
value: 50,
enableDragging: true,
markerHeight: 34,
markerWidth: 34,
markerType: MarkerType.circle,
color: Color(0xFF753A88),
borderWidth: 2,
borderColor: Colors.white54)
], )
]
)

Getting selected value from parallel coordinates chart using ngx-echarts

I'm having trouble on getting the events to work on my chart. I need to get the value of selected area of my parallel coordinates chart. I tried using chartDataRangeSelected but it does nothing when I select some data.
Here's my code:
<div echarts [options]="chartOption" class="demo-chart" (chartInit)="onChartInit($event)" (chartDataRangeSelected)="onChartSelect($event)"></div>
Chart config:
chartOption: EChartOption = {
title: {
text: 'Demo Parallel Coordinates',
subtext: 'data from macrofocus',
left: 'center',
top: 5,
itemGap: 0,
textStyle: {
color: '#000000'
},
z: 200
},
parallelAxis: this.makeParallelAxis(this.schema),
grid: [{
show: true,
left: 0,
right: 0,
top: '0',
bottom: 0,
borderColor: 'transparent',
backgroundColor: 'white',
z: 99
}],
parallel: {
top: '10%',
left: 100,
right: 100,
bottom: 100,
axisExpandable: true,
axisExpandCenter: 15,
axisExpandCount: 10,
axisExpandWidth: 60,
axisExpandTriggerOn: 'mousemove',
z: 100,
parallelAxisDefault: {
type: 'value',
nameLocation: 'start',
nameRotate: 25,
// nameLocation: 'end',
nameTextStyle: {
fontSize: 12
},
nameTruncate: {
maxWidth: 170
},
nameGap: 20,
splitNumber: 3,
tooltip: {
show: true
},
axisLine: {
// show: false,
lineStyle: {
width: 1,
color: '#000000'
}
},
axisTick: {
show: false
},
splitLine: {
show: false
},
z: 100
}
},
series: [
{
name: 'parallel',
type: 'parallel',
smooth: true,
lineStyle: {
color: '#577ceb',
width: 0.5,
opacity: 0.6
},
z: 100,
data: this.rawData
}
]
};
Function:
onChartSelect(e){
console.log(e);
}
Am I using the correct events for doing so? Your help will be much appreciated.
Thanks
according to eCharts document,
the selectDataRange Event emitted after range is changed in visualMap. https://www.echartsjs.com/en/api.html#events.datarangeselected,
which is chartDataRangeSelected of ngx-echarts mapped to.
And you can see that, it is an event related to visualMap. your charts does not have a visual map at all, so i guess the event will not be fired.
You can try chartAxisAreaSelected, as this is more related to your chart.

Google Charts: baseline not working with mirrorlog

I'm trying to create a chart using mirrorlog scale, and it seems to be ignoring the baseline; bars always start from 0.
function drawChart1() {
data = google.visualization.arrayToDataTable([
['', 'val', { role: 'style' }],
[' ', 0.6, 'red'],
]);
ops = {
height: 50,
hAxis: {
ticks: [0.1, 0.2, 0.3, 0.65, 1.0],
baseline: 0.3,
textPosition: 'out',
scaleType: 'mirrorLog',
},
chartArea: { height: '20%', backgroundColor: 'yellow', top: 3 },
fontSize: 8,
legend: { position: 'none' },
bar: { groupWidth: "15%" },
axes: {
y: {
0: { position: 'none' }
}
}
};
chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, ops);
}
jsfiddle