Closed Overx closed 4 years ago
See in readme:
'conditions' => [
['name' => 'Food', 'condition' => 'category_id = 1', 'color' => 'black'],
['name' => 'Transport', 'condition' => 'category_id = 2', 'color' => 'blue'],
],
Are fields such as name and color required?
@Overx no, optional
$chart_options = [
'chart_title' => 'Clientes por mês',
'report_type' => 'group_by_date',
'model' => 'App\Models\User',
'conditions' => [
['name' => 'Clientes', 'condition' => 'user_id = ' . auth()->user()->id, 'color' => 'black']
],
'group_by_field' => 'created_at',
'group_by_period' => 'month',
'group_by_field_format' => 'd-m-Y',
'chart_type' => 'bar',
];
$chart1 = new LaravelChart($chart_options);
Not working for me
@Overx what is the error you're getting?
what is the error you're getting?
It does not present any error, just does not have the expected effect, I would like it to show the record of this user, and are showing all the records, it is not filtering with the condition where user_id
@Overx oh now I understood why it's not working, it works only with line
chart, with purpose of having multiple lines on the same chart. With bar
chart you're using, it won't work. Sorry, for bar
we don't have where condition logic. But again, we are happy to accept a Pull Request if you build it.
@PovilasKorop Thank you for this packge, looking at this issue is it possible to filter the data which get analyzed.
For example, a Business
has many Sales
, can you be able to narrow down to specific business sales
'model' => Sales::where('business_id', 12)
@gathuku yes, it should be possible with where_raw
parameter, look at readme or in the source how it works.
@PovilasKorop where_raw
worked fine. I have another issue where the chart isn't rendered dynamically with a livewire component. What am trying to achieve is I have a dropdown which populated the filter_days
, on change should render a new chart depending on the selected value. My guess is that the javascript to render the chart isn't triggered.
@gathuku no idea, we haven't tried the package with Livewire component
How do I use conditions like where in the model? Thx