Openlayers Draw Interaction - reactjs

Openlayers Draw Interaction
Above is the link to the Openlayers interaction that I'm using. I want to use this interaction to limit users to only draw a north aligned bounding box. Out of the box that's not how the Draw interaction functions. Is there a way to enforce the drawing to be that of a north aligned bounding box? Or is there a means of making the draw interaction behave as the Extent Interaction?
Openlayers Extent Interaction
I'm using the latest version of Openlayers and here is my draw interaction configuration:
const styles = [
new Style({
stroke: new Stroke({
color: '#017e01',
width: 2.25,
}),
fill: new Fill({
color: 'rgba(36, 37, 42, .25)',
}),
}),
];
const source = new VectorSource();
const vector = new VectorLayer({
projection: 'ESPG4326',
source,
style: new Style({
fill: new Fill({
color: 'rgba(36, 37, 42, .25)',
}),
stroke: new Stroke({
color: '#017e01',
width: 2,
}),
image: new Circle({
radius: 7,
fill: new Fill({
color: '#017e01',
}),
}),
}),
});
const draw = new Draw({
style: styles,
source,
condition: olEvents.shiftKeyOnly,
type: 'Polygon',
});

Related

How to remove antd donut chart hover and select effect

In the donut chart in #ant-design/plots,
There is a black border around the individual sections of the donut chart when hovered.
The individual section is translated away from the center when selected.
How to stop/ control these behavior?
const config = {
appendPadding: 10,
data,
angleField: 'value',
colorField: 'type',
radius: 1,
innerRadius: 0.6,
label: {
type: 'inner',
offset: '-50%',
content: '{value}',
style: {
textAlign: 'center',
fontSize: 14,
},
},
interactions: [
{
type: 'element-selected',
},
{
type: 'element-active',
},
],
statistic: {
title: false,
content: {
style: {
whiteSpace: 'pre-wrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
},
content: 'AntV\nG2Plot',
},
},
};
Deal with interactions in config
There is a black border around the individual sections of the donut chart when hovered.
Remove the object type:'element-active'
Note: Removing is conveyed by commenting out in the code below.
interactions: [
...
// {
// type: 'element-active',
// },
]
The individual section is translated away from the center when selected.
Remove the object type: 'element-selected'
Note: Removing is conveyed by commenting out in the code below.
interactions: [
...
// {
// type: 'element-selected',
// },
]
To achieve both you can simply remove the interactions from the config object.

React-chartjs-2: change the backgroundColor color to a gradient

I'm using Chart.JS with React and want to change the background color to Gradient Background I know how to do it in vanilla js but I'm not sure how to do it in React
Chart
const [graphData, setGraphData] = React.useState({
labels: dataa.map((time) => time.time),
datasets: [
{
label: "just for test",
data: dataa.map((data) => data.percentage),
// i want to use Gradiant background here
backgroundColor: "rgb(184 188 23 / 75%)",
borderColor: "black",
tension: 0.4,
fill: true,
cubicInterpolationMode: "monotone",
},
],
});

FeatureLayer - won't render

I have a rather simple code that creates a FeatureLayer where I try to add some client side graphic.
facilitiesLayer = new FeatureLayer({
title: 'Facilities layers',
objectIdField: 'id',
source: [
new Graphic({
geometry: new Point({ longitude: -96.1034353, latitude: 41.5333259 }),
attributes: {
id: 1,
},
}),
],
renderer: new SimpleRenderer({
symbol: new SimpleMarkerSymbol({
size: 32,
color: '#4652C2',
outline: {
color: 'rgba(137,144,215,0.7)',
width: 2,
},
}),
}),
});
mapView.current!.map.add(facilitiesLayer);
after I add the layer to the map I immediately see this in console. If I comment out add layer addition, the map is properly displayed, meaning all of the ESRI stuff is created correct.
How do I find where this conversion fails?
using #arcgis/core 4.18.0

Why Openlayers z-Index doesn`t put zIndex 16 over zIndex -1

I'm using Ol 4.6.5 and I have a mistake:
const geoVector = new ol.source.Vector({
features: new ol.format.GeoJSON().readFeatures(geoJSON)
});
const tilesStyle = new ol.style.Style({
zIndex: -1,
stroke: new ol.style.Stroke({
color: "rgb(53,198,234, 0.8)",
width: 6
})
});
this.panoramasTracksLayer = new ol.layer.Vector({
source: geoVector,
style: tilesStyle
});
map.addLayer(this.panoramasTracksLayer);
Here I fetch GEOJSON layer from server
feature = new ol.Feature(new ol.geom.Point(ol.proj.fromLonLat(point as any)));
feature.setStyle([
new ol.style.Style({
zIndex: 15,
image: new ol.style.Circle({
radius: 20,
stroke: new ol.style.Stroke({
color: "#fff",
width: 2
}),
fill: new ol.style.Fill({
color: "rgb(53,198,234)"
})
})
}),
new ol.style.Style({
zIndex: 16,
text: new ol.style.Text({
text: "\u27A4",
textAlign: "center",
textBaseline: "middle",
font: "bold 24px",
scale: 2.7,
rotateWithView: true,
rotation: -1.6 + pRotation,
fill: new ol.style.Fill({
color: "#111"
})
})
})
]);
source.addFeature(feature);
And above I add a feature to my map. Why openLayers is painting my panoramasTracks over my features? And how to solve this problem?
You can set the Z-index on the layer itself
this.panoramasTracksLayer = new ol.layer.Vector({
source: geoVector,
style: tilesStyle,
zIndex: -1
});

Extjs Charting Series with dashed line

I am using Extjs 4 to create a line chart. Now I want to create a chart series with a dashed line. Currently my code looks the following way:
series: [{
type: 'line',
axis: 'left',
xField: 'name',
yField: 'data1',
style: {
fill: '#18428E',
stroke: '#18428E',
'stroke-width': 3
},
markerConfig: {
type: 'circle',
size: 4,
radius: 4,
'stroke-width': 0,
fill: '#18428E',
stroke: '#18428E'
}
}, ...
I tried setting the 'border-style' to 'dashed' but this neither works.
Is this possible in ExtJs Charting?
You just missed one property to get the dashed lines working. You need to add stroke-dasharray property as well. Here is the updated code:
style: {
fill: '#18428E',
stroke: '#18428E',
'stroke-width': 3,
'stroke-dasharray': 10 // You need to add this!
},
markerConfig: {
type: 'circle',
size: 4,
radius: 4,
'stroke-width': 0,
fill: '#18428E',
stroke: '#18428E'
},
You will have to play with the value (10 in my case) to get your desired dash length. Note that this will not work with IE (since its using VML to render the graph). Other browsers should render it properly.
In ExtJS 5.x or 6.x when using sencha-charts (not ext-charts package), stroke-dasharray won't work. After lot of effort, discovered the lineDashed property of Ext.draw.sprite.Sprite works like a charm. So, if you are using sencha-chart package the style config should look like :
style: {
fill: '#18428E',
stroke: '#18428E',
'stroke-width': 3,
lineDash: [10,10] // Draws dashed lines
}
Hope this will be useful for anyone having problem with sencha-charts.

Resources