nova-chartjs
nova-chartjs copied to clipboard
how to disable autorefresh?
click any resource. "NovaServiceProvider" return "Cards", and nova-chartsjs will draw again, it waste time too much
Hi, @niunaiyi . Can you please add more detail what happened and your request? Also it will be much help if you can share image or screenrecord(video) about it.
https://coroo.github.io/nova-chartjs/assets/img/code-chart-bar.png
I get data from DB for series function.
NovaServiceProvider will return Cards several times when i click any Resource,
then nova-chartjs will get data from DB several times. its not necessary。
sorry for my English.
https://github.com/insenseanalytics/nova-bar-metrics this project use "Partition" and his calcualte function to avoid. sorry for my English again.
could u give me some help?
Hi @niunaiyi , sorry for late response. So what I understand is, you use custom bar-chart https://coroo.github.io/nova-chartjs/#/?id=bar-chart. But unfortunately, the nova-chartjs still call data from db, am I right?
looks like this:
class NovaServiceProvider extends NovaApplicationServiceProvider {
/**
* Get the cards that should be displayed on the default Nova dashboard.
*
* @return array
*/
protected function cards()
{
\Log::info('return cards');
$data = getDataFromDB();
$style = ...;
$options = ...;
return [
(new LineChart())
->title('title')
->series($data, $style)
->options($options)
->width('full'),
];
}
}
when i click any menu, NovaServiceProvider will return Cards serval times, then getDataFromDB will be called serval times.
[2020-10-02 22:56:07] local.INFO: return cards
[2020-10-02 22:56:07] local.INFO: return cards
[2020-10-02 22:56:08] local.INFO: return cards
[2020-10-02 22:56:08] local.INFO: return cards
[2020-10-02 22:56:08] local.INFO: return cards
[2020-10-02 22:56:08] local.INFO: return cards
Atfer I see the documentation at laravel nova. There is an issue about that: in here, which is still in development stage in laravel nova. The best answer for now is, you can use hotfix from ibrunotome:
protected function cards()
{
if (request()->is('nova-api/dashboards*')) { // your dashboard url
\Log::info('return cards');
$data = getDataFromDB();
$style = ...;
$options = ...;
return [
(new LineChart())
->title('title')
->series($data, $style)
->options($options)
->width('full'),
];
}
}
hope this help you
wow,thanks very much.