Riksdagsmonitor Intelligence Platform - v0.7.19
    Preparing search index...
    • Generate an embeddable dashboard section with Chart.js charts.

      Returns a TemplateSection that can be appended to ArticleData.sections. Each chart is rendered as a <canvas> element with its Chart.js config stored in a data-chart-config attribute, consistent with the codebase's "no inline scripts" pattern. Client-side initialisation is NOT automatic — embedding pages must load Chart.js and run an initializer that reads data-chart-config (e.g. the shared chart-factory module).

      Parameters

      Returns TemplateSection

      import { generateDashboardSection } from './content-generators/dashboard-section.js';

      const section = generateDashboardSection({
      data: {
      title: 'Party Seat Distribution',
      summary: 'Current Riksdag seat allocation after 2022 election.',
      charts: [{
      id: 'seat-chart',
      type: 'bar',
      title: 'Seats by Party',
      labels: ['S', 'M', 'SD', 'C', 'V', 'KD', 'L', 'MP'],
      datasets: [{
      label: 'Seats',
      data: [107, 68, 73, 24, 24, 19, 16, 18],
      backgroundColor: ['#e8112d','#1b49dd','#dddd00','#009933','#da291c','#000077','#006ab3','#83cf39'],
      }],
      }],
      },
      lang: 'en',
      });

      articleData.sections = [...(articleData.sections ?? []), section];