Forums › Forums › OroCRM › OroCRM – Programming Questions › Report line chart error
This topic contains 13 replies, has 2 voices, and was last updated by Mike Kudelya 7 years, 7 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- August 22, 2016 at 2:47 am #25263
I have create my entity with some column and join column.
When I create segment, it’s ok.
When I create report, result in table grid is correctly, but line chart fail
This is image:
In chart, my label and value are column not join column. My label is “doc_date” and my value is “amount”. I was group by doc_date.
What problem here?
P/s: When I change chart_options in database, field “name”:”bar_chart” replace “name”:”line_chart”. The chart show 2 column, but not have label of vertical and horizontal, and not have date (horizontal) - CreatorTopic
- AuthorReplies
- August 23, 2016 at 7:15 pm #25264
Another issue same that issue.
When I create report for Magento Shipping Cart (with sample data) include:
– Column: created_at and amount(SUM)
– Group by: created_at
– Line chart: X-created_at and Y-amount
– No filter
==> It’s work fine, except chart (problem with line X)But when I add filter for created_at column, the chart are as same as photo above.
What problem here?
August 29, 2016 at 9:54 am #25265Hi,
It seems all the values have the same date value. I have updated created_at on one value and got photo above.
August 29, 2016 at 11:11 pm #25266But in table report, it’s have 2 different date.
And as same as in sample dataAugust 30, 2016 at 7:26 am #25267Probably this is the bug. If you try to add 3-5 different dates, problem will dissapear, right?
August 30, 2016 at 10:25 pm #25268Yes, it is.
But why, with magento shopping cart (sample data). When I create report with 1 day => no show chart, with 2 days => chart is ok. What different?
(Same in group by and filter, group by date, and sum amount)September 1, 2016 at 2:59 am #25269Hi,
I have created task for the issue, thanks! As temporary solution you can replace this piece of code to:
PHP1234567891011121314151617if ($diff->days >= self::YEAR_TYPE_DAYS) {$intervalString = 'P1Y';$valueStringFormat = 'Y';$viewType = 'year';} elseif ($diff->days > self::MONTH_TYPE_DAYS) {$intervalString = 'P1M';$valueStringFormat = 'Y-m';$viewType = 'month';} elseif ($diff->days > self::WEEK_TYPE_DAYS) {$intervalString = 'P1W';$valueStringFormat = 'Y-W';$viewType = 'date';} else {$intervalString = 'P1D';$valueStringFormat = 'Y-m-d';$viewType = 'day';}September 1, 2016 at 6:06 pm #25270Thanks for answer :)
I have 1 more question. I was created and used javascript, follow document in orocrm.com
That’s my code:
1. In direct mybundle/resources/public/js:
– File Chart.min.js
– In direct ../app/components, I have file test-chart.js with code1234567891011121314151617181920212223242526272829303132333435363738394041424344454647define(function (require) {'use strict';console.log(1);require('chart-js');return function (data) {console.log(1);const CHART = document.getElementById('chart');var chart = new Chart(CHART, {type: 'bar',data: {labels: data.label,datasets: [{label: '# of Votes',data: data.dataSet,backgroundColor: ['rgba(255, 99, 132, 0.2)','rgba(54, 162, 235, 0.2)','rgba(255, 206, 86, 0.2)','rgba(75, 192, 192, 0.2)','rgba(153, 102, 255, 0.2)','rgba(255, 159, 64, 0.2)'],borderColor: ['rgba(255,99,132,1)','rgba(54, 162, 235, 1)','rgba(255, 206, 86, 1)','rgba(75, 192, 192, 1)','rgba(153, 102, 255, 1)','rgba(255, 159, 64, 1)'],borderWidth: 1}]},options: {scales: {yAxes: [{ticks: {beginAtZero:true}}]}}});}});2. In requirejs.yml:
1234config:paths:'chart-js': 'bundles/tnamychart/js/Chart.min.js''tnamychart/js/app/components/test-chart': 'bundles/tnamychart/js/app/components/test-chart.js'3. In template file:
12345678910{% set data = {'label': label,'dataSet': dataSet} %}<div style="width: 400px"data-page-component-module="tnamychart/js/app/components/test-chart"data-page-component-options="{{ data|json_encode }}"><canvas id="chart" width="400" height="400"></canvas></div>But why, when I call template, it’s not call this js. I already try
1234{% set data = {label: label,dataSet: dataSet} %}What wrong here?
September 5, 2016 at 8:13 am #25271Hi,
I have just created a similar component and it works.
Did you run these commands
Shell12app/console oro:assets:install --env=dev --symlinkapp/console oro:requirejs:build --env=dev?
September 5, 2016 at 11:11 pm #25272Yes, I was run these commands. All file in folder Resource/public was updated in web/bundles/…
But it’s not workingSeptember 8, 2016 at 3:24 am #25273Hi,
I have created src/Custom/Bundle/OroBundle/Resources/public/js/app/components/test.js:
JavaScript1234567define(function (require) {'use strict';return function (data) {console.log(1);}});src/Custom/Bundle/OroBundle/Resources/config/requirejs.yml:
YAML123config:paths:'customoro/js/app/components/test': 'bundles/customoro/js/app/components/test.js'and write this code after ‘{% block content_data %}’ in vendor/oro/crm/src/OroCRM/Bundle/SalesBundle/Resources/views/Lead/view.html.twig:
XHTML1234567{% set data = {} %}<div style="width: 400px"data-page-component-module="customoro/js/app/components/test"data-page-component-options="{{ data|json_encode }}"><canvas id="chart" width="400" height="400"></canvas></div>It works! Are you sure that your template is rendering ? Put your <div> in existed code, for example lead view page. will be work or not?
September 9, 2016 at 9:08 am #25274My template already show (when I check inspect, in my template have <div> and <canvas> tag).
But it’s not work :(September 13, 2016 at 11:12 pm #25275Update!
I was used this js for different template, then it’s work fine …
The different between 2 template is:
– Template non working:
+ No extend exist template
+ Data return from controller12345return array('label' => ['mon', 'tue'],'dataSet' => [25,40],'dataSet2' => [27, 36]);– Template working:
+ Extend action update.html.twig, I call js in 1 block
+ Data return from controller123// All variables is arrayreturn array_merge($arr, array('label' => $label, 'dataSet' => $dataSet,'dataSet2' => $dataSet2, 'mb' => $mb, 'mn' => $mn));So, what happened there?
September 20, 2016 at 4:21 am #25276Hi,
You have two ways to resolve this problem:
first: using standard templates (with oro header, buttons, etc..), like lead view and extend it from OroUIBundle:actions:view.html.twig
second: use empty page, initialize ComponentManager and run your component.Here is an example of second variant:
XHTML123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475<html><head>{% block head %}<title>{% trans %}Loading...{% endtrans %}</title><script id="page-title" type="text/html">{{ oro_title_render() }}</script><meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=no"/><meta http-equiv="cache-control" content="max-age=0" /><meta http-equiv="cache-control" content="no-cache" /><meta http-equiv="expires" content="0" /><meta http-equiv="pragma" content="no-cache" />{% block head_style %}{% if oro_theme_icon() %}<link rel="shortcut icon" href="{{ asset(oro_theme_icon()) }}" />{% endif %}{% placeholder head_style %}{% endblock %}{% block script %}{% block scripts_before %}{% placeholder scripts_before %}{% endblock %}{% set requirejs_config_extend %}{%- placeholder requirejs_config_extend -%}{% endset %}{% include 'OroRequireJSBundle::scripts.html.twig' with {compressed: not app.debug,config_extend: requirejs_config_extend} %}{% block application %}<script type="text/javascript">require(['oroui/js/app']);</script>{% endblock %}<script type="text/javascript">require(['oroui/js/init-layout', 'orouser/js/init-user', 'oroui/js/widget-manager']);{% if isMobileVersion() %}require(['oroui/js/mobile/layout'], function (layout) {layout.init();});{% endif %}{% if app.debug %}require(['oroui/js/tools'], function (tools) {tools.debug = true;});{% endif %}</script>{% placeholder scripts_after %}{% block head_script %}{% endblock %}{% endblock %}{% endblock %}</head><body>{% block pageHeader %}{% set breadcrumbs = {} %}{% endblock pageHeader %}{% block content_data %}<script type="text/javascript">require(['oroui/js/app/components/component-manager'],function (ComponentManager) {var cm = new ComponentManager($('#my-root-element'));cm.init();});</script>{% set data = {} %}<div id="my-root-element"><div style="width: 4px"data-page-component-module="customoro/js/app/components/test"data-page-component-options="{{ data|json_encode }}"><canvas id="chart" width="4" height="4"></canvas></div></div>{% endblock content_data %}</body></html> - AuthorReplies
The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.