الانتقال إلى المحتوى
الأقسام
مكوّنات Rastrillo

الجداول والمخططات

جدول أرقام وثلاثة مخططات: مخطط أشرطة، ومخطط خطي، ومخطط مصغّر. يرسمها الخادم دون JavaScript.

كل مثال يعمل فعلًا، لكن روابطه لا تؤدي إلى أي مكان. يعرض HTML الترميز الجاهز للنسخ.

data-table

جدول أرقام داخل بطاقة. على الشاشة الضيقة، مرِّر البطاقة أفقيًا لترى كل الأعمدة. تبقى عناوين الصفوف ظاهرة.

مرتّب حسب رقم

معاينة
<div rst-box-head>
  <h2 id="sales-h">المبيعات حسب الأسبوع</h2>
</div>
<div rst-card rst-table-scroll="" tabindex="0" role="region" aria-labelledby="sales-h">
  <table rst-table="" aria-labelledby="sales-h">
    <thead>
      <tr>
        <th scope="col">الأسبوع</th>
        <th scope="col" rst-num aria-sort="descending">
          <a href="/sales?sort=sold&amp;dir=asc">المُباع<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></a>
        </th>
        <th scope="col" rst-num>
          <a href="/sales?sort=target&amp;dir=desc">الهدف<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></a>
        </th>
        <th scope="col" rst-num>المبالغ المستردة</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">3</th>
        <td rst-num>260</td>
        <td rst-num>600</td>
        <td rst-num>5</td>
      </tr>
      <tr>
        <th scope="row">4</th>
        <td rst-num>240</td>
        <td rst-num>600</td>
        <td rst-num>1</td>
      </tr>
      <tr>
        <th scope="row">2</th>
        <td rst-num>180</td>
        <td rst-num>600</td>
        <td rst-num>0</td>
      </tr>
      <tr>
        <th scope="row">1</th>
        <td rst-num>120</td>
        <td rst-num>600</td>
        <td rst-num>2</td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <th scope="row">الإجمالي</th>
        <td rst-num>800</td>
        <td rst-num>2,400</td>
        <td rst-num>8</td>
      </tr>
    </tfoot>
  </table>
</div>
{{template "data-table" dict
    "Columns" (list
        (dict "Label" "الأسبوع")
        (dict "Href" "/sales?sort=sold&dir=asc" "Label" "المُباع" "Num" true "Sort" "descending")
        (dict "Href" "/sales?sort=target&dir=desc" "Label" "الهدف" "Num" true)
        (dict "Label" "المبالغ المستردة" "Num" true))
    "Foot" (list "الإجمالي" 800 2400 8)
    "ID" "sales"
    "Rows" (list (list 3 260 600 5) (list 4 240 600 1) (list 2 180 600 0) (list 1 120 600 2))
    "Title" "المبيعات حسب الأسبوع"}}

اربط عنوان العمود بالقائمة المرتبة، ثم اضبط Sort على ذلك العمود. علِّم أعمدة الأرقام بـ Num.

كثيف، مع صف عناوين ثابت

معاينة
<div rst-box-head>
  <h2 id="sales-dense-h">المبيعات حسب الأسبوع</h2>
</div>
<div rst-card rst-table-scroll="bounded" tabindex="0" role="region" aria-labelledby="sales-dense-h">
  <table rst-table="dense" aria-labelledby="sales-dense-h">
    <thead>
      <tr>
        <th scope="col">الأسبوع</th>
        <th scope="col" rst-num>المُباع</th>
        <th scope="col" rst-num>الهدف</th>
        <th scope="col" rst-num>المبالغ المستردة</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">1</th>
        <td rst-num>120</td>
        <td rst-num>600</td>
        <td rst-num>2</td>
      </tr>
      <tr>
        <th scope="row">2</th>
        <td rst-num>180</td>
        <td rst-num>600</td>
        <td rst-num>0</td>
      </tr>
      <tr>
        <th scope="row">3</th>
        <td rst-num>260</td>
        <td rst-num>600</td>
        <td rst-num>5</td>
      </tr>
      <tr>
        <th scope="row">4</th>
        <td rst-num>240</td>
        <td rst-num>600</td>
        <td rst-num>1</td>
      </tr>
      <tr>
        <th scope="row">5</th>
        <td rst-num>390</td>
        <td rst-num>600</td>
        <td rst-num>3</td>
      </tr>
      <tr>
        <th scope="row">6</th>
        <td rst-num>610</td>
        <td rst-num>600</td>
        <td rst-num>4</td>
      </tr>
      <tr>
        <th scope="row">7</th>
        <td rst-num>650</td>
        <td rst-num>600</td>
        <td rst-num>0</td>
      </tr>
      <tr>
        <th scope="row">8</th>
        <td rst-num>690</td>
        <td rst-num>600</td>
        <td rst-num>2</td>
      </tr>
    </tbody>
  </table>
</div>
{{template "data-table" dict
    "Bounded" true
    "Columns" (list
        (dict "Label" "الأسبوع")
        (dict "Label" "المُباع" "Num" true)
        (dict "Label" "الهدف" "Num" true)
        (dict "Label" "المبالغ المستردة" "Num" true))
    "Dense" true
    "ID" "sales-dense"
    "Rows" (list (list 1 120 600 2) (list 2 180 600 0) (list 3 260 600 5) (list 4 240 600 1) (list 5 390 600 3) (list 6 610 600 4) (list 7 650 600 0) (list 8 690 600 2))
    "Title" "المبيعات حسب الأسبوع"}}

يضغط Dense الصفوف. ويحدّ Bounded الارتفاع ويُبقي الترويسة ظاهرة أثناء تمرير الصفوف.

لا صفوف مطابقة

معاينة
<div rst-box-head>
  <h2 id="sales-none-h">المبيعات حسب الأسبوع</h2>
</div>
<div rst-card rst-table-scroll="" tabindex="0" role="region" aria-labelledby="sales-none-h">
  <table rst-table="" aria-labelledby="sales-none-h">
    <thead>
      <tr>
        <th scope="col">الأسبوع</th>
        <th scope="col" rst-num>المُباع</th>
        <th scope="col" rst-num>الهدف</th>
        <th scope="col" rst-num>المبالغ المستردة</th>
      </tr>
    </thead>
    <tbody>
      <tr rst-table-empty>
        <td colspan="4">لا توجد أسابيع مطابقة.</td>
      </tr>
    </tbody>
  </table>
</div>
{{template "data-table" dict
    "Columns" (list
        (dict "Label" "الأسبوع")
        (dict "Label" "المُباع" "Num" true)
        (dict "Label" "الهدف" "Num" true)
        (dict "Label" "المبالغ المستردة" "Num" true))
    "Empty" "لا توجد أسابيع مطابقة."
    "ID" "sales-none"
    "Title" "المبيعات حسب الأسبوع"}}

عند غياب الصفوف تبقى الترويسة ويقول Empty السبب.

chart-bar

مخطط أشرطة مرسوم كجدول: اسم وشريط وقيمة في كل صف. يجب أن تكون القيم صفرًا أو أكثر.

أربعة مصادر على مقياس واحد

معاينة
<div rst-box-head>
  <h2 id="sources-h">التذاكر حسب المصدر</h2>
</div>
<div rst-card>
  <figure rst-chart aria-labelledby="sources-h" aria-describedby="sources-d">
    <p rst-chart-desc id="sources-d">بيعت معظم التذاكر عبر الإنترنت، ولم تُبع أي تذكرة عبر النشرة البريدية بعد.</p>
    <div rst-table-scroll tabindex="0" role="region" aria-labelledby="sources-h">
      <table rst-table="bars" aria-labelledby="sources-h" aria-describedby="sources-d">
        <thead>
          <tr>
            <th scope="col">المصدر</th>
            <th scope="col">
              <span class="rst-sr-only">الشريط</span>
            </th>
            <th scope="col" rst-num>التذاكر</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th scope="row">عبر الإنترنت</th>
            <td rst-table-bar>
              <svg viewBox="0 0 1000 1" preserveAspectRatio="none" aria-hidden="true" focusable="false"><rect width="1000" height="1"/></svg>
            </td>
            <td rst-num>412</td>
          </tr>
          <tr>
            <th scope="row">شباك التذاكر</th>
            <td rst-table-bar>
              <svg viewBox="0 0 1000 1" preserveAspectRatio="none" aria-hidden="true" focusable="false"><rect width="572.8" height="1"/></svg>
            </td>
            <td rst-num>236</td>
          </tr>
          <tr>
            <th scope="row">الشركاء</th>
            <td rst-table-bar>
              <svg viewBox="0 0 1000 1" preserveAspectRatio="none" aria-hidden="true" focusable="false"><rect width="237.9" height="1"/></svg>
            </td>
            <td rst-num>98</td>
          </tr>
          <tr>
            <th scope="row">النشرة البريدية</th>
            <td rst-table-bar>
              <svg viewBox="0 0 1000 1" preserveAspectRatio="none" aria-hidden="true" focusable="false"><rect width="0" height="1"/></svg>
            </td>
            <td rst-num>0</td>
          </tr>
        </tbody>
      </table>
    </div>
  </figure>
</div>
{{template "chart-bar" dict
    "Category" "المصدر"
    "Desc" "بيعت معظم التذاكر عبر الإنترنت، ولم تُبع أي تذكرة عبر النشرة البريدية بعد."
    "ID" "sources"
    "Measure" "التذاكر"
    "Points" (list
        (dict "Label" "عبر الإنترنت" "Value" 412)
        (dict "Label" "شباك التذاكر" "Value" 236)
        (dict "Label" "الشركاء" "Value" 98)
        (dict "Label" "النشرة البريدية" "Value" 0))
    "Title" "التذاكر حسب المصدر"}}

تتشارك كل الأشرطة مقياسًا واحدًا. لمقارنة مخططين، أعطِ كليهما قيمة Max نفسها.

لم يُبَع شيء بعد

معاينة
<div rst-box-head>
  <h2 id="sources-none-h">التذاكر حسب المصدر</h2>
</div>
<div rst-card>
  <figure rst-chart aria-labelledby="sources-none-h">
    <p rst-chart-empty>لم تُبع أي تذكرة بعد.</p>
  </figure>
</div>
{{template "chart-bar" dict
    "Category" "المصدر"
    "Empty" "لم تُبع أي تذكرة بعد."
    "ID" "sources-none"
    "Measure" "التذاكر"
    "Title" "التذاكر حسب المصدر"}}

عند غياب النقاط، يحلّ Empty محلّ المخطط.

chart-line

سلسلة واحدة على شكل خط فوق نقاط متباعدة بالتساوي، مع كل قيمة في جدول أسفله.

المبيعات الأسبوعية مقابل هدف

معاينة
<div rst-box-head>
  <h2 id="weekly-h">المبيعات الأسبوعية</h2>
</div>
<div rst-card>
  <figure rst-chart aria-labelledby="weekly-h" aria-describedby="weekly-d">
    <p rst-chart-desc id="weekly-d">ارتفعت المبيعات كل أسبوع تقريبًا وتجاوزت الهدف البالغ 600 في الأسبوع 6.</p>
    <div rst-chart-plot aria-hidden="true">
      <div rst-chart-y>
        <span>800</span><span>600</span><span>400</span><span>200</span><span>0</span>
      </div>
      <svg viewBox="0 0 1000 1000" preserveAspectRatio="none" focusable="false"><path rst-chart-grid d="M0 0H1000M0 250H1000M0 500H1000M0 750H1000"/><path rst-chart-base d="M0 1000H1000"/><path rst-chart-goal d="M0 250H1000"/><polyline rst-chart-line points="0,850 142.9,775 285.7,675 428.6,700 571.4,512.5 714.3,237.5 857.1,187.5 1000,137.5"/><path rst-chart-ring d="M1000 137.5h0"/><path rst-chart-dot d="M1000 137.5h0"/></svg>
      <div rst-chart-hits>
        <span title="1: 120"></span><span title="2: 180"></span><span title="3: 260"></span><span title="4: 240"></span><span title="5: 390"></span><span title="6: 610"></span><span title="7: 650"></span><span title="8: 690"></span>
      </div>
      <div rst-chart-x>
        <span rst-chart-keep>1</span><span>2</span><span rst-chart-keep>3</span><span>4</span><span rst-chart-keep>5</span><span>6</span><span>7</span><span rst-chart-keep>8</span>
      </div>
    </div>
    <p rst-chart-key>الهدف: 600</p>
    <details rst-chart-data>
      <summary>عرض الأرقام</summary>
      <div rst-table-scroll tabindex="0" role="region" aria-labelledby="weekly-h">
        <table rst-table="dense" aria-labelledby="weekly-h">
          <thead>
            <tr>
              <th scope="col">الأسبوع</th>
              <th scope="col" rst-num>المُباع</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <th scope="row">1</th>
              <td rst-num>120</td>
            </tr>
            <tr>
              <th scope="row">2</th>
              <td rst-num>180</td>
            </tr>
            <tr>
              <th scope="row">3</th>
              <td rst-num>260</td>
            </tr>
            <tr>
              <th scope="row">4</th>
              <td rst-num>240</td>
            </tr>
            <tr>
              <th scope="row">5</th>
              <td rst-num>390</td>
            </tr>
            <tr>
              <th scope="row">6</th>
              <td rst-num>610</td>
            </tr>
            <tr>
              <th scope="row">7</th>
              <td rst-num>650</td>
            </tr>
            <tr>
              <th scope="row">8</th>
              <td rst-num>690</td>
            </tr>
          </tbody>
          <tfoot>
            <tr>
              <th scope="row">الهدف</th>
              <td rst-num>600</td>
            </tr>
          </tfoot>
        </table>
      </div>
    </details>
  </figure>
</div>
{{template "chart-line" dict
    "Category" "الأسبوع"
    "Desc" "ارتفعت المبيعات كل أسبوع تقريبًا وتجاوزت الهدف البالغ 600 في الأسبوع 6."
    "Goal" 600
    "GoalLabel" "الهدف"
    "Hover" true
    "ID" "weekly"
    "Measure" "المُباع"
    "Points" (list
        (dict "Label" 1 "Value" 120)
        (dict "Label" 2 "Value" 180)
        (dict "Label" 3 "Value" 260)
        (dict "Label" 4 "Value" 240)
        (dict "Label" 5 "Value" 390)
        (dict "Label" 6 "Value" 610)
        (dict "Label" 7 "Value" 650)
        (dict "Label" 8 "Value" 690))
    "Title" "المبيعات الأسبوعية"}}

اكتب Desc بنفسك. قل ماذا يفعل الخط، لا أين ينتهي فقط. اضبط Hover لإضافة تلميح إلى كل نقطة.

أسبوع بلا بيانات

معاينة
<div rst-box-head>
  <h2 id="weekly-gap-h">المبيعات الأسبوعية</h2>
</div>
<div rst-card>
  <figure rst-chart aria-labelledby="weekly-gap-h" aria-describedby="weekly-gap-d">
    <p rst-chart-desc id="weekly-gap-d">لم تُسجَّل أي مبيعات في الأسبوع 5؛ لذلك ينقطع الخط هناك.</p>
    <div rst-chart-plot aria-hidden="true">
      <div rst-chart-y>
        <span>800</span><span>600</span><span>400</span><span>200</span><span>0</span>
      </div>
      <svg viewBox="0 0 1000 1000" preserveAspectRatio="none" focusable="false"><path rst-chart-grid d="M0 0H1000M0 250H1000M0 500H1000M0 750H1000"/><path rst-chart-base d="M0 1000H1000"/><path rst-chart-goal d="M0 250H1000"/><polyline rst-chart-line points="0,850 142.9,775 285.7,675 428.6,700"/><polyline rst-chart-line points="714.3,237.5 857.1,187.5 1000,137.5"/><path rst-chart-ring d="M1000 137.5h0"/><path rst-chart-dot d="M1000 137.5h0"/></svg>
      <div rst-chart-x>
        <span rst-chart-keep>1</span><span>2</span><span rst-chart-keep>3</span><span>4</span><span rst-chart-keep>5</span><span>6</span><span>7</span><span rst-chart-keep>8</span>
      </div>
    </div>
    <p rst-chart-key>الهدف: 600</p>
    <details rst-chart-data>
      <summary>عرض الأرقام</summary>
      <div rst-table-scroll tabindex="0" role="region" aria-labelledby="weekly-gap-h">
        <table rst-table="dense" aria-labelledby="weekly-gap-h">
          <thead>
            <tr>
              <th scope="col">الأسبوع</th>
              <th scope="col" rst-num>المُباع</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <th scope="row">1</th>
              <td rst-num>120</td>
            </tr>
            <tr>
              <th scope="row">2</th>
              <td rst-num>180</td>
            </tr>
            <tr>
              <th scope="row">3</th>
              <td rst-num>260</td>
            </tr>
            <tr>
              <th scope="row">4</th>
              <td rst-num>240</td>
            </tr>
            <tr>
              <th scope="row">5</th>
              <td rst-num>لا توجد بيانات</td>
            </tr>
            <tr>
              <th scope="row">6</th>
              <td rst-num>610</td>
            </tr>
            <tr>
              <th scope="row">7</th>
              <td rst-num>650</td>
            </tr>
            <tr>
              <th scope="row">8</th>
              <td rst-num>690</td>
            </tr>
          </tbody>
          <tfoot>
            <tr>
              <th scope="row">الهدف</th>
              <td rst-num>600</td>
            </tr>
          </tfoot>
        </table>
      </div>
    </details>
  </figure>
</div>
{{template "chart-line" dict
    "Category" "الأسبوع"
    "Desc" "لم تُسجَّل أي مبيعات في الأسبوع 5؛ لذلك ينقطع الخط هناك."
    "Goal" 600
    "GoalLabel" "الهدف"
    "Hover" false
    "ID" "weekly-gap"
    "Measure" "المُباع"
    "Points" (list
        (dict "Label" 1 "Value" 120)
        (dict "Label" 2 "Value" 180)
        (dict "Label" 3 "Value" 260)
        (dict "Label" 4 "Value" 240)
        (dict "Label" 5 "Missing" true "Value" 390)
        (dict "Label" 6 "Value" 610)
        (dict "Label" 7 "Value" 650)
        (dict "Label" 8 "Value" 690))
    "Title" "المبيعات الأسبوعية"}}

القيمة المفقودة تقطع الخط وتظهر في الجدول بعبارة «لا توجد بيانات». ولا تُرسم أبدًا على أنها 0.

sparkline

خط صغير بجانب تعليقه، لإظهار اتجاه بجوار رقم.

صاعد، مع تراجع

معاينة
<figure rst-spark>
  <svg viewBox="0 0 100 24" preserveAspectRatio="none" aria-hidden="true" focusable="false"><polyline rst-chart-line points="0,24 14.3,21.5 28.6,18.1 42.9,18.9 57.1,12.6 71.4,3.4 85.7,1.7 100,0"/><path rst-chart-ring d="M100 0h0"/><path rst-chart-dot d="M100 0h0"/></svg>
  <figcaption>
    <strong>آخر 8 أسابيع</strong> ارتفعت المبيعات من 120 إلى 690، مع تراجع في الأسبوع 4.</figcaption>
</figure>
{{template "sparkline" dict
    "Desc" "ارتفعت المبيعات من 120 إلى 690، مع تراجع في الأسبوع 4."
    "Period" "آخر 8 أسابيع"
    "Points" (list
        (dict "Label" 1 "Value" 120)
        (dict "Label" 2 "Value" 180)
        (dict "Label" 3 "Value" 260)
        (dict "Label" 4 "Value" 240)
        (dict "Label" 5 "Value" 390)
        (dict "Label" 6 "Value" 610)
        (dict "Label" 7 "Value" 650)
        (dict "Label" 8 "Value" 690))}}

التعليق هو كل ما يصل إلى قارئ الشاشة. اذكر الفترة، وصِف أي تراجع أو قفزة.