Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the statistical target has only one piece of data, continuous_time doesn't work #43

Closed
shirakun opened this issue Jul 15, 2020 · 3 comments

Comments

@shirakun
Copy link

I try to count the number of users in 30 days by day
But I found a problem
When there is only one user in 30 days, continuous_time doesn't work
When I add another user to the database with a different created_at, continuous_time works

php code

namespace App\Http\Controllers\Manager;

use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Http\Request;
use LaravelDaily\LaravelCharts\Classes\LaravelChart;

class StatisticsController extends Controller
{
    public function index(Request $request)
    {

        $user_register_count = [
            'all' => User::count(),
            '30'  => User::where([['created_at', '>=', date('Y-m-d H:i:s', time() - 2592000)]])->count(),
            '7'   => User::where([['created_at', '>=', date('Y-m-d H:i:s', time() - 604800)]])->count(),
            '1'   => User::where([['created_at', '>=', date('Y-m-d H:i:s', time() - 86400)]])->count(),
        ];

        $chart_options = [
            'chart_title'     => 'user register for month',
            'report_type'     => 'group_by_date',
            'model'           => User::class,
            'group_by_field'  => 'created_at',
            'group_by_period' => 'day',
            'chart_type'      => 'line',
            'filter_days'     => 30,
            'continuous_time' => true,
        ];
        $user_chart = new LaravelChart($chart_options);
        return view('manager.statistics.index', [
            'user_chart'          => $user_chart,
            'user_register_count' => $user_register_count,
        ]);

    }
}

html code

                <div class="chart">
                    {!! $user_chart->renderHtml() !!}
                </div>
    {!! $user_chart->renderChartJsLibrary() !!}
    {!! $user_chart->renderJs() !!}

image

@PovilasKorop
Copy link
Collaborator

@shirakun hi, thanks for the reporting. Currently we don't have free time to spend on this package, will have only in a few weeks. Meanwhile maybe you can propose the solution to this and make a Pull Request?

@shirakun
Copy link
Author

@shirakun hi, thanks for the reporting. Currently we don't have free time to spend on this package, will have only in a few weeks. Meanwhile maybe you can propose the solution to this and make a Pull Request?

Hi
When I have time, I check it and try to fix it.

@PovilasKorop
Copy link
Collaborator

Fixed in PR #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants