I am currently migrating our application using an old version of chart-js but at the moment I am a bit lost.
NB : The old project was made with vuejs 2 and now we are using nuxt3 rc11
By reading the documentation on the migration, many things have changed and I have trouble finding my way around:
https://www.chartjs.org/docs/latest/getting-started/v3-migration.html
Here is what the parameters I send to chart-js look like
{
"type":"doughnut",
"data":{
"labels":[
"",
"",
"",
""
],
"datasets":[
{
"data":[
16,
0,
0,
1
],
"backgroundColor":[
"#00CBA1",
"#FFBF00",
"#FF406C",
"#4C49AF"
],
"borderWidth":"transparent"
}
]
},
"plugins":[
],
"options":{
"hover":{
"mode":"index",
"axis":"y"
},
"legend":{
"display":false
},
"scales":{
"x":{
"gridLines":{
"display":false
},
"ticks":{
"padding":10,
"display":false
}
},
"y":{
"ticks":{
"beginAtZero":true,
"padding":20,
"display":false
},
"gridLines":{
"drawBorder":false,
"color":"#E3E3E3",
"zeroLineColor":"#E3E3E3",
"display":false
}
}
},
"tooltip":{
"enabled":false
},
"maintainAspectRatio":true,
"responsive":true,
"tooltips":{
},
"layout":{
"padding":{
"top":10,
"right":10
}
},
"cutoutPercentage":60
}
}
I don't know what is wrong with this actualy because my canvas display empty cells like this
I thank you in advance for your clarification
Related
I'm relatively new in MongoDB.
I have a single MongoDB instance in replica set in order to use 'watch'. We are currently watching on 'insert' events over the 'removeCollection' collection, the point is this collection is always empty (so noone is inserting anything there right now).
But the log is suddenly showing the below "slow query" message dozens of times. When this happens, the cpu consumption increases a 20%.
{
"t":{
"$date":"2022-11-16T09:15:45.836+00:00"
},
"s":"I",
"c":"COMMAND",
"id":51803,
"ctx":"conn522936",
"msg":"Slow query",
"attr":{
"type":"command",
"ns":"ventusproxy1.removeCollection",
"command":{
"getMore":2257121337268066828,
"collection":"removeCollection",
"batchSize":2147483647,
"$db":"ventusproxy1",
"$clusterTime":{
"clusterTime":{
"$timestamp":{
"t":1668590144,
"i":14391
}
},
"signature":{
"hash":{
"$binary":{
"base64":"AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"subType":"0"
}
},
"keyId":0
}
},
"lsid":{
"id":{
"$uuid":"47ffbf37-2a66-4b6f-bfb0-57f0e83075e2"
}
},
"$readPreference":{
"mode":"primaryPreferred"
}
},
"originatingCommand":{
"aggregate":"removeCollection",
"pipeline":[
{
"$changeStream":{
}
},
{
"$match":{
"operationType":"insert"
}
}
],
"cursor":{
"batchSize":2147483647
},
"$db":"ventusproxy1",
"$clusterTime":{
"clusterTime":{
"$timestamp":{
"t":1668590004,
"i":1046
}
},
"signature":{
"hash":{
"$binary":{
"base64":"AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"subType":"0"
}
},
"keyId":0
}
},
"lsid":{
"id":{
"$uuid":"47ffbf37-2a66-4b6f-bfb0-57f0e83075e2"
}
},
"$readPreference":{
"mode":"primaryPreferred"
}
},
"planSummary":"COLLSCAN",
"cursorid":2257121337268066828,
"keysExamined":0,
"docsExamined":17228,
"numYields":13243,
"nreturned":0,
"queryHash":"8D9BAD8C",
"reslen":319,
"locks":{
"FeatureCompatibilityVersion":{
"acquireCount":{
"r":13244
}
},
"Global":{
"acquireCount":{
"r":13244
}
},
"Mutex":{
"acquireCount":{
"r":1
}
}
},
"readConcern":{
"level":"majority"
},
"writeConcern":{
"w":"majority",
"wtimeout":0,
"provenance":"implicitDefault"
},
"storage":{
"data":{
"bytesRead":89
}
},
"remote":"10.1.0.7:36266",
"protocol":"op_msg",
"durationMillis":210
}
}
I have searched trying to find a reason for that ... no luck. And I honestly don't know where to start. I would really appreciated if someone could point me to the right direction.
Thanks,
Joan.
I am trying to update a field under doc_list which in proect_list is an embeddeddocumentfield
using [ mongoengine ]
"_id":{
"$oid":"5efae3a302449b643b2e5a06"
},
"username":"Roshan",
"project_list":[
{
"project_id":"216198",
"customername":"Gopal",
"customer_region":"IND",
"doc_list":{
"status":"Inprogress",
"date_modified":{
"$date":"2020-06-30T12:32:59.851Z"
},
"date_started":{
"$date":"2020-06-30T12:32:59.851Z"
},
"nrfu_doc_id":"",
"reference_doc_id":""
}
},
{
"project_id":"624615",
"customername":"xcisco",
"customer_region":"IND",
"doc_list":{
"status":"Completed",
"date_modified":{
"$date":"2020-06-30T12:35:06.031Z"
},
"date_started":{
"$date":"2020-06-30T12:35:06.031Z"
},
"nrfu_doc_id":"",
"reference_doc_id":""
}
}
]
}
I have tried this and tried lot of other examples in MongoEngine Documentation and also Searched in StackOverflow not yet resolved, Please Help me to do this Update.
users = PersonProjectCollection.objects(username="Roshan", project_list__project_id="216198").update_one(set__project_list__doc_list__S__reference_doc_id='21333')
mongoengine.errors.OperationError: Update failed (Cannot create field 'doc_list' in element {project_list: [ { project_id: "216198", customername: "Gopal",
customer_region: "IND", doc_list: { status: "Inprogress", date_modified: new Date(1593520379851), date_started: new Date(1593520379851), nrfu_doc_id: "",
reference_doc_id: "" } }, { project_id: "624615", customername: "xcisco", customer_region: "IND", doc_list: { status: "Completed", date_modified: new Date(
1593520506031), date_started: new Date(1593520506031), nrfu_doc_id: "", reference_doc_id: "" } } ]})
maybe this approach help you
index = 0
users = PersonProjectCollection._get_collection.update_one(
{
"username":"Roshan",
"project_list.project_id":"216198"
},
{
"$set": {
"project_list.%d.doc_list.reference_doc_id" % index: "21333"
}
}
)
Seems this question is a very popular one, but I haven't found an answer (or at least not one I was able to understand).
I'm having a flat file that I would like to store in Mongo using some nestings. Though it is relatively easy to achieve with an insert and unique content I have the need to update the content on a regular base, so would need to be able to use the update commands also.
My flat file looks as follows :
Model,Category,Organisation,CountryCode,CountryWarranty,PeriodCode,PeriodQty
Model1,Category1,Org1,Code1,2Y,201707,1
Model1,Category1,Org1,Code1,2Y,201708,2
Model1,Category1,Org1,Code1,1Y,201709,3
Model1,Category1,Org1,Code2,2Y,201707,7
Model1,Category1,Org1,Code2,2Y,201708,8
Model1,Category1,Org1,Code2,5Y,201709,7
Model1,Category1,Org2,Code3,2Y,201707,5
Model1,Category1,Org2,Code3,4Y,201708,6
Model1,Category1,Org2,Code3,2Y,201709,7
...
Model_n,Category_n,Org_n,Code_n,3Y,201802,20
and what I like to achieve is the following :
{
"_id": "Model1",
"Model_category": "Category1",
"Product_Sales": [
{
"Organisation": "Org1",
"Country": [
{
"Code": "Code1",
"Guarantee_Years": "2Y",
"Period": [
{"Code": 201707,"Qty": 1},
{"Code": 201708,"Qty": 2},
{"Code": 201709,"Qty": 3}
]
}, {
"Code": "Code2",
"Guarantee_Years": "2Y",
"Period": [
{"Code": 201707,"Qty": 7},
{"Code": 201708,"Qty": 8},
{"Code": 201709,"Qty": 7}
]
}
]
}, {
"Organisation": "Org2",
"Country": [
{
"Code": "Code3",
"Guarantee_Years": "2Y",
"Period": [
{"Code": 201707,"Qty": 5},
{"Code": 201708,"Qty": 6},
{"Code": 201709,"Qty": 7}
]
}
]
}
]
}
Below a snippet of what I tried, note that the syntax is specific to my development environment so I know it is not workable or proper mongo, but it's about the basic idea. Any example using the console will do fine for me
concat("{update: "master_Sales",
updates: [
{
q:{"_id":", %{_id},""},
u:{$addToSet: {
"Product_Sales.Organisation": "", %{org}, "",
"Product_Sales.Organisation.Country": [
-- more here but have no clue --
]
}}
, upsert: true}
]}"
)
Adding my organisations works fine, but as soon as I want to add a second level (nested within an org) it goes wrong.
So in essence I want to be able to add this flat content to my Mongo in a nested array structure, and each time one of the values is changed in the future (say the quantity is updated, or a new country is added) that the line is added / updated so I am not forced to do a full refresh and insert each time a line is modified.
What would be the best approach to deal with this?
say the quantity is updated, or a new country is added
You can try below update query in 3.6 mongo version.
For updating Qty for Organisation/Country Code/Period Code - Org1/Code1/201707
db.collection.update(
{ },
{ "$set": { "Product_Sales.$[org].Country.$[country].Period.$[period].Qty" : 2 } },
{ arrayFilters: [ { "org.organisation": "Org1" }, { "country.Code": "Code1" }, { "period.Code": 201707 } ] }
)
For adding new Country to Organisation Org2
db.collection.update(
{ },
{ "$push": { "Product_Sales.$[org].Country" : {"Code": "Code4","Guarantee_Years": "2Y"} } },
{ arrayFilters: [ { "org.organisation": "Org2"} ] }
)
Can be simplified to
db.collection.update(
{ "org.organisation": "Org2"},
{ "$push": { "Product_Sales.$.Country" : {"Code": "Code4","Guarantee_Years": "2Y"} } }
)
Is there a specific name for this kind of charts ? What JavaScript Charting Library has it ?
Look up treemaps / treemapping. This is how Wikipedia describes them:
"In information visualization and computing, treemapping is a method for displaying hierarchical data by using nested rectangles. […]
Treemaps display hierarchical (tree-structured) data as a set of
nested rectangles. Each branch of the tree is given a rectangle, which
is then tiled with smaller rectangles representing sub-branches. A
leaf node's rectangle has an area proportional to a specified
dimension of the data."
One notable tool which utilizes this technique is WinDirStat. Their website also refers to this kind of visualization as a treemap.
Given this term, you should be able to easily find a JavaScript library that can produce them by simply performing a web search. (I cannot recommend any of the following, since I haven't used them, but the linked Google search finds jsTreemap, Plotly.js, Google Charts, and a few others, on the very first result page.)
If you're curious about the algorithm(s) behind these diagrams, these papers might be of interest:
Brian Johnson, Ben Shneiderman (1991): Treemaps: a space-filling approach to the visualization of hierarchical information structures.
Mark Bruls, Kees Huizing, Jarke van Wijk (1999): Squarified Treemaps.
It's called a treemap, and ZingChart is a JavaScript charting library that has it. It's a useful way to chart hierarchical data. It also allows for user interaction since the user can further drilldown into the treemap. Check out the below demo.
var myConfig = {
"graphset":[
{
"type":"treemap",
"plotarea":{
"margin":"0 0 30 0"
},
"tooltip":{
},
"options":{
},
"series":[
{
"text":"North America",
"children":[
{
"text":"United States",
"children":[
{
"text":"Texas",
"value":21
},
{
"text":"California",
"value":53
},
{
"text":"Ohio",
"value":12
},
{
"text":"New York",
"value":46
},
{
"text":"Michigan",
"value":39
},
{
"text":"Alabama",
"value":25
}
]
},
{
"text":"Canada",
"value":113
},
{
"text":"Mexico",
"value":78
}
]
},
{
"text":"Europe",
"children":[
{
"text":"France",
"value":42
},
{
"text":"Spain",
"value":28
},
{
"text":"Switzerland",
"value":13
},
{
"text":"Germany",
"value":56
},
{
"text":"Cyprus",
"value":7
}
]
},
{
"text":"Africa",
"children":[
{
"text":"Egypt",
"value":22
},
{
"text":"Congo",
"value":38
},
{
"text":"Lesotho",
"value":9
}
]
},
{
"text":"Asia",
"children":[
{
"text":"India",
"value":92
},
{
"text":"China",
"value":68
},
{
"text":"Mongolia",
"value":25
}
]
},
{
"text":"South America",
"children":[
{
"text":"Brazil",
"value":42
},
{
"text":"Argentina",
"value":28
},
{
"text":"Peru",
"value":15
},
{
"text":"Uruguay",
"value":33
}
]
},
{
"text":"Australia (continent)",
"children":[
{
"text":"Australia (country)",
"value":121
},
{
"text":"New Zealand",
"value":24
}
]
}
]
}
]
};
zingchart.render({
id : 'myChart',
data : myConfig,
height: 400,
width: 600
});
<head>
<script src= "https://cdn.zingchart.com/zingchart.min.js"></script>
<script>zingchart.MODULESDIR = "https://cdn.zingchart.com/modules/";
ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9","ee6b7db5b51705a13dc2339db3edaf6d"];</script>
</head>
<body>
<div id='myChart'></div>
</body>
For more information on treemaps, read this blog post: https://blog.zingchart.com/2015/03/10/treemaps-charting/
Disclaimer: I'm on the ZingChart team. Let me know if you have more questions. Thanks!
I am following the examples located on the following page:
http://developer.echonest.com/docs/v4/genre.html#artists
I'd like to offset the results from a search for artists by genre. The example they provide on the page listed "results" and "start". I assume "start" is the offset. The example query they provide is:
http://developer.echonest.com/api/v4/genre/artists?api_key=JEXNQ223JXCCQEINO&format=json&results=5&start=0&bucket=hotttnesss&name=jazz
But I get any error stating the "start" is an invalid parameter. Has anyone been able to use the "start" parameter with success?
This looks like a bug in their example. If you read the documentation, "start" and "results" are not valid for the genre/artists endpoint. Changing the example to remove these to parameters works.
Calling:
http://developer.echonest.com/api/v4/genre/artists?api_key=*********&format=json&bucket=hotttnesss&name=jazz
(replace the *** with your Key)
Yields:
{
"response":{
"status":{
"version":"4.2",
"code":0,
"message":"Success"
},
"artists":[
{
"name":"John Coltrane",
"hotttnesss":0.588225,
"id":"ARIOZCU1187FB3A3DC"
},
{
"name":"Thelonious Monk",
"hotttnesss":0.649332,
"id":"AR9PLH11187FB58A87"
},
{
"name":"Miles Davis",
"hotttnesss":0.697302,
"id":"AR7RTGF1187FB38793"
},
{
"name":"Miles Davis Quintet",
"hotttnesss":0.489603,
"id":"AR5DF1C1187FB4E94C"
},
{
"name":"Cannonball Adderley",
"hotttnesss":0.560071,
"id":"ARQ5TM41187FB3E97D"
},
{
"name":"Wayne Shorter",
"hotttnesss":0.548165,
"id":"ARO3CKW1187B9905A8"
},
{
"name":"Wynton Marsalis",
"hotttnesss":0.566708,
"id":"ARV3VEI1187B9AD5C9"
},
{
"name":"Sonny Rollins",
"hotttnesss":0.577764,
"id":"AR6Q4T91187B995616"
},
{
"name":"The Dave Brubeck Quartet",
"hotttnesss":0.570099,
"id":"ARLKR161187FB50694"
},
{
"name":"Kenny Burrell",
"hotttnesss":0.543388,
"id":"ARQYH461187FB3E975"
},
{
"name":"Stan Getz",
"hotttnesss":0.559735,
"id":"ARMGQLA1187B9AEBF8"
},
{
"name":"Dizzy Gillespie",
"hotttnesss":0.561122,
"id":"ARXA17J1187FB3B507"
},
{
"name":"Yusef Lateef",
"hotttnesss":0.513261,
"id":"ART95BW1187FB3AF79"
},
{
"name":"Bill Evans",
"hotttnesss":0.581819,
"id":"ARTLL9E1187FB4436F"
},
{
"name":"Freddie Hubbard",
"hotttnesss":0.524227,
"id":"ARU1K2U1187FB48529"
}
]
}
}
As far as I can tell, there isn't a way to page through the artists associated with a genre...