Remove empty space from Streamlit Echarts - echarts

I am rendering a gauge component in the following way, within my Streamlit app:
option = {
"series": [
{
"type": "gauge",
"startAngle": 180,
"endAngle": 0,
"min": min_range_val,
"max": max_range_val,
"center": ["40%", "40%"],
"splitNumber": 5,
"axisLine": {
"lineStyle": {
"width": 6,
"color": [
[0.25, "#FF403F"],
[0.5, "#ffa500"],
[0.75, "#FDDD60"],
[1, "#64C88A"],
],
}
},
"pointer": {
"icon": "path://M12.8,0.7l12,40.1H0.7L12.8,0.7z",
"length": "12%",
"width": 30,
"offsetCenter": [0, "-60%"],
"itemStyle": {"color": "auto"},
},
"axisTick": {"length": 10, "lineStyle": {"color": "auto", "width": 2}},
"splitLine": {"length": 15, "lineStyle": {"color": "auto", "width": 5}},
"axisLabel": {
"color": "#464646",
"fontSize": 12,
"distance": -60,
},
"title": {"offsetCenter": [0, "-20%"], "fontSize": 20},
"detail": {
"fontSize": 30,
"offsetCenter": [0, "0%"],
"valueAnimation": True,
"color": "auto",
"formatter": "{value}%",
},
"data": [{"value": value, "name": caption}],
}
]
}
st_echarts(option, width="450px", height="350px", key="gauge")
However, it seems like an additional empty extra white space is added at the bottom of the component (as from the following image).
How can I effectively remove that and keep only a tiny margin all around the gauge?

The following parameters must be added:
radius: '120%',
center: ['50%', '80%']
The latter one should be adjusted according to specific use cases.

Related

change the value in jsonresponse for particular user

{
"User": {
"id": "iERl6YK6mEmzpotHBvVBiA",
"lastUpdated": 1643789241,
"userInputWeightInKG": "70",
"hasPhoto": true,
"introDone": true,
"photoTime": 1643621107,
"photofmt": "png",
"firstName": "new user",
"lastName": "new user",
"dateOfBirth": "01/31/1994",
"email": "newuser123#gmail.com",
"gender": "m",
"heightMeters": 1.7,
"fingerPrint": "",
"aadhaarNumber": "",
"mobileNumber": "2159863566",
"higiScore": 200.0,
"user_score": {
"A1": 23,
"A2": 8,
"A3": 13,
"A4": 28,
"A5": 8,
"A6": 28,
"A7": 8,
"A8": 23,
"B1": 28,
"B2": 28,
"B3": 28,
"B4": 28,
"C1": 22,
"C2": 8,
"C3": 8,
"C4": 8,
"C5": 22,
"D1": 19,
"D2": 19,
"D3": 19,
"D4": 19,
"E1": 0,
"E2": 0,
"E3": 0,
"E4": 0,
"T": 408
},
"accountCreated": "/Date(1643621096288+0530)/",
"termsHistory": [
{
"termsAgreedDate": "/Date(1643621116912+0530)/",
"termsFileName": "termsofuse_v9_01122016"
}
],
"terms": {
"termsAgreedDate": "/Date(1643621116912+0530)/",
"termsFileName": "termsofuse_v9_01122016"
},
"privacyAgreed": {
"privacyAgreedDate": "/Date(1643621116912+0530)/",
"privacyFileName": "privacypolicy_v7_08112014"
},
"privacyAgreedHistory": [
{
"privacyAgreedDate": "/Date(1643621116912+0530)/",
"privacyFileName": "privacypolicy_v7_08112014"
}
],
"Notifications": {
"EmailCheckins": "true",
"EmailMonthlyRecap": "true",
"EmailHigisphereNotifications": "true",
"EmailHigiNews": "true",
"EmailMonthlyDigest": "true"
},
"currentHigiScore": 0.0,
"hasPassword": true,
"privacy": {
"leaderBoard": {
"enabled": false
},
"thirdPartySharing": {
"nonIdentifiableSharing": true
}
},
"tags": {
"isEarndItUser": false,
"testTag1": 12345
},
"joint_user_detail_list": {
"joint_user1": {
"ihl_user_id": "17Jf3sYhwkGjNaAPPvZugQ",
"ihl_user_name": "firstuser",
"status": "requested",
"vital_read": true,
"vital_write": true,
"teleconsult_read": true,
"teleconsult_write": true
},
"joint_user2": {
"ihl_user_id": "n9RFAVPnvEitJhESoTnFtg",
"ihl_user_name": "seconduser",
"status": "Active",
"vital_read": true,
"vital_write": true,
"teleconsult_read": true,
"teleconsult_write": true
}
}
}
}
This is my response from api..
i have to change the "joint_user2": status of guest user to from "Active" to "Inactive" if i click on that second user in UI
how can i do that
please help
I would suggest creating a class which stores your user data. Then, using a fromMap() or fromJSON() method, you can create an object from your API response. You can have a look at the JSON Serialiser on pub.dev (https://pub.dev/packages/json_serializable).
After that, changing any of the values of that object becomes trivial.
onPressed: () {
guestUser.status = 'Inactive' / UserStatus.Inactive ;
}
I would recommend using enums or some other set value type rather than a string, if you need to perform operations on the guest user's status.

Symbol placed with line-center doesn't rotate as the map rotates

I'm having a problem rotating an image with property symbol-placement set to line-center.
This is what it looks like
Removing the property half-solve the issue; the icon rotate as I rotate the map, but they position at the start of the line, and it's not what I'm trying to do.
The definition of my layer is:
{
"id": "my_symbol",
"type": "symbol",
"source": "XXXX",
"source-layer": "XXXXXXX",
"minzoom": 19,
"layout": {
"symbol-placement": "line-center",
"icon-size": {
"stops": [
[20, 0.2],
[21, 0.1],
[22, 0.3],
[23, 0.5],
[24, 0.7]
]
},
"icon-image": [
"concat",
"edge_",
["get", "status_list"]
],
"icon-allow-overlap": true
}
}
I'm trying to achieve this behaviour only by the layer's definition.
I tried looking for a solution, here on SO and on some other sites but I haven't found anything that would help me.
you can set your icon rotation with icon-rotation-alignment
setting it to viewport will fix the icon rotation to your viewport while setting it to map won't rotate it
i'm sorry the gif is hard to see!
{
"id": "my_symbol",
"type": "symbol",
"source": "XXXX",
"source-layer": "XXXXXXX",
"minzoom": 19,
"layout": {
"symbol-placement": "line-center",
"icon-size": {
"stops": [
[20, 0.2],
[21, 0.1],
[22, 0.3],
[23, 0.5],
[24, 0.7]
]
},
"icon-image": [
"concat",
"edge_",
["get", "status_list"]
],
"icon-allow-overlap": true,
"symbol-placement": "line-center",
"icon-rotation-alignment": "viewport"
}
}

Check if student submitted assignment via Moodle web services

I am trying to use the Moodle API (web services) to get information about (my) assignment submissions. I want to know whether I submitted an attempt for the assignment already or not. I am using the mod_assign_get_assignments function (which doesn't have too much documentation) and the results I get (when looking at the assignments portion of each course) are:
{
"id": 25960,
"cmid": 350053,
"course": 8013502,
"name": "\u05d4\u05d2\u05e9\u05ea \u05ea\u05e8\u05d2\u05d9\u05dc \u05d1\u05d9\u05ea 1",
"nosubmissions": 0,
"submissiondrafts": 0,
"sendnotifications": 0,
"sendlatenotifications": 0,
"sendstudentnotifications": 0,
"duedate": 1617566400,
"allowsubmissionsfromdate": 0,
"grade": 100,
"timemodified": 1615897679,
"completionsubmit": 1,
"cutoffdate": 1617569940,
"gradingduedate": 0,
"teamsubmission": 0,
"requireallteammemberssubmit": 0,
"teamsubmissiongroupingid": 0,
"blindmarking": 0,
"hidegrader": 0,
"revealidentities": 0,
"attemptreopenmethod": "manual",
"maxattempts": 1,
"markingworkflow": 0,
"markingallocation": 0,
"requiresubmissionstatement": 0,
"preventsubmissionnotingroup": 0
...irrelevant configuations
}
The above result is for an assignment I have already submitted.
An example of an assignment I did not submit is:
{
"id": 19764,
"cmid": 268225,
"course": 8013201,
"name": "\u05ea\u05d9\u05d1\u05ea \u05d4\u05d2\u05e9\u05d4 14",
"nosubmissions": 0,
"submissiondrafts": 0,
"sendnotifications": 0,
"sendlatenotifications": 0,
"sendstudentnotifications": 0,
"duedate": 1611693000,
"allowsubmissionsfromdate": 0,
"grade": 100,
"timemodified": 1610972842,
"completionsubmit": 0,
"cutoffdate": 1611694860,
"gradingduedate": 0,
"teamsubmission": 0,
"requireallteammemberssubmit": 0,
"teamsubmissiongroupingid": 0,
"blindmarking": 0,
"hidegrader": 0,
"revealidentities": 0,
"attemptreopenmethod": "manual",
"maxattempts": 1,
"markingworkflow": 0,
"markingallocation": 0,
"requiresubmissionstatement": 0,
"preventsubmissionnotingroup": 0
...irrelevant configuations
}
The only apparent difference between these (that might point to a way to check if I submitted it or not) is the completionsubmit property, but that cannot be the solution because a different assignment that I have submitted has it set to 0 (just like the one I didn't submit).
Does someone have an idea how I can solve this issue?
Thanks in Advance!
EDIT: mod_assign_get_submissions denies my access
{"assignments":[],"warnings":[{"item":"assignment","itemid":myitemname,"warningcode":"1","message":"No access rights in module context"}]}
I looked now into mod_assign_get_submission_status but it seems like it is only able to parse one assignment at a time, does anyone have a way to make this more efficient?
You could try using mod_assign_get_submissions instead to retrieve submissions to assignments. Available since Moodle 2.5
References
Moodle API
Emulated Data For Get Submissions from Moodle
Sample Response
{
"assignments": [
{
"assignmentid": 14,
"submissions": [
{
"id": 7,
"userid": 3,
"attemptnumber": 0,
"timecreated": 1426865031,
"timemodified": 1426865062,
"status": "submitted",
"groupid": 0,
"plugins": [
{
"type": "onlinetext",
"name": "Online text",
"fileareas": [
{
"area": "submissions_onlinetext"
}
],
"editorfields": [
{
"name": "onlinetext",
"description": "Submission comments",
"text": "<p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. <br></p>",
"format": 1
}
]
},
{
"type": "file",
"name": "File submissions",
"fileareas": [
{
"area": "submission_files",
"files": [
{
"filepath": "APDFfile.pdf",
"fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
},
{
"filepath": "anotherfile.docx",
"fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
}
]
}
]
},
{
"type": "comments",
"name": "Submission comments"
}
]
},
{
"id": 5,
"userid": 4,
"attemptnumber": 0,
"timecreated": 1426864693,
"timemodified": 1426864740,
"status": "draft",
"groupid": 0,
"plugins": [
{
"type": "onlinetext",
"name": "Online text",
"fileareas": [
{
"area": "submissions_onlinetext",
"files": [
{
"filepath": "/Arte esquemático-Cigüeña.png",
"fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/245/assignsubmission_onlinetext/submissions_onlinetext/5/Arte%20esquem%C3%A1tico-Cig%C3%BCe%C3%B1a.png"
}
]
}
],
"editorfields": [
{
"name": "onlinetext",
"description": "Submission comments",
"text": "<p>Blah Blah Blah lorem ipsum</p><p><br></p><p><b>Blah Blah Blah lorem ipsum</b><br></p><p><b><br></b></p><p><b><span style=\"font-weight: normal;\"><i>Blah Blah Blah lorem ipsum</i></span><br></b></p><p><b><span style=\"font-weight: normal;\"><i><br></i></span></b></p><p><b><span style=\"font-weight: normal;\"><i><img src=\"##PLUGINFILE##/Arte%20esquem%C3%A1tico-Cig%C3%BCe%C3%B1a.png\" alt=\"\" width=\"734\" height=\"844\" role=\"presentation\" style=\"vertical-align:text-bottom; margin: 0 .5em;\" class=\"img-responsive\"><br></i></span></b></p>",
"format": 1
}
]
},
{
"type": "file",
"name": "File submissions",
"fileareas": [
{
"area": "submission_files",
"files": [
{
"filepath": "somefile.pdf",
"fileurl": "http://localhost/m/stable_master/webservice/pluginfile.php/247/assignsubmission_file/submission_files/12/somefile.pdf"
}
]
}
]
},
{
"type": "comments",
"name": "Submission comments"
}
]
}
]
}
],
"warnings": []
}

Better way to display images in Magento's default API response?

I am using Magento2 default API: /V1/carts/mine/payment-information.
The response from this API is:
{
"payment_methods": [
{
"code": "payu",
"title": "PayUMoney"
},
{
"code": "checkmo",
"title": "Check / Money order"
},
{
"code": "paytm",
"title": "Paytm PG"
}
],
"totals": {
"grand_total": 195,
"base_grand_total": 195,
"subtotal": 45,
"base_subtotal": 45,
"discount_amount": 0,
"base_discount_amount": 0,
"subtotal_with_discount": 45,
"base_subtotal_with_discount": 45,
"shipping_amount": 150,
"base_shipping_amount": 150,
"shipping_discount_amount": 0,
"base_shipping_discount_amount": 0,
"tax_amount": 0,
"base_tax_amount": 0,
"weee_tax_applied_amount": null,
"shipping_tax_amount": 0,
"base_shipping_tax_amount": 0,
"subtotal_incl_tax": 45,
"shipping_incl_tax": 150,
"base_shipping_incl_tax": 150,
"base_currency_code": "INR",
"quote_currency_code": "INR",
"items_qty": 1,
"items": [
{
"item_id": 41,
"price": 45,
"base_price": 45,
"qty": 1,
"row_total": 45,
"base_row_total": 45,
"row_total_with_discount": 0,
"tax_amount": 0,
"base_tax_amount": 0,
"tax_percent": 0,
"discount_amount": 0,
"base_discount_amount": 0,
"discount_percent": 0,
"price_incl_tax": 45,
"base_price_incl_tax": 45,
"row_total_incl_tax": 45,
"base_row_total_incl_tax": 45,
"options": "[{\"value\":\"Green\",\"label\":\"Color\"},{\"value\":\"29\",\"label\":\"Size\"}]",
"weee_tax_applied_amount": null,
"weee_tax_applied": null,
"name": "Erika Running Short"
}
],
"total_segments": [
{
"code": "subtotal",
"title": "Subtotal",
"value": 45
},
{
"code": "shipping",
"title": "Shipping & Handling (Fixed)",
"value": 150
},
{
"code": "tax",
"title": "Tax",
"value": 0,
"extension_attributes": {
"tax_grandtotal_details": []
}
},
{
"code": "grand_total",
"title": "Grand Total",
"value": 195,
"area": "footer"
}
]
}
}
I want to add the images tag inside items to display images of the items/products. But this tag is not defined in the interface of items, i.e
TotalsItemInterface.php
I replicated TotalsItemInterface in my custom module and added all getters and setters from Totalsinterface along with setImages and getImages Tag. Thus internally I call the method to use and show it by my custom apiInterfaces.
Is there a better or a proper "Magento 2 way" if we want to change the data displayed in the APIs?
You may use extension attributes for it. You can find more information about them in the devdocs there:
https://devdocs.magento.com/guides/v2.3/extension-dev-guide/extension_attributes/adding-attributes.html

I am building a bubble chart in AM-Charts but facing issues in plotting String values on X-axis

I am new to AM-charts, I am building a bubble chart in AM-charts http://www.amcharts.com/demos/bubble-chart/.
I want to plot following data in bubble chart where name should be appear on X-axis and job should be on Y-axis.
[{"name":"abc","jobs":15, "value":63500},{{"name":"pqr","jobs":15, "value":33000}}]
My bubble chart configuration is as follows-
{
"type": "xy",
"theme": "light",
"titles": [
{
"text": title,
"size": 16
}
],
"balloon": {
"fixedPosition": true,
},
"dataProvider": [{"name":"abc","job":15, "value":63500},{{"name":"pqr","job":15, "value":33000}}],
"valueAxes": [
{
"position": "bottom",
"axisAlpha": 0
},
{
"minMaxMultiplier": 1.2,
"axisAlpha": 0,
"position": "left"
}
],
"startDuration": 1.5,
"graphs": [
{
"balloonText": "Name: <b>[[name]]</b> Jobs: <b>[[job]]</b><br>value: <b>[[value]]</b>",
"bullet": "round",
"bulletBorderAlpha": 0.2,
"bulletAlpha": 0.8,
"lineAlpha": 0,
"fillAlphas": 0,
"valueField": "value",
"xField": "name",
"yField": "job",
"maxBulletSize": 50,
"minBulletSize": 20
}
],
"marginLeft": 46,
"marginBottom": 35,
"export": {
"enabled": true
},
"chartScrollbar": {
"offset": 15,
"scrollbarHeight": 5
}
}
I am not able to see bubble chart with this configuration. No error or warning in console.
Can anyone please suggest me some solution to fix this issue?
Thanks in advance.