How to get the plotly theme as a dictionary? - python-3.x

I would like to have the definition of the plotly theme (or any other theme that comes with plotly for that reason) as a dictionary, i.e., in this format:
ggplot' : {
'colorscale':'ggplot',
'linewidth':1.3,
'linecolor':'pearl',
'bargap' : .01,
'layout' : {
'legend' : {'bgcolor':'white','font':{'color':'grey10'}},
'paper_bgcolor' : 'white',
'plot_bgcolor' : 'grey14',
'yaxis' : {
'tickfont' : {'color':'grey10'},
'gridcolor' : 'lightivory',
'titlefont' : {'color':'grey10'},
'zerolinecolor' : 'lightivory',
'showgrid' : True
},
'xaxis' : {
'tickfont' : {'color':'grey10'},
'gridcolor' : 'lightivory',
'titlefont' : {'color':'grey10'},
'zerolinecolor' : 'lightivory',
'showgrid' : True
},
'titlefont' : {'color':'charcoal'}
},
'annotations' : {
'fontcolor' : 'grey10',
'arrowcolor' : 'grey10'
}
In other words, I would like to know the specs of the theme.
How I can get this information?

Related

Convert Map to String with custom delimiter (Groovy)

I have a JSON:
{
"order_id" : 1,
"order_item" : "PS5",
"item_specs" : {
"item_price" : "$499",
"item_available" : false,
"item_description" : "Console"
},
"sale_date" : "2020-10-20",
}
I want to transform Map inside json to String with delimiter & and put it to JSON back is another parameter:
item_specs" : {
"item_price" : "$499",
"item_available" : false,
"item_description" : "Console"
}
After this transformation my JSON should like this:
{
"order_id" : 1,
"order_item" : "PS5",
"item_specs" : {
"item_price" : "$499",
"item_available" : false,
"item_description" : "Console"
},
"items_as_string": "item_price=$499&item_available=false&item_description=Console"
"sale_date" : "2020-10-20",
}
How to do it with Groovy?
map.collect{ k,v -> k+'='+v }.join('&')

mongodb taking too much time for old entries

i am new in mongodb and i am facing an issue, i have around millions of documents in my collectionand i am trying to find single entry using findOne({}) command and when i am trying to find recent entries then response comes in miliseconds but when i am trying to fetch older entries around 600 millionth document then it takes around 2 minutes on mongo shell and my node server gives
{ MongoErro : connection 1 to 127.0.0.1:27017 timed out }
and my nodejs server sends an empty response. can any one tell me what should i do to resolve this issueThanks in advance
explain gives me
db.contacts.find({"phoneNumber":"9165900137"}).explain("executionStats")
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "meanApp.contacts",
"indexFilterSet" : false,
"parsedQuery" : {
"phoneNumber" : {
"$eq" : "9165900137"
}
},
"winningPlan" : {
"stage" : "COLLSCAN",
"filter" : {
"phoneNumber" : {
"$eq" : "9165900137"
}
},
"direction" : "forward"
},
"rejectedPlans" : [ ]
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 1,
"executionTimeMillis" : 321188,
"totalKeysExamined" : 0,
"totalDocsExamined" : 495587806,
"executionStages" : {
"stage" : "COLLSCAN",
"filter" : {
"phoneNumber" : {
"$eq" : "9165900137"
}
},
"nReturned" : 1,
"executionTimeMillisEstimate" : 295230,
"works" : 495587808,
"advanced" : 1,
"needTime" : 495587806,
"needYield" : 0,
"saveState" : 3871779,
"restoreState" : 3871779,
"isEOF" : 1,
"invalidates" : 0,
"direction" : "forward",
"docsExamined" : 495587806
}
},
"serverInfo" : {
"host" : "li1025-15.members.linode.com",
"port" : 27017,
"version" : "3.2.16",
"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
},
"ok" : 1
}
As indicated in the explain plan results, the current query is doing Collection Scan. This means it has to scan every document in collection to produce the match and you have got about half a billion documents.
Try adding this index and it might take a bit to create it.
db.contacts.createIndex( { phoneNumber: 1 }, { background: true } )
Run the query once the index creation is successful, you must see a dramatic improvement in performance. To be certain whether index got picked up, try explain again and it should no longer say COLLSCAN.

MongoDB remove the lowest score, node.js

I am trying to remove the lowest homework score.
I tried this,
var a = db.students.find({"scores.type":"homework"}, {"scores.$":1}).sort({"scores.score":1})
but how can I remove this set of data?
I have 200 pieces of similar data below.
{
"_id" : 148,
"name" : "Carli Belvins",
"scores" : [
{
"type" : "exam",
"score" : 84.4361816750119
},
{
"type" : "quiz",
"score" : 1.702113040528119
},
{
"type" : "homework",
"score" : 22.47397850465176
},
{
"type" : "homework",
"score" : 88.48032660881387
}
]
}
you are trying to remove an element but the statement you provided is just to find it.
Use db.students.remove(<query>) instead. Full documentation here

Display image from Mongodb with NodeJS

I have a collection "image" and "image_ids "in my mongoDB:
image:
{
"_id" : ObjectId("542e65368a1cec1227ae2bac"),
"reference" : "5424991"
}
images_ids:
{
"_id" : ObjectId("542e652995ac12ed3fecb85f"),
"image" : "D0000001.PNG",
"fid" : ObjectId("542e65368a1cec1227ae2bac"),
"reference" : "5424991"
}
How I can be able to display D0000001.PNG with NodeJS? I mean, to do the link with and API.
[EDIT] we have also
fs.chunks:
{
"_id" : ObjectId("542e684a8a1cec178a172673"),
"n" : 1,
"data" : BinData(0,"2N6DSSfbCN/LLacNDYrJUQDEZgimMUwFpQGoJP0RU19Bi4PM82DjrUnKhE/P9v7P8ZveD1oDpFBM0iml9NE3WQmAvYFoG+nhD73Jm4N9b4LpylaAN5Ef+gVdgGSTAfSUwOikXoVick5pSQCkRmTCU5NT9VVfjHdAx74/ZhFRj+TIRjzlAhzkACBElzgMwGCo7tX+FYrpQLJ5KRmXiwFFwsNtHHzXiK1eu+CG1FumhGpA/qdG8CdDgD1xUHEcerMGO/eLGR9ML7ni/VjXxWzqp2j5DG2/WuKNv7xd3Kz/vr0MctJhuaBIl35YrKhdLnzqDa0uDa6bm4jz+eNyAI2hQbayGo4kVPFe8W7wFpY7qfBvnB9kbocxfZSdADDUNwYaydpT8lIcKEN9XfQJOYZvHp0El"),
"files_id" : ObjectId("542e684a8a1cec178a172671")
}
fs.files:
{
"_id" : ObjectId("542e65378axdeckhb0"),
"uploadDate" : ISODate("2012-11-01"),
"length" : 15673,
"chunkSize" : 33222,
"md5" : "f66e6654854a28e3672cfhds334d223b55a1"
}
Thanks for your help !

How to pull all elements from array in MongoDB without any condition

I have a document as below, and I want to pull all the elements in this array without any condition just via one statement. how can I do?
"energy_sent" : [
{
"player_id" : "034010000093",
"_id" : ObjectId("53675b8d251c20490d9679c6"),
"time" : ISODate("2014-05-05T09:36:13.629Z"),
"has_accepted" : 0,
"energy_value" : 2
},
{
"player_id" : "034010000094",
"_id" : ObjectId("53675cfa251c20490d9679cc"),
"time" : ISODate("2014-05-05T09:42:18.015Z"),
"has_accepted" : 0,
"energy_value" : 2
},
{
"player_id" : "034010000116",
"_id" : ObjectId("5367767889f8e3ee137dd239"),
"time" : ISODate("2014-05-05T11:31:04.457Z"),
"has_accepted" : 0,
"energy_value" : 2
}
]
If you are just after emptying the entire array just set it to empty:
db.collection.update(
{ /* query to match document */ },
{ "$set": { "energy_sent": [] }
)
So just use the $set operator

Resources