Test: Porovnání verzí
Skočit na navigaci
Skočit na vyhledávání
Přidaný obsah Smazaný obsah
imported>Le0 Bez shrnutí editace |
imported>SpeLe0log mBez shrnutí editace |
||
(Není zobrazeno 28 mezilehlých verzí od 4 dalších uživatelů.) | |||
Řádek 1: | Řádek 1: | ||
https://youtu.be/_B0CyOAO8y0?t=87 |
https://youtu.be/_B0CyOAO8y0?t=87 |
||
{{N/A}} |
|||
<graph mode=interactive title="Stock Market"> |
|||
{ |
|||
"version": 2, |
|||
"width": 650, |
|||
"height": 300, |
|||
"padding": "strict", |
|||
"signals": [ |
|||
{ |
|||
"name": "indexDate", |
|||
"init": {"expr": "time('Jan 1 2005')"}, |
|||
"streams": [{ |
|||
"type": "mousemove", |
|||
"expr": "clamp(eventX(), 0, eventGroup('root').width)", |
|||
"scale": {"name": "x", "invert": true} |
|||
}] |
|||
}, |
|||
{"name": "maxDate", "init": {"expr": "time('Mar 1 2010')"}} |
|||
], |
|||
<div class="treeview"> |
|||
"data": [ |
|||
* / |
|||
{ |
|||
** A |
|||
"name": "stocks", |
|||
*** A1 |
|||
"url": "wikiraw:///Extension:Graph/data/stocks-csv", |
|||
**** A1a |
|||
"format": {"type": "csv", "parse": {"price":"number", "date":"date"}} |
|||
**** A1b |
|||
}, |
|||
*** A2 |
|||
{ |
|||
*** A3 |
|||
"name": "index", |
|||
** B |
|||
"source": "stocks", |
|||
*** B1 |
|||
"transform": [{ |
|||
*** B2 |
|||
"type": "filter", |
|||
*** B3 |
|||
"test": "month(datum.date) == month(indexDate) && year(datum.date) == year(indexDate)" |
|||
**** B3a |
|||
}] |
|||
**** B3b |
|||
}, |
|||
**** B3c |
|||
{ |
|||
</div> |
|||
"name": "indexified_stocks", |
|||
"source": "stocks", |
|||
"transform": [{ |
|||
"type": "lookup", |
|||
"on": "index", "onKey": "symbol", |
|||
"keys": ["symbol"], "as": ["index_term"], |
|||
"default": {"price": 0} |
|||
}, { |
|||
"type": "formula", |
|||
"field": "indexed_price", |
|||
"expr": "datum.index_term.price > 0 ? (datum.price - datum.index_term.price)/datum.index_term.price : 0" |
|||
}] |
|||
} |
|||
], |
|||
{{BAR|user|7|red}}{{BAR|user|3}} |
|||
"scales": [ |
|||
{ |
|||
{{BAR|20|79|red|v%|reverse=y}} |
|||
"name": "x", |
|||
{{BAR|hearts|0.5|n}} |
|||
"type": "time", |
|||
{{BAR|hearts|1|n}} |
|||
"domain": {"data": "stocks", "field": "date"}, |
|||
{{BAR|hearts|1.5|n}} |
|||
"range": "width" |
|||
{{BAR|hearts|2.5}} |
|||
}, |
|||
{{BAR|hearts|3.5|n}} |
|||
{ |
|||
{{BAR|hearts|mob|4.5|n}} |
|||
"name": "y", |
|||
{{BAR|hearts|wither|5.5|n}} |
|||
"type": "linear", |
|||
{{BAR|hearts|6.5|n}} |
|||
"domain": {"data": "indexified_stocks", "field": "indexed_price"}, |
|||
{{BAR|hunger|poison|8|n}} |
|||
"range": "height", |
|||
{{BAR|armor|7.5|n}} |
|||
"nice": true |
|||
{{BAR|hearts|absorption|4.5}} |
|||
}, |
|||
{ |
|||
"name": "color", |
|||
"type": "ordinal", |
|||
"domain": {"data": "stocks", "field": "symbol"}, |
|||
"range": "category10" |
|||
} |
|||
], |
|||
"axes": [ |
|||
{"type": "y", "scale": "y", "grid": true, "layer": "back", "format": "%"} |
|||
], |
|||
"marks": [ |
|||
{ |
|||
"type": "group", |
|||
"from": { |
|||
"data": "indexified_stocks", |
|||
"transform": [{"type": "facet", "groupby": ["symbol"]}] |
|||
}, |
|||
"marks": [ |
|||
{ |
|||
"type": "line", |
|||
"properties": { |
|||
"update": { |
|||
"x": {"scale": "x", "field": "date"}, |
|||
"y": {"scale": "y", "field": "indexed_price"}, |
|||
"stroke": {"scale": "color", "field": "symbol"}, |
|||
"strokeWidth": {"value": 2} |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
"type": "text", |
|||
"from": { |
|||
"transform": [{"type": "filter", "test": "datum.date == maxDate"}] |
|||
}, |
|||
"properties": { |
|||
"update": { |
|||
"x": {"scale": "x", "field": "date", "offset": 2}, |
|||
"y": {"scale": "y", "field": "indexed_price"}, |
|||
"fill": {"scale": "color", "field": "symbol"}, |
|||
"text": {"field": "symbol"}, |
|||
"baseline": {"value": "middle"} |
|||
} |
|||
} |
|||
} |
|||
] |
|||
}, |
|||
{ |
|||
"type":"rule", |
|||
"properties": { |
|||
"update": { |
|||
"x": {"field": {"group": "x"}}, |
|||
"x2": {"field": {"group": "width"}}, |
|||
"y": {"scale": "y", "value": 0}, |
|||
"stroke": {"value": "black"}, |
|||
"strokeWidth": {"value": 1} |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
"type":"rule", |
|||
"properties": { |
|||
"update": { |
|||
"x": {"scale": "x", "signal": "indexDate"}, |
|||
"y": {"value": 0}, |
|||
"y2": {"field": {"group": "height"}}, |
|||
"stroke": {"value": "red"} |
|||
} |
|||
} |
|||
}, |
|||
{ |
|||
"type":"text", |
|||
"properties": { |
|||
"update": { |
|||
"x": {"scale": "x", "signal": "indexDate"}, |
|||
"y2": {"field": {"group": "height"}, "offset": 15}, |
|||
"align": {"value": "center"}, |
|||
"text": {"template": "\u007B{indexDate | time: '%b %Y'}}"}, |
|||
"fill": {"value": "red"} |
|||
} |
|||
} |
|||
} |
|||
] |
|||
} |
|||
</graph> |