Advertisement
dhniceday

Untitled

Jan 3rd, 2024
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ```dataviewjs
  2. const rawData = await dv.query('TABLE WITHOUT ID file.name, G.distanz, G.dauer FROM "10 - Daily Notes" WHERE sport AND (contains(sport.type, "Gehen") OR contains(sport.type, "Laufen")) FLATTEN sport.gehen AS G SORT file.name DESC');
  3. const rows = rawData.value.values;
  4.  
  5.  
  6. const chartData = {
  7.     data: {
  8.         labels: rows.map(x => x[0]),
  9.         datasets: [{
  10.             type: 'bar',
  11.             label: 'km',
  12.             data: rows.map(x => x[1]),
  13.             barThickness: 3,
  14.             pointStyle: 'cross',
  15.             backgroundColor: ['#478FEE'],
  16.             borderWidth: 1,
  17.             borderColor: ['#478FEE'],
  18.             fill: false,
  19.             xAxisID: 'x2'
  20.             },
  21.             {
  22.             type: 'bar',
  23.             label: 'Minuten',
  24.             data: rows.map(x => x[2]),
  25.             barThickness: 3,
  26.             backgroundColor: ['#44475a'],
  27.             borderWidth: 0,
  28.             borderColor: ['#44475a'],
  29.             fill: false,
  30.             xAxisID: 'x1',         
  31.             },
  32.         ],
  33.     },
  34.     options: {
  35.        
  36.         responsive: true,
  37.         animations: true,
  38.         indexAxis: 'y',
  39.         plugins: {
  40.             legend: {
  41.                 display: true,
  42.                 position: 'bottom',
  43.             },         
  44.         },
  45.         scales: {
  46.             x1: {
  47.                 type: 'linear',
  48.                 display: true,
  49.                 position: 'top',
  50.             },
  51.             x2: {
  52.                 type: 'linear',
  53.                 display: true,
  54.                 position: 'bottom',
  55.             },
  56.         },
  57.     },
  58. }
  59.  
  60. // this.container.style.width = "80%";
  61. // this.container.style.margin = "auto";
  62.  
  63. window.renderChart(chartData, this.container);
  64. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement