creating diagrams
-
I don’t understand how to insert a diagram into Calculated Fields Forms using CP Blocks; when adding a diagram, the code appears
<!--BLOCK_ID_74--><script>if(typeof chartjsBlock=='undefined'){chartjsBlock={'queue':[],'loading':false,'formatNumber':function(v){v=(new String(v)).replace(/[^\d\.\-]/g,'');if(!isNaN(v)) return v*1;throw'Not a Number';},'getColor':function(i){var COLORS=['#4dc9f6','#f67019','#f53794','#537bc4','#acc236','#166a8f','#00a950','#58595b','#8549ba'];return COLORS[i%COLORS.length];},'clear':function(id){var e=jQuery('#'+id),n=jQuery('<canvas></canvas>');n.attr('id',id).width(e.width()).height(e.height());e.replaceWith(n);},'callback':function(){while(this.queue.length){var i=this.queue.shift();i['chart'].apply(this,i['args']);}}};} chartjsBlock['pieChart']=function(canvasId,data,config){var me=this,options={responsive:!(document.getElementById(canvasId).offsetParent===null),animation:false,plugins:{legend:{display:true},title:{display:true}},cutout:0,},labels=[],values=[],colors=[];me.clear(canvasId);if(typeof config['title']=='string'){options['plugins']['title']['display']=true;options['plugins']['title']['text']=config['title'];delete config['titlel'];} jQuery.extend(true,options,config);if(typeof data==='object'&&typeof data['length']!=='undefined'){for(var i in data){var d=data[i],v;try{if(typeof d==='object'){if(typeof d['value']==='undefined') throw'Data Required';v=me.formatNumber(d.value);values.push(v);labels.push((typeof d['label']!=='undefined')?d.label:'');colors.push((typeof d['color']!=='undefined')?d.color:me.getColor(i));}else{v=me.formatNumber(d);values.push(v);labels.push('');colors.push(me.getColor(i));} if(v<0) options.scales.y.beginAtZero=false;}catch(err){continue;}}} new Chart(document.getElementById(canvasId),{type:'pie',data:{labels:labels,datasets:[{fill:false,data:values,backgroundColor:colors}]},options:options});};window['setPieChartBlock']=function(id,items,config){if(typeof id==='undefined') return;var c=document.getElementById(id);if(!c||c.tagName!=='CANVAS') return;if(typeof config==='undefined') config={};chartjsBlock.queue.push({'chart':chartjsBlock.pieChart,'args':[id,items,config]});if(typeof window['Chart']==='undefined'){if(!chartjsBlock.loading){jQuery.getScript('https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.min.js',function(){chartjsBlock.callback();});} chartjsBlock.loading=true;return;} chartjsBlock.callback();};</script><!--END_BLOCK_ID_74-->
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘creating diagrams’ is closed to new replies.