added some plots on initial article, theme alter

This commit is contained in:
Corey 2020-10-15 09:02:34 -04:00
parent 201e4dfaa2
commit 9cdee237ab
No known key found for this signature in database
GPG Key ID: 724684AF1BAAC90F
12 changed files with 87287 additions and 217 deletions

View File

@ -1,6 +1,6 @@
baseUrl = ""
title = "Distill Hugo Theme"
author = "Sanyam Kapoor"
title = "Status Network Token Distribution Analysis"
author = "Corey Petty"
canonifyurls = true
theme = "distillpub"
@ -8,41 +8,25 @@ theme = "distillpub"
# TODO: Taxonomies?
[params]
description = "Distill Hugo Theme Demo"
description = "Status Network Token Distribution"
keywords = ["hugo", "distill", "theme"]
sourcePrefix = "https://github.com/activatedgeek/distillpub/blob/master/exampleSite"
sourcePrefix = "https://github.com/status-im/snt-distribution"
color = "#0f2e3d"
[[params.social]]
class = "fas fa-user-graduate"
url = "https://scholar.google.com/citations?user=p0NMtgsAAAAJ"
color = "#4360DF"
[[params.social]]
class = "fab fa-github"
url = "https://github.com/activatedgeek"
[[params.social]]
class = "fab fa-hacker-news"
url = "https://news.ycombinator.com/user?id=activatedgeek"
[[params.social]]
class = "fab fa-linkedin"
url = "https://linkedin.com/in/sanyamkapoor"
[[params.social]]
class = "fab fa-stack-overflow"
url = "https://stackoverflow.com/users/2425365"
url = "https://github.com/status-im"
[[params.social]]
class = "fab fa-twitter"
url = "https://twitter.com/activatedgeek"
url = "https://twitter.com/ethstatus"
[menu]
[[menu.main]]
identifier = "about"
name = "About Hugo"
name = "Corey Petty"
title = "about"
url = "/about"
weight = -10

View File

@ -1,7 +1,8 @@
### Contributions
Some text describing who did what.
- Corey Petty performed the aggregation of data, labeling of addresses, data munging and transformation, plot visualization, and writing.
- Jakub Sakolowski recommeneded the Hugo platform and assisted in platform familiarization, as well as various devOps questions.
### Reviewers
Some text with links describing who reviewed the article.
The associated Status accounts were reviewed by Jarrad Hope and Carl Bennetts

View File

@ -1,7 +1,7 @@
+++
title = "Attention and Augmented Recurrent Neural Networks"
title = "SNT Distribution Analysis: A visual article"
description = "This is a demo article."
date = "2017-01-10"
date = "2020-10-15"
thumbnail = ""
categories = [
"demo"
@ -31,68 +31,35 @@ vega = true
<p>This is the first paragraph of the article. Test a longdashhere it is.</p>
</d-abstract>
This is the first paragraph of the article. Test a longdashhere it is
This is an article that will discribe how SNT is distributed throughout its community. There was a previous analysis performed by the author {{<cite bib="pettyDistribution2017">}} directly after the Status.im ICO. This analysis attempted to look at who participated directly with the token distribution smart contract, and how they relate to each other. Since then, there has been a lot of development, a lot of movement of the SNT token, and adoption of several exchanges whcih drastically alters the distribution.
Test for owners possessive. Test for "quoting a passage." And another sentence. Or two. Some flopping fins; for diving.
Here we will create various plots that show, in as much detail as publicly possible, who holds what as it stands today and review is it looks any different than a naive view, or the snapshot given by the author directly after the ICO.
Heres a test of an inline equation {{<math>}}c = a^2 + b^2{{</math>}}. And then theres a block equation:
{{<math block="true">}}
c = \pm \sqrt{ \sum_{i=0}^{n}{a^{222} + b^2}}
{{</math>}}
Here we have the initial SNT distribution seperation. It is most easily seperated into three seperate sections which each require further analysis:
We can {{<cite bib="mercier2011humans">}} also cite {{<cite bib="gregor2015draw,mercier2011humans">}} external publications. {{<cite bib="dong2014image,dumoulin2016guide,mordvintsev2015inceptionism">}}.
{{<vega id="viz-compare" spec="status-exchange-community-donut.vg.json" >}}
We should also be testing footnotes{{<footnote>}}This will become a hoverable footnote. This will become a hoverable footnote. This will become a hoverable footnote. This will become a hoverable footnote. This will become a hoverable footnote. This will become a hoverable footnote. This will become a hoverable footnote. This will become a hoverable footnote.{{</footnote>}}. There are multiple footnotes, and they appear in the appendix{{<footnote>}}Given I have coded them right. Also, heres math in a footnote: {{<math>}}c = \sum_0^i{x}{{</math>}}. Also, a citation. Box-ception {{<cite bib="gregor2015draw">}}! {{</footnote>}} as well.
1. `Status`- contracts and accounts related to the Status Network. These don't necessarily need to be owned and operated by the Status Network GmbH, but certaily include those accounts.
2. `Exchanges` - accounts that have been identified {{<cite bib="etherscan,f13endgist">}} as accounts used by exchanges to store funds.
3. `Community` - accounts that cannot be attribute elsewhere that hold SNT, we consider this the "community."
| **First** | **Second** | **Third** |
|---|---|---|
| 23 | 654 | 23 |
| 14 | 54 | 34 |
| 234 | 54 | 23 |
An initial glance at this distribution combined with a naive understanding of the specifics of the Status related holdings will lead to the narrative that SNT is "centralized."
## Displaying code snippets
---
## Plots of Status related addresses
Some inline javascript: {{<code language="javascript">}}var x = 25;{{</code>}}
---
## Plots of Exchange addresses
Heres a javascript code block.
{{<code language="javascript" block="true">}}
var x = 25;
function(x){
return x * x;
}
{{</code>}}
{{<vega id="viz-exchange" spec="exchange-treemap.vg.json" >}}
We also support python.
{{<code language="python" block="true">}}
# Python 3: Fibonacci series up to n
def fib(n):
a, b = 0, 1
while a &lt; n:
print(a, end=' ')
a, b = b, a+b
{{</code>}}
---
## Plots of the Community distribution
And guess what! We also have Vega-Lite embedded graphs!
Here we break up the community accounts into groups of "exponential value."{{<footnote>}}Note that this plot is not interactive, because it is a picture and I haven't had time to create the vega-lite version of it yet.{{</footnote>}} That is, we bucket each address based on what order of magnitude it is, as well as note how big that bucket is to show how many people control how much total value.
{{<vega id="viz" spec="https://raw.githubusercontent.com/vega/vega/master/docs/examples/bar-chart.vg.json">}}
![alt](static_exp_group.png)
Thats it for the example article!
## Bringing it all together to get a real picture
<table>
<thead>
<tr>
<th>Address</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
{{ $url := "static/data_csv/holders.csv" }}
{{ $sep := "," }}
{{ range $i, $r := getCSV $sep $url }}
<tr>
<td>{{ index $r 0 }}</td>
<td>{{ index $r 1 }}</td>
</tr>
{{ end }}
</tbody>
</table>
Now that we have more insight into each of the sub-groups explained earlier, we can start to form a more informed picture of the total distribution of SNT across its various holders.

View File

@ -1,89 +1,18 @@
@article{gregor2015draw,
title={DRAW: A recurrent neural network for image generation},
author={Gregor, Karol and Danihelka, Ivo and Graves, Alex and Rezende, Danilo Jimenez and Wierstra, Daan},
journal={arXiv preprint arXiv:1502.04623},
@misc{etherscan,
title={Etherscan Blockchain Explorer},
author={Matthew Tann},
year={2015},
url ={https://arxiv.org/pdf/1502.04623.pdf}
url={https://etherscan.io},
}
@article{mercier2011humans,
title={Why do humans reason? Arguments for an argumentative theory},
author={Mercier, Hugo and Sperber, Dan},
journal={Behavioral and brain sciences},
volume={34},
number={02},
pages={57--74},
year={2011},
publisher={Cambridge Univ Press},
doi={10.1017/S0140525X10000968}
@misc{f13endgist,
title={Wallet Addresses Github Gist},
author={f13end},
year={2018},
url={https://gist.github.com/f13end/bf88acb162bed0b3dcf5e35f1fdb3c17},
}
@article{dong2014image,
title={Image super-resolution using deep convolutional networks},
author={Dong, Chao and Loy, Chen Change and He, Kaiming and Tang, Xiaoou},
journal={arXiv preprint arXiv:1501.00092},
year={2014},
url={https://arxiv.org/pdf/1501.00092.pdf}
}
@article{dumoulin2016adversarially,
title={Adversarially Learned Inference},
author={Dumoulin, Vincent and Belghazi, Ishmael and Poole, Ben and Lamb, Alex and Arjovsky, Martin and Mastropietro, Olivier and Courville, Aaron},
journal={arXiv preprint arXiv:1606.00704},
year={2016},
url={https://arxiv.org/pdf/1606.00704.pdf}
}
@article{dumoulin2016guide,
title={A guide to convolution arithmetic for deep learning},
author={Dumoulin, Vincent and Visin, Francesco},
journal={arXiv preprint arXiv:1603.07285},
year={2016},
url={https://arxiv.org/pdf/1603.07285.pdf}
}
@article{gauthier2014conditional,
title={Conditional generative adversarial nets for convolutional face generation},
author={Gauthier, Jon},
journal={Class Project for Stanford CS231N: Convolutional Neural Networks for Visual Recognition, Winter semester},
volume={2014},
year={2014},
url={http://www.foldl.me/uploads/papers/tr-cgans.pdf}
}
@article{johnson2016perceptual,
title={Perceptual losses for real-time style transfer and super-resolution},
author={Johnson, Justin and Alahi, Alexandre and Fei-Fei, Li},
journal={arXiv preprint arXiv:1603.08155},
year={2016},
url={https://arxiv.org/pdf/1603.08155.pdf}
}
@article{mordvintsev2015inceptionism,
title={Inceptionism: Going deeper into neural networks},
author={Mordvintsev, Alexander and Olah, Christopher and Tyka, Mike},
journal={Google Research Blog},
year={2015},
url={https://research.googleblog.com/2015/06/inceptionism-going-deeper-into-neural.html}
}
@misc{mordvintsev2016deepdreaming,
title={DeepDreaming with TensorFlow},
author={Mordvintsev, Alexander},
year={2016},
url={https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/deepdream/deepdream.ipynb},
}
@article{radford2015unsupervised,
title={Unsupervised representation learning with deep convolutional generative adversarial networks},
author={Radford, Alec and Metz, Luke and Chintala, Soumith},
journal={arXiv preprint arXiv:1511.06434},
year={2015},
url={https://arxiv.org/pdf/1511.06434.pdf}
}
@inproceedings{salimans2016improved,
title={Improved techniques for training gans},
author={Salimans, Tim and Goodfellow, Ian and Zaremba, Wojciech and Cheung, Vicki and Radford, Alec and Chen, Xi},
booktitle={Advances in Neural Information Processing Systems},
pages={2226--2234},
year={2016},
url={https://arxiv.org/pdf/1606.03498.pdf}
}
@article{shi2016deconvolution,
title={Is the deconvolution layer the same as a convolutional layer?},
author={Shi, Wenzhe and Caballero, Jose and Theis, Lucas and Huszar, Ferenc and Aitken, Andrew and Ledig, Christian and Wang, Zehan},
journal={arXiv preprint arXiv:1609.07009},
year={2016},
url={https://arxiv.org/pdf/1609.07009.pdf}
@#article{pettyDistribution2017,
title={A Look at the Status.im ICO Token Distribution},
author={Corey Petty},
year={2017},
url={https://medium.com/the-bitcoin-podcast-blog/a-look-at-the-status-im-ico-token-distribution-f5bcf7f00907},
}

86457
data_csv/holders_munged.csv Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,52 +0,0 @@
import pandas as pd
import numpy as np
snt_stats = {
'total_supply': 6804870174.8781,
}
def lower(string):
return string.lower()
def label_exp_group(value):
labels = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11']
for label in labels:
if value <= 10**float(label):
return label
# import known Status Addresses
status = pd.read_csv('./data_csv/utility.csv')
status['address'] = status['address'].apply(lower)
status['isStatus'] = True
# import holder accounts
holders = pd.read_csv('./data_csv/holders.csv')
holders['address'] = holders['address'].apply(lower)
# import exchange accounts
exchanges = pd.read_csv('./data_csv/exchanges.csv')
exchanges['address'] = exchanges['address'].apply(lower)
exchanges['isExchange'] = True
# merge into single dataset
holders = holders.merge(status, on="address", how="left")
holders = holders.merge(exchanges, on="address", how="left")
# clean up
holders['name_x'].fillna('', inplace=True)
holders['name_y'].fillna('', inplace=True)
holders['name'] = holders['name_x'] + holders['name_y']
# add additional columns
holders['percent'] = holders['balance'] / snt_stats['total_supply'] * 100
holders['exp_group'] = holders.balance.apply(label_exp_group)
# clean up NaN
holders['isContract'].fillna('False', inplace=True)
holders['isExchange'].fillna('False', inplace=True)
holders['isStatus'].fillna('False', inplace=True)
# filter out what we want
holders = holders[['address', 'balance', 'percent', 'exp_group', 'name', 'isContract', 'isExchange', 'isStatus']]
holders.to_csv('./data_csv/holders_munged.csv')

250
munge_and_generate_plots.py Normal file
View File

@ -0,0 +1,250 @@
import pandas as pd
import numpy as np
import json
snt_stats = {
'total_supply': 6804870174.8781,
}
def lower(string):
return string.lower()
def label_exp_group(value):
labels = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11']
for label in labels:
if value <= 10**float(label):
return label
# import known Status Addresses
status = pd.read_csv('./data_csv/utility.csv')
status['address'] = status['address'].apply(lower)
status['isStatus'] = True
# import holder accounts
holders = pd.read_csv('./data_csv/holders.csv')
holders['address'] = holders['address'].apply(lower)
# import exchange accounts
exchanges = pd.read_csv('./data_csv/exchanges.csv')
exchanges['address'] = exchanges['address'].apply(lower)
exchanges['isExchange'] = True
# merge into single dataset
holders = holders.merge(status, on="address", how="left")
holders = holders.merge(exchanges, on="address", how="left")
# clean up
holders['name_x'].fillna('', inplace=True)
holders['name_y'].fillna('', inplace=True)
holders['name'] = holders['name_x'] + holders['name_y']
# add additional columns
holders['percent'] = holders['balance'] / snt_stats['total_supply'] * 100
holders['exp_group'] = holders.balance.apply(label_exp_group)
# clean up NaN
holders['isContract'].fillna('False', inplace=True)
holders['isExchange'].fillna('False', inplace=True)
holders['isStatus'].fillna('False', inplace=True)
# filter out what we want
holders = holders[['address', 'balance', 'percent', 'exp_group', 'name', 'isContract', 'isExchange', 'isStatus']]
## Export holders CSV
holders.to_csv('./data_csv/holders_munged.csv')
##################### Plots creation
## Status vs Exchange vs Community
status_perc = holders[holders['isStatus'] == True].percent.sum()
exchange_perc = holders[holders['isExchange'] == True].percent.sum()
community_perc = 100 - status_perc - exchange_perc
vegaJson = {
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic bar chart example, with value labels shown upon mouse hover.",
"width": 400,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{"category": "Status", "amount": round(status_perc,2)},
{"category": "Exchanges", "amount": round(exchange_perc,2)},
{"category": "Community", "amount": round(community_perc,2)}
]
}
],
"signals": [
{
"name": "tooltip",
"value": {},
"on": [
{"events": "rect:mouseover", "update": "datum"},
{"events": "rect:mouseout", "update": "{}"}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "category"},
"range": "width",
"padding": 0.05,
"round": True
},
{
"name": "yscale",
"domain": {"data": "table", "field": "amount"},
"nice": True,
"range": "height"
}
],
"axes": [
{ "orient": "bottom", "scale": "xscale" },
{ "orient": "left", "scale": "yscale" }
],
"marks": [
{
"type": "rect",
"from": {"data":"table"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "category"},
"width": {"scale": "xscale", "band": 1},
"y": {"scale": "yscale", "field": "amount"},
"y2": {"scale": "yscale", "value": 0}
},
"update": {
"fill": {"value": "steelblue"}
},
"hover": {
"fill": {"value": "red"}
}
}
},
{
"type": "text",
"encode": {
"enter": {
"align": {"value": "center"},
"baseline": {"value": "bottom"},
"fill": {"value": "#333"}
},
"update": {
"x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
"y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
"text": {"signal": "tooltip.amount"},
"fillOpacity": [
{"test": "datum === tooltip", "value": 0},
{"value": 1}
]
}
}
}
]
}
with open('./static/status-exchange-community-donut.vg.json', 'w') as plot_file:
json.dump(vegaJson, plot_file, ensure_ascii=False, indent=4, sort_keys=False)
## Exchange Treemap
exchangeBarJson = holders[holders['isExchange'] == True].groupby("name").sum().reset_index().reset_index().to_json(orient='records')
vegaJson ={
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic bar chart example, with value labels shown upon mouse hover.",
"width": 400,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": json.loads(exchangeBarJson)
}
],
"signals": [
{
"name": "tooltip",
"value": {},
"on": [
{"events": "rect:mouseover", "update": "datum"},
{"events": "rect:mouseout", "update": "{}"}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "name"},
"range": "width",
"padding": 0.05,
"round": True
},
{
"name": "yscale",
"domain": {"data": "table", "field": "percent"},
"nice": True,
"range": "height"
}
],
"axes": [
{ "orient": "bottom", "scale": "xscale" },
{ "orient": "left", "scale": "yscale" }
],
"marks": [
{
"type": "rect",
"from": {"data":"table"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "name"},
"width": {"scale": "xscale", "band": 1},
"y": {"scale": "yscale", "field": "percent"},
"y2": {"scale": "yscale", "value": 0}
},
"update": {
"fill": {"value": "steelblue"}
},
"hover": {
"fill": {"value": "red"}
}
}
},
{
"type": "text",
"encode": {
"enter": {
"align": {"value": "center"},
"baseline": {"value": "bottom"},
"fill": {"value": "#333"}
},
"update": {
"x": {"scale": "xscale", "signal": "tooltip.name", "band": 0.5},
"y": {"scale": "yscale", "signal": "tooltip.percent", "offset": -2},
"text": {"signal": "tooltip.percent"},
"fillOpacity": [
{"test": "datum === tooltip", "value": 0},
{"value": 1}
]
}
}
}
]
}
with open('static/exchange-treemap.vg.json', 'w') as treemapPlot:
json.dump(vegaJson, treemapPlot, ensure_ascii=False, indent=4, sort_keys=False)

100
static/bar-chart.vg.json Normal file
View File

@ -0,0 +1,100 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic bar chart example, with value labels shown upon mouse hover.",
"width": 400,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{
"category": "Status.im",
"amount": 46.520569484242756
},
{
"category": "Exchanges",
"amount": 32.04532180329212
},
{
"category": "Community",
"amount": 21.434108712465125
}
]
}
],
"signals": [
{
"name": "tooltip",
"value": {},
"on": [
{"events": "rect:mouseover", "update": "datum"},
{"events": "rect:mouseout", "update": "{}"}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {"data": "table", "field": "category"},
"range": "width",
"padding": 0.05,
"round": true
},
{
"name": "yscale",
"domain": {"data": "table", "field": "amount"},
"nice": true,
"range": "height"
}
],
"axes": [
{ "orient": "bottom", "scale": "xscale" },
{ "orient": "left", "scale": "yscale" }
],
"marks": [
{
"type": "rect",
"from": {"data":"table"},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "category"},
"width": {"scale": "xscale", "band": 1},
"y": {"scale": "yscale", "field": "amount"},
"y2": {"scale": "yscale", "value": 0}
},
"update": {
"fill": {"value": "steelblue"}
},
"hover": {
"fill": {"value": "red"}
}
}
},
{
"type": "text",
"encode": {
"enter": {
"align": {"value": "center"},
"baseline": {"value": "bottom"},
"fill": {"value": "#333"}
},
"update": {
"x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
"y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
"text": {"signal": "tooltip.amount"},
"fillOpacity": [
{"test": "datum === tooltip", "value": 0},
{"value": 1}
]
}
}
}
]
}

View File

@ -0,0 +1,194 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic bar chart example, with value labels shown upon mouse hover.",
"width": 400,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{
"index": 0,
"name": "Binance",
"balance": 540477233.0112911,
"percent": 7.9425061628
},
{
"index": 1,
"name": "Bitfinex",
"balance": 75644081.8606061,
"percent": 1.1116168261
},
{
"index": 2,
"name": "Bitrex",
"balance": 1066272864.0312135,
"percent": 15.6692609356
},
{
"index": 3,
"name": "Gate.io",
"balance": 108969051.66943823,
"percent": 1.6013391713
},
{
"index": 4,
"name": "Huobi",
"balance": 197336263.422743,
"percent": 2.8999269398
},
{
"index": 5,
"name": "Kucoin",
"balance": 47290553.264842294,
"percent": 0.6949515869
},
{
"index": 6,
"name": "OKEx",
"balance": 122699341.4858642,
"percent": 1.8031106889
},
{
"index": 7,
"name": "Peatio",
"balance": 15296368.661758801,
"percent": 0.224785606
},
{
"index": 8,
"name": "Poloniex",
"balance": 6656788.42817715,
"percent": 0.0978238858
}
]
}
],
"signals": [
{
"name": "tooltip",
"value": {},
"on": [
{
"events": "rect:mouseover",
"update": "datum"
},
{
"events": "rect:mouseout",
"update": "{}"
}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {
"data": "table",
"field": "name"
},
"range": "width",
"padding": 0.05,
"round": true
},
{
"name": "yscale",
"domain": {
"data": "table",
"field": "percent"
},
"nice": true,
"range": "height"
}
],
"axes": [
{
"orient": "bottom",
"scale": "xscale"
},
{
"orient": "left",
"scale": "yscale"
}
],
"marks": [
{
"type": "rect",
"from": {
"data": "table"
},
"encode": {
"enter": {
"x": {
"scale": "xscale",
"field": "name"
},
"width": {
"scale": "xscale",
"band": 1
},
"y": {
"scale": "yscale",
"field": "percent"
},
"y2": {
"scale": "yscale",
"value": 0
}
},
"update": {
"fill": {
"value": "steelblue"
}
},
"hover": {
"fill": {
"value": "red"
}
}
}
},
{
"type": "text",
"encode": {
"enter": {
"align": {
"value": "center"
},
"baseline": {
"value": "bottom"
},
"fill": {
"value": "#333"
}
},
"update": {
"x": {
"scale": "xscale",
"signal": "tooltip.name",
"band": 0.5
},
"y": {
"scale": "yscale",
"signal": "tooltip.percent",
"offset": -2
},
"text": {
"signal": "tooltip.percent"
},
"fillOpacity": [
{
"test": "datum === tooltip",
"value": 0
},
{
"value": 1
}
]
}
}
}
]
}

88
static/pie-chart.vg.json Normal file
View File

@ -0,0 +1,88 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic donut chart example.",
"width": 200,
"height": 200,
"autosize": "none",
"signals": [
{
"name": "startAngle", "value": 0,
"bind": {"input": "range", "min": 0, "max": 6.29, "step": 0.01}
},
{
"name": "endAngle", "value": 6.29,
"bind": {"input": "range", "min": 0, "max": 6.29, "step": 0.01}
},
{
"name": "padAngle", "value": 0,
"bind": {"input": "range", "min": 0, "max": 0.1}
},
{
"name": "innerRadius", "value": 60,
"bind": {"input": "range", "min": 0, "max": 90, "step": 1}
},
{
"name": "cornerRadius", "value": 0,
"bind": {"input": "range", "min": 0, "max": 10, "step": 0.5}
},
{
"name": "sort", "value": false,
"bind": {"input": "checkbox"}
}
],
"data": [
{
"name": "table",
"values": [
{"id": 1, "field": 4},
{"id": 2, "field": 6},
{"id": 3, "field": 10},
{"id": 4, "field": 3},
{"id": 5, "field": 7},
{"id": 6, "field": 8}
],
"transform": [
{
"type": "pie",
"field": "field",
"startAngle": {"signal": "startAngle"},
"endAngle": {"signal": "endAngle"},
"sort": {"signal": "sort"}
}
]
}
],
"scales": [
{
"name": "color",
"type": "ordinal",
"domain": {"data": "table", "field": "id"},
"range": {"scheme": "category20"}
}
],
"marks": [
{
"type": "arc",
"from": {"data": "table"},
"encode": {
"enter": {
"fill": {"scale": "color", "field": "id"},
"x": {"signal": "width / 2"},
"y": {"signal": "height / 2"}
},
"update": {
"startAngle": {"field": "startAngle"},
"endAngle": {"field": "endAngle"},
"padAngle": {"signal": "padAngle"},
"innerRadius": {"signal": "innerRadius"},
"outerRadius": {"signal": "width / 2"},
"cornerRadius": {"signal": "cornerRadius"}
}
}
}
]
}

BIN
static/static_exp_group.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -0,0 +1,152 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic bar chart example, with value labels shown upon mouse hover.",
"width": 400,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{
"category": "Status",
"amount": 46.52
},
{
"category": "Exchanges",
"amount": 32.05
},
{
"category": "Community",
"amount": 21.43
}
]
}
],
"signals": [
{
"name": "tooltip",
"value": {},
"on": [
{
"events": "rect:mouseover",
"update": "datum"
},
{
"events": "rect:mouseout",
"update": "{}"
}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"domain": {
"data": "table",
"field": "category"
},
"range": "width",
"padding": 0.05,
"round": true
},
{
"name": "yscale",
"domain": {
"data": "table",
"field": "amount"
},
"nice": true,
"range": "height"
}
],
"axes": [
{
"orient": "bottom",
"scale": "xscale"
},
{
"orient": "left",
"scale": "yscale"
}
],
"marks": [
{
"type": "rect",
"from": {
"data": "table"
},
"encode": {
"enter": {
"x": {
"scale": "xscale",
"field": "category"
},
"width": {
"scale": "xscale",
"band": 1
},
"y": {
"scale": "yscale",
"field": "amount"
},
"y2": {
"scale": "yscale",
"value": 0
}
},
"update": {
"fill": {
"value": "steelblue"
}
},
"hover": {
"fill": {
"value": "red"
}
}
}
},
{
"type": "text",
"encode": {
"enter": {
"align": {
"value": "center"
},
"baseline": {
"value": "bottom"
},
"fill": {
"value": "#333"
}
},
"update": {
"x": {
"scale": "xscale",
"signal": "tooltip.category",
"band": 0.5
},
"y": {
"scale": "yscale",
"signal": "tooltip.amount",
"offset": -2
},
"text": {
"signal": "tooltip.amount"
},
"fillOpacity": [
{
"test": "datum === tooltip",
"value": 0
},
{
"value": 1
}
]
}
}
}
]
}