pie
Shows the share of each part in the total; a donut by default with the total in the center.
Examples
Shows how margin is split across positions.
javascript
function main() {
exchange.SetContractType("swap")
var positions = exchange.GetPositions()
if (!positions) return
var items = positions.map(function (p) { return {name: p.Symbol, value: p.Margin} })
LogStatus({type: "pie", title: "Margin by position", legend: true, items: items,
format: {precision: 2}})
}
python
def main():
exchange.SetContractType("swap")
positions = exchange.GetPositions()
if positions is None:
return
items = [{"name": p["Symbol"], "value": p["Margin"]} for p in positions]
LogStatus({"type": "pie", "title": "Margin by position", "legend": True, "items": items,
"format": {"precision": 2}})
rust
fn main() {
if exchange.SetContractType("swap").is_err() { return; }
let Ok(positions) = exchange.GetPositions(None) else { return };
let items: Vec<String> = positions.iter()
.map(|p| format!(r#"{{"name": "{}", "value": {}}}"#, p.Symbol, p.Margin))
.collect();
LogStatus!(format!(
r#"{{"type": "pie", "title": "Margin by position", "legend": true, "items": [{}],
"format": {{"precision": 2}}}}"#,
items.join(",")
));
}Attributes
| Name | Type | Description |
type | string | Required. Always |
items | object array | Required. The parts; entries without |
items[].name | string | Required. Name. |
items[].value | number | Required. Value, not negative. |
items[].color | string | Color, assigned in order by default. Values: see |
donut | bool | Donut chart; |
legend | bool | List the parts next to the chart. Default |
format | object | Number format |
title | string | Title shown at the top left of the component. |
id | string | Stable identifier. Set it when the number or order of components changes, so refreshes do not rebuild the component. |
span | number | Number of columns it spans in the enclosing |
See Also