Sending list information for google charts properly via flask to JS?
you can use a style column role
in your JS, add the role as the last column heading.
(the style role should follow the series column it represents)
var data1 = google.visualization.arrayToDataTable([ ['Episode', 'Rating', {role: 'style', type: 'string'}], // <-- add style role]);
then in your data, you can add the color each point should be...
data = [1, 8.7, 'blue'],[2, 8.8, 'blue'],[3, 8.3, 'blue'],[4, 8.4, 'red'],[5, 9.3, 'red'],[6, 8.9, 'orange'],[8, 9.3, 'orange'],[9, 8.4, 'orange'],
Here is my working code now after properly formatting the data block.
Python
def SendtoHTML(): finalEpNumParsable = int(finalEpNum) datapointTest = [[1, 8.7, "0000ff"],[2, 6.7, "orange"],[3, 8.7, "0000ff"],[4,6.7,'red']] render = render_template('Scatter.html', dataPoint = datapointTest) return render
JS
function drawChart() { var dataPoint = {{ dataPoint | tojson }}; var series = '{{series}}'; var finalEpUnparsed = {{finalEpNum}} var finalEpNum = parseInt(finalEpUnparsed, 10); var minRatingFinal = '{{minRatingFinal}}' var data1 = google.visualization.arrayToDataTable([ ['Episode', 'Rating', { role: 'style', type: 'string' }], // <-- add style role dataPoint[0] ]); for (i = 1; i < finalEpNum-5; i++){ data1.addRows([dataPoint[i]]);}