How to set polygon fill based on imported parameters from postGIS - ajax

Have successfully imported polygons in OpenLayers along with popup of pertinent data. Need guidance on assigning fill colors from parameters passed via ajax.
your textHoping to assign fill color based on setting parameter in json file. Currently using:
var polyStyle = new ol.style.Style({
fill: new ol.style.Fill({
color: [12,240,60]
}),
stroke: new ol.style.Stroke({
color: [0,0,0], width: 1
})
});
to load the following:
const layer = new ol.layer.Vector({
source: new ol.source.Vector({
features:features,
projection: 'EPSG: 3857'
}),
style: polyStyle
});
I next tried the following as a test based on the "settings feature the file:
// Polygons style
var setfcolor = function(features) {
console.log(features);
var fcolor;
if (feature.get("setting")=='Carbonate'){
fcolor = "blue";
} else if (feature.get("setting")=='Clastic: continental'){
fcolor = "yellow";
} else if (feature.get("setting")=='Extrusive: mafic'){
fcolor = "brown";
}
};
But it fails and reverts to all black.
Snippet of json file is:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-45.499757432,
60.988125868
],
[
-45.49967049,
60.988157751
],
[
-45.497458466,
60.989470026
],
[
-45.487258845,
60.995518876
],
[
-45.483858593,
60.999870372
],
[
-45.483858591,
60.99987019
],
[
-45.465241806,
60.991366687
],
[
-45.450273556,
60.988997409
],
[
-45.422944921,
60.990687369
],
[
-45.42294477,
60.990687194
],
[
-45.419225021,
60.984549241
],
[
-45.412472331,
60.973399399
],
[
-45.502278621,
60.96070259
],
[
-45.525166866,
60.957726342
],
[
-45.544395412,
60.955624111
],
[
-45.572353843,
60.951692596
],
[
-45.655768925,
60.94244974
],
[
-45.670854236,
60.94123391
],
[
-45.693899808,
60.940200373
],
[
-45.664305174,
60.947778021
],
[
-45.659448977,
60.949020163
],
[
-45.648191047,
60.951923402
],
[
-45.636669092,
60.954825483
],
[
-45.565410441,
60.967827923
],
[
-45.523123774,
60.979977384
],
[
-45.517219284,
60.981999
],
[
-45.517218946,
60.981999115
],
[
-45.5059008,
60.985872696
],
[
-45.499757432,
60.988125868
]
]
]
},
"properties": {
"setting_ty": "Supracrustal",
"setting": "Sedimentary and/or volcanic: undivided",
"lithology": "Basalt, sandstone, conglomerate",
"colour_cmy": "20 40 70 0",
"colour": "247"
}
},
[Polygons and popups working](https://i.stack.imgur.com/TqbV8.jpg)

strong text Got a good lead from Mike user:10118270 and applied it.Replaced the following code
var polyStyle = new ol.style.Style({
fill: new ol.style.Fill({
color: [12,202,50]
}),
stroke: new ol.style.Stroke({
color: [0,0,0], width: 1
})
});
with the following code:
// Polygons style
const fillColors = {
'Slope and deep water': [100,100,100,1],
'Intrusive: syenitic': [240,10,10,1],
'Intrusive: gabbroic': [240,10,10,1],
'Intrusive: anorthositic': [240,10,10,1],
'Intrusive: tonalitic-granodioritic': [240,10,10,1],
'Intrusive: granitic':[240,10,10,1],
'Intrusive: undivided': [230,10,10,1],
'Sedimentary: undivided': [250,250,10,1],
'Clastic: shallow marine': [240,240,20,1],
'Clastic: continental': [255,255,1,1],
'Clastic: deltaic and nearshore': [240,240,20,1],
'Marine sedimentary: undivided': [230,230,10,1],
'Extrusive: mafic': [250,200,10,1],
'Sedimentary and/or volcanic: undivided': [250,120,10,1],
'Carbonate': [10,40,255,1],
'Metamorphic: undivided': [230,10,240,1],
'ice': [250,250,250,1],
};
const style = new ol.style.Style({
fill: new ol.style.Fill(),
stroke: new ol.style.Stroke({
color: [0, 0, 0, 1],
width: 0.5,
}),
});
strong text The end result is shown on the image.
geologic polygon

Related

How to Display value in chart js Incline [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 days ago.
Improve this question
how to display the point value incline.
I have a problem with ChartJS: I am using Laravel and wanna to show the point value as incline. can you all help a beginner like me
enter image description here
here is my code : im using PHP
enter image description here
$chartjs = app()->chartjs
->name('projectSummaryByTeam')
->type('line')
->size(['width' => 350, 'height' => 200])
->labels($graphInfo[0])
->datasets([
[
"label" => "Acumulative (Plan)",
'data' => $graphInfo[1],
'type' => 'line',
'borderColor' => "blue",
'backgroundColor' => "blue",
'pointBackgroundColor' => "blue",
'pointBorderColor' => "blue",
'yAxisID' => 'first-y-axis',
'order' => 1,
'fill' => false,
],
[
"label" => "Acumulative (Actual)",
'data' => $graphInfo[2],
'type' => 'line',
'backgroundColor' => $graphActualLineColour,
'borderColor' => $graphActualLineColour,
'pointBackgroundColor' => $graphActualLineColour,
'pointBorderColor' => $graphActualLineColour,
'yAxisID' => 'first-y-axis',
'order' => 2,
'fill' => false,
],
])
here is the next..
the option that work as the animation and display the data
->optionsRaw("
{
plugins: {
colorschemes: {
scheme: 'tableau.Tableau10'
},
datalabels: {
display: false
}
},
tooltips: {
mode: 'index',
callbacks: {
label: function (tooltipItem, data) {
var tooltipValue = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
return parseInt(tooltipValue).toLocaleString();
}
}
},
animation: {
duration: 0,
onComplete: function () {
var chartInstance = this.chart,
ctx = chartInstance.ctx;
ctx.textAlign = 'top';
ctx.fillStyle = 'rgba(0, 0, 0, 1)';
ctx.textBaseline = 'bottom';
// Loop through each data in the datasets
this.data.datasets.forEach(function (dataset, i) {
var meta = chartInstance.controller.getDatasetMeta(i);
meta.data.forEach(function (bar, index) {
var data = parseInt(dataset.data[index]).toLocaleString();
ctx.fillText(data, bar._model.x, bar._model.y - 5);
});
});
}
},
scales: {
xAxes: [{
gridLines: {
color: [$arra],
}
}],
yAxes: [
{
id: 'first-y-axis',
type: 'linear',
gridLines: {
display:false
},
ticks: {
beginAtZero: true,
userCallback: function(value, index, values) {
return value.toLocaleString(); // this is all we need
},
},
},
]
}
}"
);

ReactQuill default fonts (sans serif, serif and monospace) not working

I have this react component, and I try to change the font of a text but it's hasn't effect.
This is my component:
<ReactQuill
theme="snow"
value={value}
onChange={onChange}
modules={QuillEditorControlled.modules}
// formats={QuillEditorControlled.formats}
/>
This is my modules JSON:
{
toolbar: [
// [{ header: [1, 2, 3, 4, 5, 6, false] }],
[{ font: [] }], // fonts
[{ size: ["8px", "10px", "12px", "14px", "16px", "18px", "20px", "24px"] }], // custom dropdown
["bold", "italic", "underline", "strike", "clean"], // toggled buttons
[
{ list: "ordered" },
{ list: "bullet" },
{ indent: "-1" }, // outdent
{ indent: "+1" }, // indent
{ align: [] }, // text alignment
],
[
// { direction: "rtl" }, // text direction
{ script: "super" }, // superscript
{ script: "sub" }, //subscript
],
[
{ color: [] }, // font color
{ background: [] }, // font background color
],
["link", "image"],
],
}
This is how the component looks:

Apexcharts - bars are too small

I am using a timeline chart from Apexcharts 3.19.0 and I noticed that every time I add a new vertical "category" the bars start to shrink. Is it possible to set the bar height a fixed size?
I am building a timeline chart that represents a production line. Bars are the production and the categories are the machines. And one build is related only to one machine.
This is the series that I pass and if I continue to add new machines bars continue to shrink.
I noticed that Apexcharts makes every bar with such height that every row can take all bars, but I don't need this in my case.
[
{
"name": "B-2004281001-6763",
"data": [
{
"x": "Cube 3-1",
"y": [
1588068083109,
1588071676403
],
}
]
},
{
"name": "B-2004281000-8133",
"data": [
{
"x": "BiZon Prusa i3 Steel-2",
"y": [
1588068021615,
1588075213496
],
}
]
},
{
"name": "B-2004281001-9110",
"data": [
{
"x": "BiZon Prusa i3 Steel-2",
"y": [
1588068068356,
1588078856311
],
}
]
}
]
That's how my chart looks like
My Chart
I had a similar issue and I got around it by using a common shared "x" value ("Production" in your example) and setting "name" values in the series data arrays that were then displayed by dataLabels.
So your modified data:
[
{
name: "B-2004281001-6763",
data: [{ name: "Cube 3-1", x: "Production", y: [ 1588068083109, 1588071676403 ] }]
},
{
name: "B-2004281000-8133",
data: [{ name: "BiZon Prusa i3 Steel-2", x: "Production", y: [1588068021615, 1588075213496 ] }]
},
{
name: "B-2004281001-9110",
data: [{ name: "BiZon Prusa i3 Steel-2", x: "Production", y: [1588068068356, 1588078856311 ], } ]
}
]
and the corresponding dataLabels option (black text color for visibility)
dataLabels: {
enabled: true,
formatter: function(val, opts) {
return opts.w.config.series[opts.seriesIndex].data[opts.dataPointIndex].name;
},
style: {
colors: ["#000000"]
}
}
Check it out here

ruby fill data in chart.js

I'm new in ruby programming and I am sticky
I would like to copy data from mesdata to data in data table.
data = [
{
data: Array.new(4) {},
backgroundColor: [
'#F7464A',
'#46BFBD',
'#FDB45C',
'#32CD32',
],
hoverBackgroundColor: [
'#FF6384',
'#36A2EB',
'#FFCE56',
'#00FF00',
],
},
]
mesdata = [10,20,20,40]

Projection path there; but the path is only 1px by 1px?

I am trying to project a geojson file, which has a default projection type.
My path lines are appearing in the console inspector:
But the lines are only 1px by 1px, so they do not appear. What is happening?
My code:
var mapWidth = 60;
var mapHeight = 90;
var projection = d3.geo.mercator().scale([100]);
var path = d3.geo.path()
.projection(projection);
(function run() {
d3.json("./data/output.geojson", function(error, map) {
var chart = d3.select("#charts").selectAll("svg")
.data(map.features)
.enter()
.append("svg")
.attr("width", mapWidth)
.attr("height", mapHeight)
.append("g")
chart
.append("path")
.attr("d", path)
.style("fill","steelblue");
});
})()
Geojson is as following (this is a snippet):
{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "neighborhood": "Battery Park City", "boroughCode": "1", "borough": "Manhattan", "#id": "http:\/\/nyc.pediacities.com\/Resource\/Neighborhood\/Battery_Park_City" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -74.013754000000176, 40.71369 ], [ -74.014262000000187, 40.710928000000195 ], [ -74.016542000000186, 40.704733000000275 ], [ -74.016174, 40.702572000000174 ], [ -74.01563, 40.701862000000233 ], [ -74.015127, 40.701390000000259 ], [ -74.014008, 40.701043000000325 ], [ -74.013959214170356, 40.700965860994032 ], [ -74.01410490300087, 40.700510828386832 ], [ -74.

Resources