phibr0 / obsidian-charts

Charts - Obsidian Plugin | Create editable, interactive and animated Charts in Obsidian via Chart.js
https://charts.phib.ro/
GNU Affero General Public License v3.0
592 stars 27 forks source link

how to use series: via dataviewjs? #43

Closed BigbadHort closed 2 years ago

BigbadHort commented 2 years ago

thanks for the wonderful plugin and the ability to work with dataviewjs

This code works fine for me

const pages = dv.pages('"05πŸ§™Π‘ΠΈΡΠ°Π΄ΠΌΠΈΠ½/ΠΌΠΎΠΉ_ΠΊΠΎΠΌΠΏ_ΠΏΠ°Ρ€ΠΊ"').where(b => b.file.name != "ΠΌΠΎΠΉ_ΠΊΠΎΠΌΠΏ_ΠΏΠ°Ρ€ΠΊ.md").sort(k => k.rating, 'desc');
const labels = pages.map(b=>b["title"]);
const data = pages.map(b=>b["rating"]);

const chartData = {
    type: 'line',
    data: {
        labels: labels.values,
        datasets: [{
            label: 'Π Π΅ΠΉΡ‚ΠΈΠ½Π³',
            data: data.values,
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)'
            ],
            borderColor: [
                'rgba(255, 99, 132, 1)'
            ],
            borderWidth: 1
        }]
    }
}
window.renderChart(chartData, this.container);

but I can't figure out how to use series?

Could you give an example of working with cap of series?

BigbadHort commented 2 years ago

The answer!!! You can close it