This plugin can create a chart according to the result of advanced query, so that you can visualize any data in your logseq as you want.
这个插件能根据高级查询的结果绘制图表。帮助你可视化logseq中记录的数据。
- Use slash command
/Insert Query Chart
to insert a chart. - Write down the options of chart in the child block. Options including:
- chart type
- width
- height
- color scheme (optional)
- labels of data
- Write advanced query in grand child block.
- 使用斜杠命令
/Insert Query Chart
插入图表。 - 在子块中写入图表的一些设置选项。包括:
- 图表类型
- 图表宽度
- 图表高度
- 颜色 (可选)
- 数据的标签
- 在子块的子块中写入需要绘图的高级查找。
- bar (柱状图)
Check this link for all supported color schemes. Default color scheme is brewer.Paired12
.
所有配色方案请参考此链接. 默认配色方案为brewer.Paired12
。
You need to write a query whose result is a list of array. Take the following query as an example.
你需要写一个带有数组返回结果的查询。以下面这个查询为例
:query [:find ?x ?y
:in $ ?start ?today
:where
[?b :block/content ?x]
[?b :block/page ?journal]
[?journal :block/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?today)]
[?b :block/priority ?y]
]
:inputs [:-7d :today]
The result would be like [task1, A], [task2, B], [task3, C], ...
For x-y plot, the first elements in each array formats the data on x-axis.
查询结果将为[task1, A], [task2, B], [task3, C], ...
。对于x-y形式坐标系的图,第一个元素是横轴的标签。
It is recommended to use the relative date input if you need date/time paremeter. Check the usage in official document
如果你需要日期或者时间作为查询参数,建议使用相对日期的形式,详见官方文档
I have page like the following one. I log the sleep time as sleep-time [[改善睡眠质量,平均7小时]]
我有如下形式的页面。我会以睡眠时间 [[改善睡眠质量,平均7小时]]
的形式记录睡眠时间。
## [[OKR Tracker]]
- 6 [[改善睡眠质量,平均7小时]]
The query I used to generate a chart for the last 7 days is
我用如下查询绘制过去7天的睡眠时间曲线
{
:query [:find ?date ?result
:in $ ?start ?today ?kr
:where
[?b :block/parent ?p]
[?p :block/refs ?pr]
[?b :block/refs ?ref]
[?ref :block/name ?kr]
[?b :block/page ?journal]
[?journal :block/name ?date]
[?journal :block/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?today)]
[?b :block/content ?content]
[?pr :block/name "okr tracker"]
[(re-pattern "([\\d\\.]+)\\s\\[\\[.*\\]\\]") ?reg]
[(re-find ?reg ?content) ?c]
[(get ?c 1) ?result]
]
:inputs [:5d-before :today "改善睡眠质量,平均7小时"]
}
The chart is
图表如下
- Custom colorscheme
MIT