{"id":3575,"date":"2024-02-24T19:06:42","date_gmt":"2024-02-24T18:06:42","guid":{"rendered":"https:\/\/fhumanes.es\/blog\/?p=3575"},"modified":"2024-02-24T19:06:42","modified_gmt":"2024-02-24T18:06:42","slug":"utilizacion-del-plugin-anychart-actualizacion","status":"publish","type":"post","link":"https:\/\/fhumanes.es\/blog\/utilizacion-del-plugin-anychart-actualizacion\/","title":{"rendered":"Utilizaci\u00f3n del Plugin AnyChart Actualizaci\u00f3n"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-599 alignleft\" src=\"https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2019\/07\/anychart_0-300x75.png\" alt=\"\" width=\"300\" height=\"75\" srcset=\"https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2019\/07\/anychart_0-300x75.png 300w, https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2019\/07\/anychart_0.png 451w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>En el Foro de XlineSoft y correos que he recibido, hay usuarios que desean que en la p\u00e1gina LIST se pueda facilitar un gr\u00e1fico en cada l\u00ednea.<\/p>\n<p>He tomado este ejemplo para explicar c\u00f3mo se puede hacer con el Plugin de AnyChart.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3571\" src=\"https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2024\/02\/grafico_2_001.png\" alt=\"\" width=\"800\" height=\"344\" srcset=\"https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2024\/02\/grafico_2_001.png 800w, https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2024\/02\/grafico_2_001-300x129.png 300w, https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2024\/02\/grafico_2_001-768x330.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Ese campo nuevo de la tabla \u00abFactura\u00bb es un duplicado del \u00abidfactura\u00bb y lo utilizaremos con el plugin para crear el gr\u00e1ficos.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3572\" src=\"https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2024\/02\/grafico_2_002.png\" alt=\"\" width=\"800\" height=\"435\" srcset=\"https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2024\/02\/grafico_2_002.png 882w, https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2024\/02\/grafico_2_002-300x163.png 300w, https:\/\/fhumanes.es\/blog\/wp-content\/uploads\/2024\/02\/grafico_2_002-768x418.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Y el c\u00f3digo escrito para producir el gr\u00e1fico est\u00e1 en el fichero (<strong>anychart_3.php<\/strong>):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\n\/*\r\nVariables passed by the Plugin:\r\n\r\n$field_value .- Field what show screen\r\n$DataValue  .- Valor del campo que se utiliza en el plugin\r\n$javascript  .- File of Javascript of Anychart\r\n$theme .- File of Theme of Anychart\r\n$language  .- File Javscript of language\r\n$decimalsCount .-  Parameter\r\n$zeroFillDecimals .-  Parameter\r\n$decimalPoint .-  Parameter\r\n$groupsSeparator .-  Parameter\r\n$license .- License of ANYCHART  for PHPRunner\r\n$id_field .-  Field occurrence identification number used to identify the \"container\".\r\n*\/\r\n\r\nglobal $conn;\r\n\r\n$chartData='';\r\n\r\n$idfactura = $DataValue;\r\n\r\n$strSQLExists = \"SELECT\r\nfactura.idfactura, factura.Nif, factura.NombreRazonSocial, factura.FechaFactura, factura.TotalFactura,\r\nlinea_factura.idlinea_factura, linea_factura.factura_idfactura, linea_factura.producto_idproducto, linea_factura.Nombre, linea_factura.Valor\r\nFROM factura\r\nleft join linea_factura on (factura.idfactura = linea_factura.factura_idfactura)\r\nWHERE idfactura = $idfactura \";\r\n\r\n$rsExists = db_query($strSQLExists,$conn);\r\n\r\n  while ($Row = db_fetch_array($rsExists)) {\r\n    $idFactura='Factura: '.$Row[\"idfactura\"].' Producto: '.$Row[\"Nombre\"];\r\n    $TotalValor=$Row[\"Valor\"];\r\n    $FechaFactura=$Row[\"FechaFactura\"];\r\n    $chartData.=\"['$idFactura', $TotalValor, $FechaFactura] \\n,\";\r\n  }\r\n$chartData = substr($chartData, 0, -1);\r\n \r\n$graphicDefinition= &lt;&lt;&lt;EOT\r\n\r\n\/\/ create pie chart with passed data\r\nvar data = anychart.data.set([ \r\n\/\/ add data of the Client\r\n $chartData \r\n    ]);\r\n\r\nvar wealth = data.mapAs({'x': 0, 'value': 1});\r\n\r\nvar chart = anychart.pie(wealth);\r\n\r\n\/\/ License, out logo\r\n$license\r\n\r\n\/\/ apply coffee theme\r\n\/\/ anychart.theme(anychart.themes.coffee);\r\n\r\n\/\/ turn on chart animation\r\nchart.animation(true);\r\n\r\n\/\/ set chart title text settings\r\nchart.title('Facturas del Cliente');\r\n\/\/ Special \r\nchart.title().enabled(false);\r\n\r\n\r\n\/\/ Tooltip\r\nvar tooltip = chart.tooltip();\r\ntooltip.titleFormat(\"{%x}\");\r\n\r\ntooltip.format(\"Valor:{%value}{groupsSeparator:.,decimalPoint:\\\\\\\\,,decimalsCount:2}({%yPercentOfTotal}{decimalPoint:\\\\\\\\,,decimalsCount:2}%)\");\r\n\r\n\/\/ URL Format in:  https:\/\/docs.anychart.com\/Common_Settings\/Text_Formatters\r\n\r\nchart.labels().format('{%Value}{decimalsCount:0} ({%yPercentOfTotal}{decimalsCount:2}%)');\r\n\r\n\/\/ set legend title text settings\r\nvar legend = chart.legend();\r\n\/\/ set legend position and items layout\r\nlegend.position(\"center\");\r\nlegend.align(\"Bottom\");\r\nlegend.fontSize(10);\r\nlegend.itemsLayout(\"vertical\");\r\n\r\n\/\/ Special \r\nlegend.enabled(false);\r\n\r\n\/\/ set container id for the chart\r\nchart.container('container_$id_field');\r\n\/\/ initiate chart drawing\r\nchart.draw();\r\n});\r\n&lt;\/script&gt;\r\nEOT;\r\n\r\n$field_value .= $graphicDefinition;\r\n?&gt;<\/pre>\n<p>La nueva versi\u00f3n est\u00e1 programada en PHPRunner 10.7<\/p>\n<p>Si te interesa este art\u00edculo, <a href=\"https:\/\/fhumanes.es\/blog\/otros-ejemplos\/utilizacion-del-plugin-anychart\/\">sigue ley\u00e9ndolo en este link<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>En el Foro de XlineSoft y correos que he recibido, hay usuarios que desean que en la p\u00e1gina LIST se pueda facilitar un gr\u00e1fico en cada l\u00ednea. He tomado este ejemplo para explicar c\u00f3mo se puede hacer con el Plugin de AnyChart. Ese campo nuevo de la tabla \u00abFactura\u00bb es un duplicado del \u00abidfactura\u00bb y &hellip; <a href=\"https:\/\/fhumanes.es\/blog\/utilizacion-del-plugin-anychart-actualizacion\/\" class=\"more-link\">Seguir leyendo <span class=\"screen-reader-text\">Utilizaci\u00f3n del Plugin AnyChart Actualizaci\u00f3n<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-3575","post","type-post","status-publish","format-standard","hentry","category-plugins"],"_links":{"self":[{"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/posts\/3575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/comments?post=3575"}],"version-history":[{"count":1,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/posts\/3575\/revisions"}],"predecessor-version":[{"id":3576,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/posts\/3575\/revisions\/3576"}],"wp:attachment":[{"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/media?parent=3575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/categories?post=3575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fhumanes.es\/blog\/wp-json\/wp\/v2\/tags?post=3575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}