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

Multiple dataset from same Model but grouped by a foreign key #117

Open
CarterSnich opened this issue Nov 27, 2023 · 1 comment
Open

Multiple dataset from same Model but grouped by a foreign key #117

CarterSnich opened this issue Nov 27, 2023 · 1 comment

Comments

@CarterSnich
Copy link

So, I have a Student model that has section_id column. I was able to create a line graph that shows number of enrollments every year. Now, I want to make multiple lines for each section_id. How can I achieve this? Also, how can I make the Y numbers as whole numbers and ranges only to available data. Example, the max data is 10 and min is 3, the Y numbers should only show range from 3 to 10.
image

Controller

 $apple = [
        'chart_title' => 'Apple',
        'report_type' => 'group_by_date',
        'model' => 'App\Models\Student',
        'group_by_field' => 'created_at',
        'group_by_period' => 'year',
        'chart_type' => 'line',

    ];
    $orange = [
        'chart_title' => 'Orange',
        'report_type' => 'group_by_date',
        'model' => 'App\Models\Student',
        'group_by_field' => 'created_at',
        'group_by_period' => 'year',
        'chart_type' => 'line',
    ];
   $mango = [...];

    $chart = new LaravelChart($apple, $orange, $mango);

Model

class Student extends Model
{
    use HasFactory;

    protected $fillable = [
        'student_id',
        'firstname',
        'lastname',
        'middlename',
        'birthdate',
        'section_id' // foreign key
    ];
}
@CarterSnich
Copy link
Author

I'm sorry that this just become a more of a help instead of a bug report.

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

1 participant