I have a textearea with a value of an array with several values and colors to draw in a polar area chart:
<textarea style="display:none" id="span_canva_<?= $vino['id'] ?>" >
<?= $vino['vino_wineid'] ?>
</textarea>
{value: '20', color: '#4D5360'},
{value: '25', color: '#24b34b'},
{value: '14', color: '#7b3adc'},
{value: '68', color: '#8eb580'},
{value: '69', color: '#b58093'},
{value: '61', color: '#44454f'},
{value: '38', color: '#f65a7b'},
{value: '35', color: '#4e5d3e'},
{value: '41', color: '#cd2c7c'},
{value: '39', color: '#F7464A'},
{value: '33', color: '#46BFBD'},
{value: '62', color: '#8eb580'},
{value: '45', color: '#44454f'},
{value: '36', color: '#f7b10b'},
{value: '41', color: '#92a6ba'},
{value: '25', color: '#f65a7b'},
{value: '45', color: '#4e5d3e'},
{value: '35', color: '#F7464A'},
{value: '45', color: '#46BFBD'},
{value: '10', color: '#FDB45C'},
{value: '50', color: '#949FB1'},
{value: '40', color: '#4D5360'},
{value: '40', color: '#24b34b'}
Then I need to get the .text()
of the textarea
and draw into a canvas
(Chart.js). As you can see the format is right, just need to close the .text()
into []
. So I did it:
var id_match = jQuery(this).attr('id');
var vino_wineid = "[" + jQuery("#span_" + id_match).text() + "]";
contendor_chart_popup = new Chart(chart_popup).PolarArea(vino_wineid);
All seems perfect but nothing to draw for the canvas, that because the object type still incorrect.