mirror of
https://github.com/olehomelchenko/olehomelchenko.com.git
synced 2026-02-05 02:54:37 +00:00
chore: move posts to qmd
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
---
|
||||
title: "Bar Charts: Makeover in Vega-Lite"
|
||||
date: 2025-07-07
|
||||
draft: false
|
||||
image: https://static.olehomelchenko.com/blog/tableau-seven-bar-charts-yoy-growth.png
|
||||
|
||||
load_vega: true
|
||||
tags:
|
||||
- dataviz
|
||||
- vega-lite
|
||||
- makeover
|
||||
---
|
||||
|
||||
## oeuth
|
||||
|
||||
Of all tools for data visualization, I mostly enjoy working with Vega-Lite. As I enhance my skills in making the visualizations using it, I become increasingly interesting not just in the "dataviz" part of its capabilities, but also on making it aesthetically compelling, as well as challenging myself to reach the limits of what is possible with Vega-Lite. I am by no means near the limits so far, however I got increasingly interested in replicating the charts I see throughout the internet.
|
||||
|
||||
One that caught me attention is Tableau's Viz of the Day: [Seven Bar Charts to Visualise Year-Over-Year Growth](https://public.tableau.com/app/profile/jacob.rothemund/viz/SevenBarChartstoVisualiseYear-Over-YearGrowth/Dashboard)
|
||||
@@ -75,7 +72,7 @@ After this, we can make the following layers:
|
||||
- `text` mark with calculated `text_label`
|
||||
- two separate `point` mark layers, each with a different color but more importantly - `triangle-up` and `triangle-down`. We cannot encode the two marks dynamically (or, rather, we cannot make dynamic fill color which is my goal here) so we'll need to do it separately for positive and negative changes.
|
||||
|
||||
{{< vega-lite id="chart-bar-in-bar" actions="true">}}
|
||||
```{.vega-lite}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"width": 400,
|
||||
@@ -300,13 +297,13 @@ After this, we can make the following layers:
|
||||
}
|
||||
]
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
```
|
||||
|
||||
|
||||
## Highlighted Absolute Change
|
||||
|
||||
This one largely repeats the bar-in-bar, with the exception that the highlighted changes are achieved by combining `x` and `x2` channels combined with `color`
|
||||
{{< vega-lite id="chart-highlighted-absolute-change" actions="true">}}
|
||||
```{.vega-lite}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"width": 400,
|
||||
@@ -556,13 +553,13 @@ This one largely repeats the bar-in-bar, with the exception that the highlighted
|
||||
}
|
||||
]
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
```
|
||||
|
||||
## Bullet
|
||||
|
||||
Key difference in schema here - instead of highlighted bar mark, we use `tick` with exact value for the previous period.
|
||||
|
||||
{{< vega-lite id="chart-bullet" actions="true">}}
|
||||
```{.vega-lite}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"width": 400,
|
||||
@@ -793,13 +790,13 @@ Key difference in schema here - instead of highlighted bar mark, we use `tick` w
|
||||
}
|
||||
]
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
```
|
||||
|
||||
|
||||
## Direction Arrows
|
||||
|
||||
|
||||
{{< vega-lite id="chart-direction-arrows" actions="true">}}
|
||||
```{.vega-lite}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"width": 400,
|
||||
@@ -1044,7 +1041,8 @@ Key difference in schema here - instead of highlighted bar mark, we use `tick` w
|
||||
}
|
||||
]
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Error Bars
|
||||
@@ -2,8 +2,10 @@
|
||||
title: Блоги та Ресурси з візуалізації даних
|
||||
date: 2024-07-20
|
||||
draft: false
|
||||
lang: uk
|
||||
tags:
|
||||
- Датавіз
|
||||
- Dataviz
|
||||
---
|
||||
|
||||
- https://datatowel.in.ua/ - демографія, економіка, електоральна географія України
|
||||
|
||||
@@ -8,6 +8,7 @@ languages:
|
||||
- R
|
||||
- Python
|
||||
---
|
||||
|
||||
### Аналіз даних
|
||||
- **The Data Journalism Handbook**:
|
||||
- [переклад українською на texty.org.ua (2015)](https://texty.org.ua/archive-books/40161/zhurnalistyka-danykh-posibnyk-40161/),
|
||||
@@ -18,20 +19,24 @@ languages:
|
||||
- The Quartz guide to bad data - [Оригінал EN (GitHub)](https://github.com/Quartz/bad-data-guide)
|
||||
|
||||
### Візуалізація даних
|
||||
- **Visualization Analysis and Design*- by Tamara Munzner: [taylorfrancis.com](https://www.taylorfrancis.com/books/mono/10.1201/b17511/visualization-analysis-design-tamara-munzner)
|
||||
- **Fundamentals of Data Visualization*- by Claus O. Wilke: [clauswilke.com/dataviz](https://clauswilke.com/dataviz/)
|
||||
- **Visualization Analysis and Design**- by Tamara Munzner: [taylorfrancis.com](https://www.taylorfrancis.com/books/mono/10.1201/b17511/visualization-analysis-design-tamara-munzner)
|
||||
- **Fundamentals of Data Visualization**- by Claus O. Wilke: [clauswilke.com/dataviz](https://clauswilke.com/dataviz/)
|
||||
- **Good Charts: The HBR Guide to Making Smarter, More Persuasive Data Visualizations**
|
||||
- EN: [Amazon](https://www.amazon.com/dp/1633690709)
|
||||
- **Good Charts Workbook: Tips, Tools, and Exercises for Making Better Data Visualizations**
|
||||
- EN: [Amazon](https://www.amazon.com/dp/1633696170)
|
||||
- Українською: [ArtHuss](https://www.arthuss.com.ua/shop/khoroshi-diahramy)
|
||||
- **ggplot2 book*- by Hadley Wickham: [ggplot2-book.org](https://ggplot2-book.org/)
|
||||
- **Storytelling With Data** by Cole N. Knaflic
|
||||
- EN: [Amazon](https://www.amazon.com/Storytelling-Data-Visualization-Business-Professionals/dp/1119002257?linkId=309f73640a0cb64e3b676e26561d07a0&language=en_US)
|
||||
- Українською: [ArtHuss](https://www.arthuss.com.ua/shop/efektyvna-rozpovid-za-dopomohoyu-danykh)
|
||||
- **ggplot2 book**- by Hadley Wickham: [ggplot2-book.org](https://ggplot2-book.org/)
|
||||
|
||||
### Курси та навчальні програми
|
||||
- **SDS 375 - Data Visualization in R*- - by Claus O. Wilke: https://wilkelab.org/SDS375/
|
||||
- **Computing for Information Science*- by Benjamin Soltoff: https://info5940.infosci.cornell.edu/
|
||||
|
||||
- **SDS 375 - Data Visualization in R**- - by Claus O. Wilke: https://wilkelab.org/SDS375/
|
||||
- **DS 4200 F23: Information Presentation & Visualization** - https://neu-ds-4200-f23.github.io/
|
||||
- **Computing for Information Science**- by Benjamin Soltoff: https://info5940.infosci.cornell.edu/
|
||||
|
||||
|
||||
### Інше
|
||||
- **A Layered Grammar of Graphics*- by [Hadley Wickham](https://substack.com/@hadleywickham): [PDF](https://static.olehomelchenko.com/wickham_layered-grammar.pdf)
|
||||
- **A Layered Grammar of Graphics**- by [Hadley Wickham](https://substack.com/@hadleywickham): [PDF](https://static.olehomelchenko.com/wickham_layered-grammar.pdf)
|
||||
- **Science of Visual Data Communication - What Works** [Online](https://journals.sagepub.com/doi/epub/10.1177/15291006211051956)
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
---
|
||||
title: Візуалізація руху електроенергії з та в Україну за даними ENTSO-E
|
||||
date: 2024-07-21T20:20:24+03:00
|
||||
draft: true
|
||||
|
||||
load_vega: true
|
||||
image: https://static.olehomelchenko.com/2026-01-10%2004.45.50.png
|
||||
---
|
||||
|
||||
|
||||
|
||||
{{< vega-lite id="entso-e-bar" dataUrl="https://github.com/olehomelchenko/ua-entso-e-transfers/raw/main/output.json">}}
|
||||
```{.vega-lite}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"data": {
|
||||
@@ -130,11 +126,11 @@ load_vega: true
|
||||
}
|
||||
}
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
```
|
||||
|
||||
|
||||
|
||||
{{< vega-lite id="entso-e-dynamics" dataUrl="https://github.com/olehomelchenko/ua-entso-e-transfers/raw/main/output.json">}}
|
||||
```{.vega-lite}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"data": {
|
||||
@@ -323,4 +319,4 @@ load_vega: true
|
||||
}
|
||||
]
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
```
|
||||
@@ -2,6 +2,8 @@
|
||||
title: "Візуалізація: Топ-50 благодійних фондів за версією Forbes"
|
||||
date: 2024-09-11
|
||||
draft: false
|
||||
lang: uk
|
||||
image: https://static.olehomelchenko.com/2026-01-08%2005.32.39.png
|
||||
tags:
|
||||
- Dataviz
|
||||
- Showcase
|
||||
@@ -9,7 +11,6 @@ languages:
|
||||
- Vega-Lite
|
||||
|
||||
|
||||
load_vega: true
|
||||
---
|
||||
|
||||
В нещодавньому випуску український Forbes опублікував список топ-50 благодійних фондів України.
|
||||
@@ -23,7 +24,7 @@ load_vega: true
|
||||
## Список фондів за структурою надходжень
|
||||
|
||||
|
||||
{{< vega-lite id="entso-e-dynamics" width=600 height=1000 >}}
|
||||
```{.vega-lite}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"config": {
|
||||
@@ -51,7 +52,7 @@ load_vega: true
|
||||
"anchor": "middle"
|
||||
}
|
||||
},
|
||||
"orient": "bottom",
|
||||
"orient": "top",
|
||||
"gradientLength": 500,
|
||||
"labelLimit": 500,
|
||||
"columns": 3,
|
||||
@@ -81,7 +82,7 @@ load_vega: true
|
||||
"width": 600,
|
||||
"params": [
|
||||
{
|
||||
"name": "org",
|
||||
"name": "Джерело",
|
||||
"select": {"type": "point", "fields": ["Джерело"]},
|
||||
"bind": {
|
||||
"input": "select",
|
||||
@@ -115,7 +116,7 @@ load_vega: true
|
||||
"fold": ["Юрособи", "Фізособи", "Нерезиденти", "Інше"],
|
||||
"as": ["Джерело", "value"]
|
||||
},
|
||||
{"filter": {"param": "org"}}
|
||||
{"filter": {"param": "Джерело"}}
|
||||
],
|
||||
"data": {
|
||||
"values": [
|
||||
@@ -922,4 +923,4 @@ load_vega: true
|
||||
]
|
||||
}
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
```
|
||||
|
||||
@@ -3,12 +3,12 @@ title: "Posts"
|
||||
page-layout: full
|
||||
listing:
|
||||
contents: "*.qmd"
|
||||
type: default
|
||||
type: grid
|
||||
sort: "date desc"
|
||||
categories: true
|
||||
sort-ui: true
|
||||
filter-ui: true
|
||||
fields: [date, title, reading-time, categories]
|
||||
fields: [image, date, title, reading-time, categories]
|
||||
date-format: "D MMMM YYYY"
|
||||
page-size: 10
|
||||
---
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: Рушій блогу для цього сайту
|
||||
date: 2024-07-21T20:20:24+03:00
|
||||
draft: false
|
||||
---
|
||||
|
||||
Для створення цього сайту я надихався декількома блогами.
|
||||
|
||||
В першу чергу я зупинився на генераторах статичних сайтів, з міркувань простоти.
|
||||
|
||||
З-поміж багатьох існуючих фреймворків обрав один з найбільш популярних (бо по ньому має бути багато напрацювань спільноти) та не закинутий опенсорс проєкт.
|
||||
|
||||
В результаті отримав одним з перших кандидатів [Hugo](https://gohugo.io/). Одна з його переваг - широкий вибір тем які можна кастомізувати. Як прихильник мінімальної кількості ганяти лишні байти туди-сюди, обрав тему [PaperMod](https://adityatelange.github.io/hugo-PaperMod/tags/papermod/)
|
||||
|
||||
- [Installation](https://github.com/adityatelange/hugo-PaperMod/wiki/Installation)
|
||||
@@ -1,145 +0,0 @@
|
||||
---
|
||||
title: Додавання Vega-Lite візуалізацій в Hugo за допомогою Shortcodes
|
||||
date: 2024-07-23
|
||||
draft: false
|
||||
tags:
|
||||
- Dataviz
|
||||
- Hugo
|
||||
languages:
|
||||
- Altair
|
||||
- Vega-Lite
|
||||
- Hugo
|
||||
|
||||
load_vega: true
|
||||
---
|
||||
|
||||
|
||||
Код специфікації vega-lite, що треба додати:
|
||||
```json
|
||||
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"description": "A simple bar chart with embedded data.",
|
||||
"data": {
|
||||
"values": [
|
||||
{"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
|
||||
{"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
|
||||
{"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
|
||||
]
|
||||
},
|
||||
"mark": "bar",
|
||||
"encoding": {
|
||||
"x": {"field": "a", "title": "aoesuthaosth", "type": "nominal", "axis": {"labelAngle": 0}},
|
||||
"y": {"field": "b", "type": "quantitative"}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
Замість ручного додавання скриптів та ембеддингу як в [туторіалі](https://vega.github.io/vega-lite/usage/embed.html), є можливість підійти трохи гнучкіше і завантажувати vega-lite бібліотеки лише на тих сторінках на яких вони потрібні, а також параметризувати деякі із штук за замовчуванням:
|
||||
|
||||
|
||||
```html
|
||||
<!-- Create a unique ID for the div where the Vega-Lite visualization will be rendered -->
|
||||
<div class="vegaVis" id="{{ .Get "id" | default "vega-lite-vis" }}"></div>
|
||||
<script>
|
||||
const spec = {{ .Inner | safeJS }};
|
||||
spec['width'] = spec['width']? spec['width'] : {{ .Get "width" | default 700}};
|
||||
spec['height'] = spec['height']? spec['height'] : {{ .Get "height" | default 300}};
|
||||
vegaEmbed('#{{ .Get "id" | default "vega-lite-vis" }}', spec, {"actions": false}).catch(console.error);
|
||||
|
||||
</script>
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
Використання (прибрати пробіл до/після `< >`, які я додав щоб воно не рендерилось):
|
||||
|
||||
|
||||
```
|
||||
{{ < vega-lite id="unique-vis-id-1" actions="true"> }}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"description": "A simple bar chart with embedded data.",
|
||||
"data": {
|
||||
"values": [
|
||||
{"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
|
||||
{"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
|
||||
{"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
|
||||
]
|
||||
},
|
||||
"mark": "bar",
|
||||
"width": 300,
|
||||
"encoding": {
|
||||
"x": {"field": "a", "title": "aoesuthaosth", "type": "nominal", "axis": {"labelAngle": 0}},
|
||||
"y": {"field": "b", "type": "quantitative"}
|
||||
}
|
||||
}
|
||||
{{ < /vega-lite > }}
|
||||
```
|
||||
|
||||
Результат:
|
||||
{{< vega-lite id="unique-vis-id-1" >}}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"description": "A simple bar chart with embedded data.",
|
||||
"data": {
|
||||
"values": [
|
||||
{"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
|
||||
{"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
|
||||
{"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
|
||||
]
|
||||
},
|
||||
"mark": "bar",
|
||||
"width": 300,
|
||||
"encoding": {
|
||||
"x": {"field": "a", "title": "aoesuthaosth", "type": "nominal", "axis": {"labelAngle": 0}},
|
||||
"y": {"field": "b", "type": "quantitative"}
|
||||
}
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
|
||||
|
||||
{{< vega-lite id="entso-e" dataUrl="https://github.com/olehomelchenko/ua-entso-e-transfers/raw/main/output.json">}}
|
||||
{
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"description": "Daily import and export visualization",
|
||||
"data": {
|
||||
"url": "https://github.com/olehomelchenko/ua-entso-e-transfers/raw/main/output.json"
|
||||
},
|
||||
"transform": [
|
||||
{ "calculate": "0-datum.Export_from_UA", "as": "Export" },
|
||||
{ "calculate": "datum.Import_to_UA", "as": "Import" }
|
||||
],
|
||||
"width": 800,
|
||||
"layer": [
|
||||
{
|
||||
"mark": "bar",
|
||||
"encoding": {
|
||||
"x": { "field": "Date", "type": "temporal", "title": "Date", "timeUnit": "yearmonthdate" },
|
||||
"y": { "field": "Import", "type": "quantitative", "title": "MW", "aggregate": "sum" },
|
||||
"color": { "value": "blue" },
|
||||
"tooltip": [
|
||||
{ "field": "Date", "type": "temporal", "title": "Date", "timeUnit": "yearmonthdate" },
|
||||
{ "field": "Import", "type": "quantitative", "title": "Import to UA (MW)", "aggregate": "sum" }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"mark": "bar",
|
||||
"encoding": {
|
||||
"x": { "field": "Date", "type": "temporal" , "timeUnit": "yearmonthdate"},
|
||||
"y": { "field": "Export", "type": "quantitative", "aggregate": "sum" },
|
||||
"color": { "value": "red" },
|
||||
"tooltip": [
|
||||
{ "field": "Date", "type": "temporal", "title": "Date", "timeUnit": "yearmonthdate" },
|
||||
{ "field": "Export", "type": "quantitative", "title": "Export from UA (MW)", "aggregate": "sum" }
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
{{< /vega-lite >}}
|
||||
Reference in New Issue
Block a user