asantibanez / livewire-charts

Neat Livewire Charts for your Laravel projects
MIT License
787 stars 116 forks source link

multiline chart mode am i using it correctly? #123

Open ndarproj opened 4 months ago

ndarproj commented 4 months ago
$multiLineChartModel = $aggregatedData->reduce(
                function ($chartModel, $data) {
                    // Assuming $data->date_interval is your column category (x-axis)
                    $chartModel->addSeriesPoint('Notified Users', $data->date_interval, $data->total_sent);
                    $chartModel->addSeriesPoint('Opted-Out Users', $data->date_interval, $data->total_not_sent);
                    $chartModel->addSeriesPoint('Clicks', $data->date_interval, $data->total_open_count);

                    return $chartModel;
                },
                LivewireCharts::multiLineChartModel()
                    ->setTitle('Notification Stats')
                    ->setAnimated(true)
                    ->setDataLabelsEnabled(true)
                    ->withOnPointClickEvent('onPointClick')
                    ->setSmoothCurve()
                    ->multiLine()
                    ->setColors(['#15803d', '#b91c1c', '#1d4ed8']) // Set your colors accordingly
            );

image

i don't understand as to why the line is off. jan'24 blue line should have been in 5 but instead it is in 20, same as the red line..

sinarahmany commented 3 weeks ago

It looks like your issue might be related to the data points not aligning correctly with your x-axis labels. Ensure that the $data->date_interval values are consistent and correctly formatted. Additionally, verify that the addSeriesPoint method is receiving the expected data.