Forums › Forums › OroCRM › OroCRM – How do I? Questions › multiline chart in dashboard
This topic contains 6 replies, has 2 voices, and was last updated by fred33 8 years, 1 month ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- March 14, 2016 at 12:56 am #28836
Hi,
how can i create a multiline chart in dashboard, or where i can find documentation ?Thanks
- CreatorTopic
- AuthorReplies
- March 14, 2016 at 3:26 am #28837
Hello.
Here is example of configuration, controller and data provider.
As for documentation – you can check bundle documentation and configuration format reference.
March 16, 2016 at 1:39 am #28838Hi,
I read the documentation for the dashboard and I understood the march followed by against using graphics really remains very obscure for me. I need a graph with two lines representing the monthly sales for each employee , so connecting a database ….March 16, 2016 at 8:37 am #28839You should look at the example – e.g. you can debug this widget with real (or demo) data and check what data and format are used there.
March 23, 2016 at 4:00 am #28840I come to you for this problem of multiline chart . In fact I can not have much and I think the management of chart is really not an easy thing in orocrm.
this is not a criticism it’s just that the level of knowledge must be high enough to understand all the mechanismsMarch 23, 2016 at 8:22 am #28841Ok, let’s have a closer look at the dashboard multiline widget data. I’ve used a widget from the links before (New Web Customers), and here is what my results are:
1) General widget configuration can be generated automatically based on YAML config using this code (new_magento_customers_chart is a name of a widget):
PHP1$data = $widgetAttributes->getWidgetAttributesForTwig('new_magento_customers_chart');And here is real data generated by this method:
Shell1234567891011121314151617181920212223242526272829303132333435363738394041array ('widgetName' => 'new_magento_customers_chart','widgetLabel' => 'orocrm.magento.dashboard.new_magento_customers_chart.title','widgetDescription' => 'orocrm.magento.dashboard.new_magento_customers_chart.description','widgetIcon' => 'bundles/orocrmmagento/img/number-magento-customers.png','widgetApplicable' => '@orocrm_magento.provider.enitity_state->isEntityCustomerEnabled()','widgetConfiguration' =>array ('title' =>array ('type' => 'oro_type_widget_title','options' =>array ('label' => 'oro.dashboard.title.label','required' => false,),'show_on_widget' => false,'converter_attributes' =>array (),'value' => 'orocrm.magento.dashboard.new_magento_customers_chart.title',),'dateRange' =>array ('type' => 'oro_type_widget_date_range','options' =>array ('label' => 'oro.dashboard.date_range.label',),'show_on_widget' => true,'converter_attributes' =>array (),'value' => 'more than Jan 1, 2015',),),'widgetEnabled' => true,'widgetDataItems' =>array (),)2) Chart view consists of two parts – chart options and chart data, here is how they should be used:
Shell1234$data['chartView'] = $chartViewBuilder->setOptions($chartOptions)->setArrayData($items)->getView()Not let’s look at these two parts.
2.1) Chart options define type of a widget and additional parameters required to build this chard (axis, labels etc.) – almost all of these options can be extracted from config too:
Shell12345678910111213141516171819202122232425262728293031323334353637383940414243array ('name' => 'multiline_chart','label' => 'oro.chart.multiline_chart.label','data_schema' =>array ('label' =>array ('name' => 'label','label' => 'oro.dashboard.chart.month.label','required' => true,'default_type' => 'string','type' => 'month','field_name' => 'date','type_filter' =>array (),),'value' =>array ('name' => 'value','label' => 'orocrm.magento.dashboard.new_magento_customers_chart.customer_count','required' => true,'default_type' => 'integer','field_name' => 'cnt','type_filter' =>array (),),),'xaxis' =>array ('mode' => 'time','noTicks' => 12,),'template' => 'OroChartsBundle:Chart:multiline.html.twig','settings_schema' =>array (),default_settings' =>array (),)'2.2) Chart data is basically a data used to render this chart:
Shell123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155array ('mag1' =>array (0 =>array ('date' => '2015-01-01','cnt' => 13,),1 =>array ('date' => '2015-02-01','cnt' => 2,),2 =>array ('date' => '2015-03-01','cnt' => 6,),3 =>array ('date' => '2015-04-01','cnt' => 2,),4 =>array ('date' => '2015-05-01','cnt' => 5,),5 =>array ('date' => '2015-06-01','cnt' => 5,),6 =>array ('date' => '2015-07-01','cnt' => 1,),7 =>array ('date' => '2015-08-01','cnt' => 5,),8 =>array ('date' => '2015-09-01','cnt' => 5,),9 =>array ('date' => '2015-10-01','cnt' => 1,),10 =>array ('date' => '2015-11-01','cnt' => 3,),11 =>array ('date' => '2015-12-01',),12 =>array ('date' => '2016-01-01','cnt' => 1,),13 =>array ('date' => '2016-02-01',),14 =>array ('date' => '2016-03-01','cnt' => 11,),),'mag2' =>array (0 =>array ('date' => '2015-01-01','cnt' => 4,),1 =>array ('date' => '2015-02-01','cnt' => 2,),2 =>array ('date' => '2015-03-01','cnt' => 40,),3 =>array ('date' => '2015-04-01','cnt' => 63,),4 =>array ('date' => '2015-05-01','cnt' => 4,),5 =>array ('date' => '2015-06-01','cnt' => 2,),6 =>array ('date' => '2015-07-01','cnt' => 1,),7 =>array ('date' => '2015-08-01','cnt' => 9,),8 =>array ('date' => '2015-09-01','cnt' => 3,),9 =>array ('date' => '2015-10-01','cnt' => 3,),10 =>array ('date' => '2015-11-01','cnt' => 1,),11 =>array ('date' => '2015-12-01',),12 =>array ('date' => '2016-01-01','cnt' => 1,),13 =>array ('date' => '2016-02-01','cnt' => 3,),14 =>array ('date' => '2016-03-01','cnt' => 2,),),)And as a result we can see dashboard widget with required information rendered as two lines:
In general – if you feel that you can improve documentation for dashboard widget – we will be happy to accept your pull request to platform or documentation repository.
March 23, 2016 at 11:57 pm #28842in no way my knowledge about orocrm are too poor to bring my contribution I am trying to understand the philosophy of orocrm and apply it . I think I understand the operation of the chart it’s just in construction that I have trouble , controller, dataprovider , twig …
- AuthorReplies
The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.