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
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ hugo.darwin
|
|||||||
# Quarto
|
# Quarto
|
||||||
/.quarto/
|
/.quarto/
|
||||||
/_site/
|
/_site/
|
||||||
|
.venv/
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
### Basic Usage
|
### Basic Usage
|
||||||
|
|
||||||
````markdown
|
````markdown
|
||||||
```{vega-lite}
|
```{.vega-lite}
|
||||||
{
|
{
|
||||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -39,18 +39,19 @@
|
|||||||
### With Options
|
### With Options
|
||||||
|
|
||||||
````markdown
|
````markdown
|
||||||
```{vega-lite}
|
```{.vega-lite echo=false}
|
||||||
#| echo: false
|
|
||||||
#| code-fold: true
|
|
||||||
{your vega spec}
|
{your vega spec}
|
||||||
```
|
```
|
||||||
````
|
````
|
||||||
|
|
||||||
**Supported options:**
|
**Supported options:**
|
||||||
- `echo: false` - Hide the code, show only the visualization
|
- `echo=false` - Hide the code, show only the visualization
|
||||||
- `echo: true` - Show both code and visualization (default)
|
- `echo=true` - Show code (default)
|
||||||
- `code-fold: true` - Make code collapsible (collapsed by default)
|
- `code-fold=true` - Make code collapsible and collapsed (default)
|
||||||
- `code-fold: show` - Make code collapsible but open by default
|
- `code-fold=show` - Make code collapsible but expanded by default
|
||||||
|
- `code-fold=false` - Show code expanded, not collapsible
|
||||||
|
|
||||||
|
**Default behavior:** Code is shown in a collapsed, expandable section. Click to view the code.
|
||||||
|
|
||||||
## 🔧 How the Filter Works
|
## 🔧 How the Filter Works
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ The `vega-lite.lua` filter:
|
|||||||
|
|
||||||
**Quarto with Lua filter (NEW):**
|
**Quarto with Lua filter (NEW):**
|
||||||
````markdown
|
````markdown
|
||||||
```{vega-lite}
|
```{.vega-lite}
|
||||||
{
|
{
|
||||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"mark": "bar",
|
"mark": "bar",
|
||||||
@@ -107,7 +108,7 @@ The `vega-lite.lua` filter:
|
|||||||
|
|
||||||
3. **Replace with code fence:**
|
3. **Replace with code fence:**
|
||||||
````markdown
|
````markdown
|
||||||
```{vega-lite}
|
```{.vega-lite}
|
||||||
{your JSON spec here}
|
{your JSON spec here}
|
||||||
```
|
```
|
||||||
````
|
````
|
||||||
@@ -140,7 +141,7 @@ categories:
|
|||||||
|
|
||||||
## Simple Bar Chart
|
## Simple Bar Chart
|
||||||
|
|
||||||
```{vega-lite}
|
```{.vega-lite}
|
||||||
{
|
{
|
||||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"description": "A simple bar chart",
|
"description": "A simple bar chart",
|
||||||
@@ -178,4 +179,4 @@ categories:
|
|||||||
- Verify Vega-Lite spec schema version matches (v5)
|
- Verify Vega-Lite spec schema version matches (v5)
|
||||||
|
|
||||||
**Code block shown as plain text:**
|
**Code block shown as plain text:**
|
||||||
- Make sure you're using ````{vega-lite}` not ````{json}` or ````json`
|
- Make sure you're using ````{.vega-lite}` not ````{json}` or ````json`
|
||||||
|
|||||||
@@ -57,3 +57,7 @@ format:
|
|||||||
|
|
||||||
execute:
|
execute:
|
||||||
freeze: auto
|
freeze: auto
|
||||||
|
|
||||||
|
echo: true
|
||||||
|
code-fold: true
|
||||||
|
code-summary: "Click to show code"
|
||||||
@@ -1,17 +1,14 @@
|
|||||||
---
|
---
|
||||||
title: "Bar Charts: Makeover in Vega-Lite"
|
title: "Bar Charts: Makeover in Vega-Lite"
|
||||||
date: 2025-07-07
|
date: 2025-07-07
|
||||||
draft: false
|
image: https://static.olehomelchenko.com/blog/tableau-seven-bar-charts-yoy-growth.png
|
||||||
|
|
||||||
load_vega: true
|
|
||||||
tags:
|
tags:
|
||||||
- dataviz
|
- dataviz
|
||||||
- vega-lite
|
- vega-lite
|
||||||
- makeover
|
- 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.
|
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)
|
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`
|
- `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.
|
- 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",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"width": 400,
|
"width": 400,
|
||||||
@@ -300,13 +297,13 @@ After this, we can make the following layers:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
{{< /vega-lite >}}
|
```
|
||||||
|
|
||||||
|
|
||||||
## Highlighted Absolute Change
|
## 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`
|
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",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"width": 400,
|
"width": 400,
|
||||||
@@ -556,13 +553,13 @@ This one largely repeats the bar-in-bar, with the exception that the highlighted
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
{{< /vega-lite >}}
|
```
|
||||||
|
|
||||||
## Bullet
|
## Bullet
|
||||||
|
|
||||||
Key difference in schema here - instead of highlighted bar mark, we use `tick` with exact value for the previous period.
|
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",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"width": 400,
|
"width": 400,
|
||||||
@@ -793,13 +790,13 @@ Key difference in schema here - instead of highlighted bar mark, we use `tick` w
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
{{< /vega-lite >}}
|
```
|
||||||
|
|
||||||
|
|
||||||
## Direction Arrows
|
## Direction Arrows
|
||||||
|
|
||||||
|
|
||||||
{{< vega-lite id="chart-direction-arrows" actions="true">}}
|
```{.vega-lite}
|
||||||
{
|
{
|
||||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"width": 400,
|
"width": 400,
|
||||||
@@ -1044,7 +1041,8 @@ Key difference in schema here - instead of highlighted bar mark, we use `tick` w
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
{{< /vega-lite >}}
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Error Bars
|
## Error Bars
|
||||||
@@ -2,8 +2,10 @@
|
|||||||
title: Блоги та Ресурси з візуалізації даних
|
title: Блоги та Ресурси з візуалізації даних
|
||||||
date: 2024-07-20
|
date: 2024-07-20
|
||||||
draft: false
|
draft: false
|
||||||
|
lang: uk
|
||||||
tags:
|
tags:
|
||||||
- Датавіз
|
- Датавіз
|
||||||
|
- Dataviz
|
||||||
---
|
---
|
||||||
|
|
||||||
- https://datatowel.in.ua/ - демографія, економіка, електоральна географія України
|
- https://datatowel.in.ua/ - демографія, економіка, електоральна географія України
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ languages:
|
|||||||
- R
|
- R
|
||||||
- Python
|
- Python
|
||||||
---
|
---
|
||||||
|
|
||||||
### Аналіз даних
|
### Аналіз даних
|
||||||
- **The Data Journalism Handbook**:
|
- **The Data Journalism Handbook**:
|
||||||
- [переклад українською на texty.org.ua (2015)](https://texty.org.ua/archive-books/40161/zhurnalistyka-danykh-posibnyk-40161/),
|
- [переклад українською на 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)
|
- 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)
|
- **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/)
|
- **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**
|
- **Good Charts: The HBR Guide to Making Smarter, More Persuasive Data Visualizations**
|
||||||
- EN: [Amazon](https://www.amazon.com/dp/1633690709)
|
- EN: [Amazon](https://www.amazon.com/dp/1633690709)
|
||||||
- **Good Charts Workbook: Tips, Tools, and Exercises for Making Better Data Visualizations**
|
- **Good Charts Workbook: Tips, Tools, and Exercises for Making Better Data Visualizations**
|
||||||
- EN: [Amazon](https://www.amazon.com/dp/1633696170)
|
- EN: [Amazon](https://www.amazon.com/dp/1633696170)
|
||||||
- Українською: [ArtHuss](https://www.arthuss.com.ua/shop/khoroshi-diahramy)
|
- Українською: [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/
|
- **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/
|
- **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
|
title: Візуалізація руху електроенергії з та в Україну за даними ENTSO-E
|
||||||
date: 2024-07-21T20:20:24+03:00
|
date: 2024-07-21T20:20:24+03:00
|
||||||
draft: true
|
image: https://static.olehomelchenko.com/2026-01-10%2004.45.50.png
|
||||||
|
|
||||||
load_vega: true
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
```{.vega-lite}
|
||||||
|
|
||||||
{{< vega-lite id="entso-e-bar" dataUrl="https://github.com/olehomelchenko/ua-entso-e-transfers/raw/main/output.json">}}
|
|
||||||
{
|
{
|
||||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"data": {
|
"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",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"data": {
|
"data": {
|
||||||
@@ -323,4 +319,4 @@ load_vega: true
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
{{< /vega-lite >}}
|
```
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
title: "Візуалізація: Топ-50 благодійних фондів за версією Forbes"
|
title: "Візуалізація: Топ-50 благодійних фондів за версією Forbes"
|
||||||
date: 2024-09-11
|
date: 2024-09-11
|
||||||
draft: false
|
draft: false
|
||||||
|
lang: uk
|
||||||
|
image: https://static.olehomelchenko.com/2026-01-08%2005.32.39.png
|
||||||
tags:
|
tags:
|
||||||
- Dataviz
|
- Dataviz
|
||||||
- Showcase
|
- Showcase
|
||||||
@@ -9,7 +11,6 @@ languages:
|
|||||||
- Vega-Lite
|
- Vega-Lite
|
||||||
|
|
||||||
|
|
||||||
load_vega: true
|
|
||||||
---
|
---
|
||||||
|
|
||||||
В нещодавньому випуску український Forbes опублікував список топ-50 благодійних фондів України.
|
В нещодавньому випуску український 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",
|
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||||
"config": {
|
"config": {
|
||||||
@@ -51,7 +52,7 @@ load_vega: true
|
|||||||
"anchor": "middle"
|
"anchor": "middle"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orient": "bottom",
|
"orient": "top",
|
||||||
"gradientLength": 500,
|
"gradientLength": 500,
|
||||||
"labelLimit": 500,
|
"labelLimit": 500,
|
||||||
"columns": 3,
|
"columns": 3,
|
||||||
@@ -81,7 +82,7 @@ load_vega: true
|
|||||||
"width": 600,
|
"width": 600,
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
"name": "org",
|
"name": "Джерело",
|
||||||
"select": {"type": "point", "fields": ["Джерело"]},
|
"select": {"type": "point", "fields": ["Джерело"]},
|
||||||
"bind": {
|
"bind": {
|
||||||
"input": "select",
|
"input": "select",
|
||||||
@@ -115,7 +116,7 @@ load_vega: true
|
|||||||
"fold": ["Юрособи", "Фізособи", "Нерезиденти", "Інше"],
|
"fold": ["Юрособи", "Фізособи", "Нерезиденти", "Інше"],
|
||||||
"as": ["Джерело", "value"]
|
"as": ["Джерело", "value"]
|
||||||
},
|
},
|
||||||
{"filter": {"param": "org"}}
|
{"filter": {"param": "Джерело"}}
|
||||||
],
|
],
|
||||||
"data": {
|
"data": {
|
||||||
"values": [
|
"values": [
|
||||||
@@ -922,4 +923,4 @@ load_vega: true
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{< /vega-lite >}}
|
```
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ title: "Posts"
|
|||||||
page-layout: full
|
page-layout: full
|
||||||
listing:
|
listing:
|
||||||
contents: "*.qmd"
|
contents: "*.qmd"
|
||||||
type: default
|
type: grid
|
||||||
sort: "date desc"
|
sort: "date desc"
|
||||||
categories: true
|
categories: true
|
||||||
sort-ui: true
|
sort-ui: true
|
||||||
filter-ui: true
|
filter-ui: true
|
||||||
fields: [date, title, reading-time, categories]
|
fields: [image, date, title, reading-time, categories]
|
||||||
date-format: "D MMMM YYYY"
|
date-format: "D MMMM YYYY"
|
||||||
page-size: 10
|
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 >}}
|
|
||||||
62
styles.css
62
styles.css
@@ -1,5 +1,18 @@
|
|||||||
/* Minimal custom styling for olehomelchenko.com */
|
/* Minimal custom styling for olehomelchenko.com */
|
||||||
|
|
||||||
|
/* Vega-Lite visualization container */
|
||||||
|
.vega-viz-container {
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reverse order to put filters on top of canvas */
|
||||||
|
.chart-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column-reverse;
|
||||||
|
align-items: center;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Vega-Lite visualization styling - center and add subtle shadow */
|
/* Vega-Lite visualization styling - center and add subtle shadow */
|
||||||
.vega-embed {
|
.vega-embed {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -10,3 +23,52 @@
|
|||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Style the interactive parameter filters */
|
||||||
|
/* Hide when empty, style only when it has content */
|
||||||
|
.vega-bindings:empty {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vega-bindings:not(:empty) {
|
||||||
|
background: #f8f9fa;
|
||||||
|
border: 1px solid #dee2e6;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 15px 20px;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vega-bindings label {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-right: 20px;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #495057;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vega-bindings input,
|
||||||
|
.vega-bindings select {
|
||||||
|
padding: 6px 12px;
|
||||||
|
border: 1px solid #ced4da;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: white;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #495057;
|
||||||
|
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vega-bindings input:focus,
|
||||||
|
.vega-bindings select:focus {
|
||||||
|
border-color: #80bdff;
|
||||||
|
outline: 0;
|
||||||
|
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vega-bindings select {
|
||||||
|
cursor: pointer;
|
||||||
|
min-width: 150px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ title: "TILs - Today I Learned"
|
|||||||
page-layout: full
|
page-layout: full
|
||||||
listing:
|
listing:
|
||||||
contents: "*.qmd"
|
contents: "*.qmd"
|
||||||
type: table
|
type: default
|
||||||
sort: "date desc"
|
sort: "date desc"
|
||||||
fields: [date, title, categories]
|
fields: [date, title, categories]
|
||||||
date-format: "YYYY-MM-DD"
|
date-format: "YYYY-MM-DD"
|
||||||
table-striped: true
|
# table-striped: true
|
||||||
filter-ui: true
|
# filter-ui: true
|
||||||
---
|
---
|
||||||
|
|
||||||
Quick tips, discoveries, and learnings. Short-form content about interesting things I've discovered.
|
Quick tips, discoveries, and learnings. Short-form content about interesting things I've discovered.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ draft: false
|
|||||||
|
|
||||||
Серія блогів
|
Серія блогів
|
||||||
|
|
||||||
https://jamierubin.net/blog-series/practically-paperless-with-obsidian/
|
[https://jamierubin.net/blog-series/practically-paperless-with-obsidian/](https://jamierubin.net/blog-series/practically-paperless-with-obsidian/ )
|
||||||
|
|
||||||
|
|
||||||
Obsidian для воркфлоу наукових досліджень: https://medium.com/@alexandraphelan/an-updated-academic-workflow-zotero-obsidian-cffef080addd
|
Obsidian для воркфлоу наукових досліджень: [https://medium.com/@alexandraphelan/an-updated-academic-workflow-zotero-obsidian-cffef080addd](https://medium.com/@alexandraphelan/an-updated-academic-workflow-zotero-obsidian-cffef080addd)
|
||||||
|
|||||||
28
til/ojs-in-quarto.qmd
Normal file
28
til/ojs-in-quarto.qmd
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
title: ObservableJS in Quarto
|
||||||
|
date: 2025-01-10
|
||||||
|
draft: false
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
```{ojs}
|
||||||
|
vegalite = require("@observablehq/vega-lite")
|
||||||
|
|
||||||
|
vegalite({
|
||||||
|
"$schema": "https://vega.github.io/schema/vega-lite/v6.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", "type": "nominal", "axis": {"labelAngle": 0}},
|
||||||
|
"y": {"field": "b", "type": "quantitative"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
@@ -30,8 +30,9 @@ function CodeBlock(block)
|
|||||||
local echo = block.attributes['echo']
|
local echo = block.attributes['echo']
|
||||||
local codeFold = block.attributes['code-fold']
|
local codeFold = block.attributes['code-fold']
|
||||||
|
|
||||||
-- Default to showing code
|
-- Default to showing code collapsed
|
||||||
if echo == nil then echo = "true" end
|
if echo == nil then echo = "true" end
|
||||||
|
if codeFold == nil then codeFold = "true" end
|
||||||
|
|
||||||
local result = {}
|
local result = {}
|
||||||
|
|
||||||
@@ -62,7 +63,9 @@ function CodeBlock(block)
|
|||||||
|
|
||||||
-- Create the HTML output for the visualization
|
-- Create the HTML output for the visualization
|
||||||
local html = string.format([[
|
local html = string.format([[
|
||||||
<div id="%s"></div>
|
<div class="vega-viz-container">
|
||||||
|
<div id="%s"></div>
|
||||||
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
vegaEmbed('#%s', %s, {"actions": true});
|
vegaEmbed('#%s', %s, {"actions": true});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user