Changing icon offset based on zoom level - mapbox-gl-js

I am trying to offset symbols of a symbol layer so that they don't interfere with a previous symbol layer (i.e. they don't overlap). I need to offset them as in both cases icon-allow-overlap needs to be set to true, as the symbols need to be viewable at all zoom levels. Ideally I'd like to do something like this:
"icon-offset": [
["zoom"],
12, [-16, 0],
22, [0, 0]
]
but that gives me an error:
array length 2 expected, length 5 found
Is there a way I can do what I want similar to what I was trying above? I know that icon-offset is not transitionable so that is why the above is failing.
Any help would be appreciated.
Thanks for your time.

The answer was to use a function:
"icon-offset": {
"stops": [
[12, [-16, 0]],
[22, [0, 0]]
]
}
More info on this can be found here

Related

Interrupt a line in Chart.js lines

I've a weird situation in chart.js, see the picture
Basically a dataset with 4 date and 4 numbers. All 4 numbers value are 1 (doesnt matter).
But actually the real data need to show just 2 intervals (1/1/2020 -> 2/2/2020) and (3/4/2021->6/6/2021). Basically without the segment in the middle.
In this case there is no way Chart.js would be able to understand to not drawn that segment, all values are 1 in all 4 different dates.
So the only solution in my mind is to sub divide all the intervals so I can place a NaN in the middle and use something like stepped:true for the line. But with a lot of data I basically double the numbers of dates making the graph more confusing.
So the question is.. Is there any way to specify for given point if it's a start or an end ?
Or maybe there is a better approach instead of a single line dataset?
Thank you.
Just pass 2 datasets:
const labels = Utils.months({count: 7});
const data = {
labels: labels,
datasets: [{
label: 'My First Dataset',
data: [65, 59, 80],
fill: false,
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
},{
label: 'My 2nd Dataset',
data: [null, null, null, 81, 56, 55, 40],
fill: false,
borderColor: 'rgb(75, 40, 192)',
tension: 0.1
}]
};
If You pass objects instead of arrays as data, then you do not even have to pad with nulls

How to show/hide labels according to zoom levels with expressions in mapbox-gl-js / maplibre-gl?

I have a point layer with an icon, and I would like to display the labels in addition to the icon only from a certain zoom level (9). I would like to avoid creating a dedicated label layer. Looking at the expression documentation, Stet and Zoom should give me the desired result, but it doesn't work.
Following this answer, I try to change the size of the text depending on the zoom level, but no matter the zoom, the text will always have the default size (here 7)
Am I missing something or is it a bug? I'm using Maplibre
layout: {
"icon-image": "border_crossing",
"icon-size": 0.5,
"icon-allow-overlap": true,
'text-field': ['get', 'loc_type'],
'text-variable-anchor': ['top'],
'text-radial-offset': 0.5,
'text-justify': 'auto',
"text-size": [ "step",
["zoom"],
0,0,
9,15,
7
]
}
There are various ways. One would be:
'text-field`: ["step", ["zoom"], "", 9, ["get", "loc_type"]]
It looks like you had a bug in your step code.

What is the file identifier for Fortran 90 in VS code?

I was trying to add vertical rules for Fortran code in VS code, with the following lines
{
"[fortran]":
{
"editor.rulers": [0, 1, 5, 6, 79, 120]
},
}
in settings.json, I was able to make it work for .f files. However, the .f90 files do not get any vertical lines. It seems to me that the language identifier [fortran] is only for Fortran 77 code, but I can not find any clue of such an identifier for Fortran 90 code. Could someone point it out to me?
By the way, I would need a separate vertical rule setting for Fortran 90 anyway, because the four leading vertical rules are only needed for Fortran 77 code.
Thanks in advance!
If you use the extension Modern Fortran, then the ID for fortran language is changed, as shown in the contribution page of the extension.
ID Name file extension
FortranFreeForm Fortran90 .f90 .F90 .f95 .F95 .f08 .F08
fortran_fixed-form Fortran .f .F .f77 .F77 .for .FOR .fpp .FPP
So if you want to set rulers for fixed form files, use
"[fortran_fixed-form]": {
"editor.rulers": [1,5,6,72,80]
}
for f90, use
"[FortranFreeForm]": {
"editor.rulers": [0, 1, 5, 6, 79, 120]
}
I am unable to test this but possibly one of these settings helps:
"files.associations": {
"*.f90": "fortran", // or the next
// "fortran90": "fortran"
},
if just using fortran90 doesn't work as in
{
"[fortran90]": {
"editor.rulers":
[0, 1, 5, 6, 79, 120]
},
}
With v1.63 (and later version) of vscode, the fortran_fixed-form is already changed to FortranFixedForm instead.
So you (and for others newly-started searching for the answer) probably should use
"[FortranFixedForm]": {
"editor.rulers": [1,5,6,72,80]
}
instead.

Highcharts Pyramid - same size of segments - despite the data value

I was wondering if it would be possible to ignore the sizes of segments in highcharts pyramid. I would like all segments to be of the same size despite the value. The reason is that sometimes differences between values may be quite significant and value of 1 - even being extremely important, becomes invisible when the next value is 500. Also, would like to be able to add a legend if possible. It would be nice to set a minimum size of a segment if not possible to get dynamic sizing disabled.
Thanks for your help!
Pawel
Yes, you can add additional data according to which the height of the segment will be calculated. Next, use keys option to map the values and show the right one in a tooltip and data label:
tooltip: {
pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.realY}</b><br/>'
},
series: [{
...
keys: ['name', 'realY', 'y'],
dataLabels: {
format: '<b>{point.name}</b> ({point.realY:,.0f})',
...
},
data: [
['Website visits', 15654, 1],
['Downloads', 4064, 1],
['Requested price list', 1987, 1],
['Invoice sent', 976, 1],
['Finalized', 846, 1]
]
}]
Live demo: https://jsfiddle.net/BlackLabel/e83fatk2/
API Reference: https://api.highcharts.com/highcharts/series.column.keys

Sorting By Excel Headers in MATLAB (High Level I/O)

Alright, so I feel like this should be a pretty simple problem, but I'm already struggling with it. Which is bad since I have a test next week and I barely understand half the stuff we need to know. that, however, is besides the point. What I need to do is write a function that takes in an Excel file and a Header (which will be a string we input). It then finds the Header in the file and sorts it (in alphabetical order if the column consists of characters or ascending if it has numbers).
Input:
Test Case:
scores = sortByHeader(x, 'Opponent');
scores => 'Opponent' 'Tech Points' 'Opponent Points'
'Clemson' [ 30] [ 27]
'Clemson' [ 39] [ 34]
'Duke' [ 49] [ 10]
'Florida State' [ 49] [ 44]
'Georgia' [ 24] [ 30]
'Iowa' [ 14] [ 24]
'Jacksonville State' [ 37] [ 17]
'Miami' [ 17] [ 33]
'Mississippi State' [ 42] [ 31]
'North Carolina' [ 24] [ 7]
'Vanderbilt' [ 56] [ 31]
'Virginia' [ 34] [ 9]
'Virginia Tech' [ 28] [ 23]
'Wake Forest' [ 30] [ 27]
I am mostly having trouble figuring out how to identify the header in the problem. So far I Have:
function[scores] = sortByHeader(File, Name)
[num, txt, raw] = xlsread(File); %// Reads in the file
%// Gives me the dimensions of the file
[r,c] = size(raw);
%// I want to look through all of the columns until I find the header I need
for i = 1:c
%// I'm attempting to search through the file here
if strcmp(raw(1, i), Name)
%// Here's my issue. When it finds the name, I am not sure what to do with it then
Name_Column = 1;
end
%// I tried to mask it, but this doesn't actually work.
raw(Name_Column) = raw;
%// How I plan to sort everything once I find it. Though I believe I need to adjust this slightly to solely account for the 'Name' Column.
scores = sort(raw, 'ascend');
I mostly need tips at this point. I should probably work on figuring this stuff out on my own, but that's easier said than done. Note: The headers will not always be in the same place and there can be any number of rows or columns.
Conveniently, the headers will always be in the first row of the variable 'raw' as you have defined above.
headerMatch = strcmp(raw, Name);
whichColumn = find(headerMatch(1,:));
This will return a logical array headerMatch with a 1 in the location of a match to your string, Name, and whichColumn will return the column number, since we're only looking in the first row.
Then it's a matter of pulling out the column you identified with those commands and sorting it, which is where you struggled before. There are a couple of ways to address cell arrays and it can seem inconsistent, but it comes down to what you want as the output. If you want a cell array that is a sub-section of your current array back, use parenthesis like you use for matrix addressing. If you are trying to get at the values inside the cells that you are addressing, use curly braces. See the difference in how you pull out a cell array of strings or the values to make a vector in the two sort calls below. The sort command is a little different for a cell array of strings vs a vector of numbers so that's why there are two different calls with two different argument formats. Just have to check which one you're dealing with first, then pass to the appropriate sort function.
if ischar(raw{2, whichColumn}) % ischar checks if the first cell we want to sort has numbers or letters in it
sortedColumn = sort(raw(2:end, whichColumn)); % Sort a cell array of strings
else
sortedColumn = sort(vertcat(raw{2:end, whichColumn}), 'ascend'); % Sort a vector of numbers
end
Edit: To return the entirety of the spreadsheet data (without headers) sorted by a given column, specified by the header name, pull out the column index as above (the whichColumn variable). Then use the 'sortrows' command to sort the cell array of spreadsheet data by that column.
sortedMatrix = sortrows(raw(2:end, :), whichColumn);