Related
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.
Is there any way to differentiate columns that are of type drop down multi select from regular text columns :
This is supposed to be a multi select drop down list without any option :
"id": 5414087443146628,
"version": 2,
"index": 2,
"title": "Column3",
"type": "TEXT_NUMBER",
"validation": false,
"width": 150
Same question goes for multi contact list without contact options defined.
If you think of multi-contact or multi-dropdown as new versions of the various GET requests, then its easier to return the correct values. For multi-dropdown, you use a combination of query parameters of "level=3" and "include=objectValue", then you'll see the column type change to MULTI_PICKLIST instead of TEXT. (The TEXT value is to maintain backwards compatibility.)
So, essentially, your request would look something like GET /sheets/{sheetId}?level=3&include=objectValue.
To test the scenario you've described, I created the following sheet structure in Smartsheet, where the column names indicate the type of each column:
Then I used Postman to issue a Get Sheet request for that sheet:
GET https://api.smartsheet.com/2.0/sheets/5831916227192708
The columns portion of the API response looks like this:
{
"id": 5831916227192708,
...
"columns": [
{
"id": 1256050323154820,
"version": 0,
"index": 0,
"title": "Description",
"type": "TEXT_NUMBER",
"primary": true,
"validation": false,
"width": 124
},
{
"id": 5759649950525316,
"version": 0,
"index": 1,
"title": "Type=Text/Number",
"type": "TEXT_NUMBER",
"validation": false,
"width": 128
},
{
"id": 1323283741206404,
"version": 0,
"index": 2,
"title": "Type=Dropdown (single select)",
"type": "PICKLIST",
"validation": false,
"width": 111
},
{
"id": 7741495861110660,
"version": 2,
"index": 3,
"title": "Type=Dropdown (multiple select)",
"type": "TEXT_NUMBER",
"validation": false,
"width": 113
},
{
"id": 3048711514285956,
"version": 0,
"index": 4,
"title": "Type=Contact List (single select)",
"type": "CONTACT_LIST",
"validation": false,
"width": 122
},
{
"id": 3992195570132868,
"version": 1,
"index": 5,
"title": "Type=Contact List (multiple select)",
"type": "TEXT_NUMBER",
"validation": false,
"width": 125
}
],
...
}
In this response, we see the following:
If column type is specified as Text/Number, the type attribute value is TEXT_NUMBER
If column type is specified as Dropdown (single select), the type attribute value is PICKLIST
If column type is specified as Dropdown (multiple select), the type attribute value is TEXT_NUMBER
If column type is specified as Contact List (single select), the type attribute value is CONTACT_LIST
If column type is specified as Contact List (multiple select), the type attribute value is TEXT_NUMBER
Therefore, it doesn't seem possible to programmatically differentiate a Dropdown (multiple select) column from a Text/Number column or a Contact List (multiple select) column from a Text/Number column, based on column metadata alone. IMO, seems like a bug for the Dropdown (multiple select) column type and Contact List (multiple select) column type to return type: TEXT_NUMBER. Perhaps someone with Smartsheet can comment here to provide more insight into this behavior.
Did a few tests and level 3 isn't available : https://api.smartsheet.com/2.0/sheets/{sheetId}?level=3 :
{
"errorCode": 1018,
"message": "The value '3' was not valid for the parameter 'level'.",
"refId": "1godowa5cigf1"
}
Although i tried with level 2 and got the info :
https://api.smartsheet.com/2.0/sheets/{sheetId}?level=2&include=objectValue
Results for a multi drop down list :
{
"id": 5414087443146628,
"version": 2,
"index": 2,
"title": "Column3",
"type": "MULTI_PICKLIST",
"options": [
"a",
"b"
],
"validation": false,
"width": 150
}
I'm modifying my icon size based on the current zoom value by using the zoom data to drive the size.
As I understand it, I'm using the property "zoom" to track the zoom value (This is required as per the spec), In the stops I setup each desired "zoom" value and then output the icon-size value for that state (shown by the 0-1 > 3 range). If I don't include the parameter "value": something the code fails. If I set it all to 1, it works fine, so it seems that this value is ignored.
Can anyone explain its actual use?
// Add layer to map populating data from Geojson
map.addLayer({
"id": "seed",
"type": "symbol",
"source": "objects",
"layout": {
"icon-rotation-alignment": "map",
"icon-keep-upright": true,
"icon-rotate": 0,
"icon-image": "{icon}",
"icon-allow-overlap": true,
"icon-size": {
"property": "zoom",
"type": "exponential",
"stops": [
[{ "zoom": 15, "value": 1}, 0.1],
[{ "zoom": 16, "value": 1}, 0.3],
[{ "zoom": 17, "value": 1}, 0.6],
[{ "zoom": 18, "value": 1}, 0.8],
[{ "zoom": 19, "value": 1}, 2],
[{ "zoom": 20, "value": 1}, 3]
]
}
}
});
});
Apologies for the confusion #stuffyjoelab!
There are three types of functions in Mapbox GL:
Zoom functions allow the appearance of a map feature to change with map’s zoom level
Property functions allow the appearance of a map feature to change with its properties.
Zoom-and-property functions allow the appearance of a map feature to change with both its properties and zoom.
(There's more info about these in our style spec docs)
I'm using the property "zoom" to track the zoom value
We define a "property" as being per-feature metadata, a la GeoJSON feature properties. By this definition, zoom is not a property (unless you have a property on your features called zoom)
If you switch to the zoom function syntax by removing "property": "zoom" and replacing the {zoom, value} objects from your stops with numeric zooms, everything should work as expected.
// Add layer to map populating data from Geojson
map.addLayer({
"id": "seed",
"type": "symbol",
"source": "objects",
"layout": {
"icon-rotation-alignment": "map",
"icon-keep-upright": true,
"icon-rotate": 0,
"icon-image": "{icon}",
"icon-allow-overlap": true,
"icon-size": {
"type": "exponential",
"stops": [
[15, 0.1],
[16, 0.3],
[17, 0.6],
[18, 0.8],
[19, 2],
[20, 3]
]
}
}
});
I am trying to make my stacked column amChart always display value labels on the columns. Even if they do not fit.
I am using this code:
var qtrchart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "none",
"legend": {
"autoMargins": false,
"borderAlpha": 0.2,
"equalWidths": false,
"horizontalGap": 10,
"markerSize": 10,
"useGraphSettings": true,
"valueAlign": "left",
"valueWidth": 0
},
"dataProvider": [{
"QTR":"FY14 Q2",
"DSAT":0.032602706911007306,
"Neutral":0.069205892921307938,
"CSAT":0.89819140016768484},
{"QTR":"FY14 Q3",
"DSAT":0.038609212354234618,
"Neutral":0.060273567620017982,
"CSAT":0.90111722002574746},
{"QTR":"FY14 Q4","DSAT":0.038757557172180282,
"Neutral":0.058425780441887579,
"CSAT":0.90281666238593217},
{"QTR":"FY15 Q1",
"DSAT":0.12391774891774893,
"Neutral":0.10355411255411255,
"CSAT":0.77252813852813851}],
"valueAxes": [{
"stackType": "100%",
"axisAlpha": 0,
"gridAlpha": 0,
"labelsEnabled": false,
"position": "left"
}],
"graphs": [{
"balloonText": "[[title]], [[category]]<br><span style='font-size:14px;'>[[percents]]%</span>",
"fillColors": "#87898b",
"lineColor": "#87898b",
"color": "#ffffff",
"fillAlphas": 0.9,
"fontSize": 11,
"labelText": "[[percents]]%",
"lineAlpha": 0.5,
"title": "DSAT",
"type": "column",
"valueField": "DSAT"
}, {
"balloonText": "[[title]], [[category]]<br><span style='font-size:14px;'>[[percents]]%</span>",
"fillColors": "#822980",
"lineColor": "#822980",
"color": "#ffffff",
"fillAlphas": 0.9,
"fontSize": 11,
"labelText": "[[percents]]%",
"lineAlpha": 0.5,
"title": "Neutral",
"type": "column",
"valueField": "Neutral"
}, {
"balloonText": "[[title]], [[category]]<br><span style='font-size:14px;'>[[percents]]%</span>",
"fillColors": "#0096d6",
"lineColor": "#0096d6",
"color": "#ffffff",
"fillAlphas": 0.9,
"fontSize": 11,
"labelText": "[[percents]]%",
"lineAlpha": 0.5,
"title": "CSAT",
"type": "column",
"valueField": "CSAT"
}],
"marginTop": 30,
"marginRight": 0,
"marginLeft": 0,
"marginBottom": 40,
"autoMargins": false,
"categoryField": "QTR",
"categoryAxis": {
"gridPosition": "start",
"axisAlpha": 0,
"gridAlpha": 0
},
"percentPrecision": 1,
"data_labels_always_on": true
});
http://jsfiddle.net/Cww3D/288/
Is there a way to achieve this? I found older versions had a special parameter "data_labels_always_on" that you could set to true. But that does not work.
Any ideas?
I'm using AmChart also, and found this that may help you, that goes on "graph" options:
showAllValueLabels Boolean false If graph's type is column and labelText is set, graph hides labels which do not fit into the column's space. If you don't want these labels to be hidden, set this to true.
Hope this helps you!
I got the labels to display by setting the graphs label position, like this:
"labelPosition": "bottom"
here is the JSFiddle: http://jsfiddle.net/Cww3D/291/
Apparently, this forces the labels to display, while the one you'd expect, "showAllValueLabels": true does not.
Weird!
The text labels are not showing because the font size assigned is larger than the space allowed. Modifying the "fontSize" property in the first two of the three "graphs" objects from 11 to 3 displays the percent values you are looking for. However, the font size is so small it isn't very legible even in the fourth column. It's not a solution, but maybe a starting point for you to investigate further?
No screen cap, sorry, I'm still new here.
I am using open flash chart to display a chart in my page. I am using the below code to display the line chart data to my page.
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "530", "250","9.0.0", "expressInstall.swf",
{"data-file":"data.json"}
);
</script>
and my json file is as follows
{
"y_legend":{
"text": "Price US$",
"style": "{color: #53B9AA;font-size:20; }"
},
"elements":[
{
"type": "line",
"colour": "#53B9AA",
"bg_colour": "#E58A25",
"background-color":"#53B9AA",
"inner_background": "#E58A25",
"text": "Price History",
"font-size": 19,
"width": 1,
"dot-style": {
"type":"solid-dot", "colour":"#F57F22", "dot-size": 3,
"tip":"Average price: #val#<br>#x_label#" },
"on-show": {"type": "shrink-in", "cascade":1, "delay":0.7},
"values" : [
5,7,10,12,13,{"value":11,"colour":"#53B9AA","tip":"Average price : #val#<br>#x_label#"},
10,9,8,7,6]
}
],
"x_axis":{
"colour": "#7CC8B5",
"text": "Price US$",
"labels": {
"rotate": "vertical",
"labels":["Jan-09","Feb-09","Mar-09",
"Apr-09","May-09","Jun-09",
"Jul-09","Aug-09","Sep-09",
"Oct-09","Nov-09","Dec-09",
"Jan-10","Feb-10","Mar-10"]
}
},
"y_axis":{
"stroke": 4,
"tick-length": 10,
"colour": "#7CC8B5",
"grid-colour": "#ADB5C7",
"grid-visible": true,
"offset": false,
"min": 5,
"max": 20,
"visible": true,
"steps": 5
}
}
The chart is rendering in my browser pretty well. Now I want to add some more data to chart. Basically my chart is displaying the average sales for past few months. I want to show the projected/forecasted/future data also.I can pass that data to the jSON file. I want the future data to be in a different color in the chart. And I want to display the legends too in the top of the chart to indicate which one is current data and which one is future data.
The solution is to use different lines for the current and projected data.
You can add multiple lines to a single chart, but this might not suit your purposes, since (currently at least), line charts need to have data for the whole x-axis range, and any null values are interpolated.
One option is to use the patched version from this site, set null-gap:true and use null data values to pad the line positions.
The option is to use the normal version of the flash object and use scatter charts as in this example: http://teethgrinder.co.uk/open-flash-chart-2/scatter-mixed.php