Skip to content

Chart displays only partial data despite having records in database #231

@ParhamTehrani

Description

@ParhamTehrani

Description

When viewing charts with Weekly granularity, only a small number of records are displayed even though there are hundreds of records in the database.

Root Cause

The bounds check in DataBuckets::addRow() at line 209 is incorrect:

if ($offset <= $this->points) {

This condition has two problems:

  1. It allows negative offsets (which should be rejected)
  2. It uses <= instead of <, which can cause out-of-bounds access

Solution

Change the bounds check to:

if ($offset >= 0 && $offset < $this->points) {

Affected File

src/Helpers/DataBuckets.php line 209

Steps to Reproduce

  1. Have a site with hundreds of pageview records in the database
  2. Go to SlimStat dashboard
  3. Select Weekly granularity for the chart
  4. Observe that only a few records are displayed

Expected Behavior

All records within the selected date range should be displayed in the chart.

Actual Behavior

Only a small subset of records is displayed (e.g., 3 instead of hundreds).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions