Loading Mapbox Style object from local json file in dash app - mapbox

Trying to set a Mapbox style from a local JSON file in plotly dash app.
mapbox_token = <mytoken>
local_style=
json.load(open(application_root_path+r'/pages/campaignmap/mapbox_style.json'))
fig = go.Figure(
go.Scattermapbox(
mode="lines", fill="toself",
lon=[-10, -10, 8, 8, -10, None, 30, 30, 50,
50, 30, None, 100, 100, 80, 80, 100],
lat=[30, 6, 6, 30, 30, None, 20, 30, 30, 20, 20, None, 40, 50, 50, 40, 40],))
fig.update_layout(
dict1={"mapbox": {"accesstoken": mapbox_token}})
fig.update_layout(
showlegend=False,
margin={'l': 0, 'r': 0, 'b': 0, 't': 0},
mapbox_style=local_style
)
Based on the documentation on the plotly website Mapbox Map Layers in Python (see image below) this should work. The JSON file contains the export of the style from MapBox and it works fine when I use the service URL (second last dot point in image).
I've tried loading the JSON as string, dictionary and file path in the mapbox_style parameter with no luck.
Any ideas on how to make it load?

I've tried the same things you've described and had no luck. I can provide a style URL and it works perfectly, but if I download that style and provide just the style.json representation of that same style, I can't seem to get Plotly to recognize it...

Related

How can I add custom time line in react native svg charts

I am using react native svg charts to display some data on line chart .the data is associated with some time which need to be labelled on x axis can anybody tell me how can I do it.
When we look at LineChart, it draws the lines like this.
It accepts 50 as points and 10 points and draws a line between
It accepts 10 as points and 40 points and draws a line between
class LineChartExample extends React.PureComponent {
render() {
const data = [50, 10, 40, 95, -4, -24, 85, 91, 35, 53, -53, 24, 50, -20, -80]
return (
<LineChart
style={{ height: 200 }}
data={data}
svg={{ stroke: 'rgb(134, 65, 244)' }}
contentInset={{ top: 20, bottom: 20 }}
>
<Grid />
</LineChart>
)
}
}

Delphi 11: Constant object cannot be passed as var parameter

I am trying to transfer my Delphi 7 code to Delphi 11.
The following code worked fine in Delphi 7, but in Delphi 11 I get a compile-time error
[dcc32 Error] VELOS.PAS(44): E2197 Constant object cannot be passed as var parameter
Is there a way to make Delphi 11 compile my code?
I can make the initialized constants be global initialized var, but changing all similar code to comply with Delphi 11 is a lot of work because I use similar stuff a lot.
My code:
function Kt_f25(Mrd,Md,aro,dh:real; var k:real):real;
const
vmax=9;
type
Atype=array [1..vmax] of real;
const
arA:Atype=( 10, 15, 20, 25, 30, 40, 60, 100, 200);
v0a08: Atype=( 235, 170, 135, 115, 100, 82, 63, 46, 33);
v1a08: Atype=( 135, 102, 84, 74, 67, 57, 47, 37, 30);
v0a09: Atype=( 166, 118, 95, 80, 70, 57, 44, 33, 23);
v1a09: Atype=( 99, 76, 63, 56, 50, 43, 36, 29, 22);
v0a10: Atype=( 120, 86, 70, 59, 51, 42, 32, 24, 17);
v1a10: Atype=( 77, 59, 50, 44, 40, 34, 28, 22, 16);
dhA:array [1..3] of real=(8,9,10);
var
v0,v1,v2,kt:real;
res:array [1..3] of real;
begin
if Md>0 then k:=Mrd/Md else if Mrd=0 then k:=1 else k:=10;
if k>1.3 then k:=1.3;
if k<0 then k:=0;
v0:=LinearApr(arA,v0a08,aro*1000,vmax); v1:=LinearApr(arA,v1a08,aro*1000,vmax); v2:=20;
if k>=1 then res[1]:=v2+k*(v1-v2)/0.2 else res[1]:=v1+k*(v0-v1)/1.0;
v0:=LinearApr(arA,v0a09,aro*1000,vmax); v1:=LinearApr(arA,v1a09,aro*1000,vmax); v2:=20;
if k>=1 then res[2]:=v2+k*(v1-v2)/0.2 else res[2]:=v1+k*(v0-v1)/1.0;
v0:=LinearApr(arA,v0a10,aro*1000,vmax); v1:=LinearApr(arA,v1a10,aro*1000,vmax); v2:=20;
if k>=1 then res[3]:=v2+k*(v1-v2)/0.2 else res[3]:=v1+k*(v0-v1)/1.0;
kt:=LinearApr(dhA,res,dh*10,3);
Result:=kt/10;
end;
function LinearApr(var ap1,AV1; r:real; Vmax:integer):real;
const gmax=100;
type
Atype=array [1..gmax] of real;
var
i,j:integer;
ap2:Atype absolute ap1;
AV2:Atype absolute AV1;
ap,AV:Atype;
begin
...
end;
The error is self-explanatory. You are passing typed constants where variable references are expected.
You are encountering the following change in behavior between Delphi 7 and 11:
Writeable typed constants (Delphi)
The $J directive controls whether typed constants can be modified or not. In the {$J+} state, typed constants can be modified, and are in essence initialized variables. In the {$J-} state, typed constants are truly constant, and any attempt to modify a typed constant causes the compiler to report an error.
...
In early versions of Delphi and Object Pascal, typed constants were always writeable, corresponding to the {$J+} state. Old source code that uses writeable typed constants must be compiled in the {$J+} state, but for new applications it is recommended that you use initialized variables and compile your code in the {$J-} state.
The default state is {$J-} in modern Delphi versions. So, simply add an explicit {$J+} or {$WRITEABLECONST ON} directive to your existing code to get the old behavior.

Convert uint8list image to a supported Image file(jpg or etc.)

In android 10 and 11 (SDK number 29 and 30) music covers (artworks) formats aren't the same as previous versions, in fact, they aren't readable as a supported image file such as jpg or png, they are uint8lists and only Image.memory widget accepts and shows them.
Now, my problem is I don't wanna read them as a memory image, I need files such as jpg or etc.
Searched a lot! Read a lot and found only 1, not working solution!
And that was writing unit8list as bytes in a file which it's path is ended with ".jpg".
As I said it's not working.
Anyone can help?
Thanks in advance, <3.
final io.File image = File('directory/image.jpg').create();
image.writeAsBytesSync(uint8list);
uint8list sample:[255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255, 226, 2, 40, 73, 67, 67, 95, 80, 82 ,...]
length: thousands
To write Uint8list as a file, you can use File(String).writeAsBytes(Uint8list);. You can set the path and file extension on the File object and pass the image bytes on writeAsBytes()
Uint8List imageBytes;
File('image.jpg').writeAsBytes(imageBytes);

Some questions as for vue-chartjs

In Laravel 5.6 / vuejs 2.5 application I use vue-chartjs, but my charts looks like :
https://imgur.com/a/ru1dXlm
I want some more:
having several items(artists in my case) I want to see them half-transparent, just as in first example here http://demo.vue-chartjs.org/
having points with values shown as in first example at link above
I need to see all labels in x-direction( I fill labels parameter ) for here
If there source code of demo examples of link above > I searched and did not find...
Thanks!
Well, you should find everything you need in the documentation of chart.js and vue-chart.js
http://www.chartjs.org/docs/latest/
http://vue-chartjs.org/#/home?id=resources
You can add rgb values as a background color to make them transparent.
You can also use gradients as its just a canvas element.
Here is a tutorial:
https://hackernoon.com/creating-stunning-charts-with-vue-js-and-chart-js-28af584adc0a?source=user_profile---------5----------------
Here is the source code of the vue-chartjs demo page:
https://github.com/apertureless/vue-chartjs-demo
(It's a bit outdated as with v3 the creation of chart components changed a bit)
It seems you did not filled the labels correctly.
{
labels: ['Here', 'are', 'your', 'x-axis', 'labels'],
datasets: [
{
label: 'artist 1',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
data: [0, 1, 2, 3, 4],
},
{
label: 'artist 2',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
data: [0, 1, 2, 3, 4],
},
],
}

Formatting data for CoreImage CIColorCube

I'm trying to apply arbitrary 3D Luts to images on iOS, but I'm stuck.
I can't for the life of me figure out how to correctly format the cube data for CIColorCube.
I've done what I can based on the brief screen grabs I've taken from the WWDC videos, but what I really need is some sort of working template to go from.
Are there any docs with an example of a hard coded cube rather than the procedural ICC generated ones shown in the ImageApp sample code?
Right now my cube data looks like what you see below (with the middle chopped out for brevity).
Its throwing the error:
"Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CIColorCube 0xb46a850> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key inputCubedata.'"
Any help would be much appreciated, I'm tearing my hear out over this one. I can't find any sold examples of what CIColorCube is expecting (As in a working example, not just a explanation).
uint8_t color_cube_data[4096*4] = {
0, 0, 0, 1,
17, 0, 0, 1,
33, 0, 0, 1,
51, 0, 0, 1,
68, 0, 0, 1,
84, 0, 0, 1,
102, 0, 0, 1,
119, 0, 0, 1,
-----etc etc etc
153, 255, 255, 1,
170, 255, 255, 1,
186, 255, 255, 1,
204, 255, 255, 1,
221, 255, 255, 1,
237, 255, 255, 1,
255, 255, 255, 1
};
I can't help with all your problems without more info, but I think your current error may be cause by this. Make sure the line of code setting your cube data reads like this...
[_colorCube setValue:color_cube_data forKey:#"inputCubeData"];
not this...
[_colorCube setValue:color_cube_data forKey:#"inputCubedata"];
3D LUT has to be wrapped into NSData before passed as an argument to the CIFilter. Cube values are in range [0.0 : 1.0]
NSData * cube_data = [NSData dataWithBytes:color_cube_data length:4096*sizeof(float)*4];
[filter setValue:input_image forKey:#"inputImage"];
[filter setValue:cube_data forKey:#"inputCubeData"];
[filter setValue:[NSNumber numberWithFloat:16] forKey:#"inputCubeDimension"];
Value for inputCubeDimension is strictly power of two.