Advertisement
ZEdKasat

Untitled

Jan 22nd, 2022
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.96 KB | None | 0 0
  1. {% extends "base.html" %}
  2.  
  3. {% block title %}
  4.    
  5. {% endblock title %}
  6.  
  7.  
  8. {% block style %}
  9.     <style>
  10.       #incomeChart, #expenseChart{
  11.         height: 500px;
  12.         background-color: rgba(0, 0, 0, 0.5);
  13.       }
  14.       #chartContainer{
  15.         display: grid;
  16.         grid-template-columns: 1fr 1fr;
  17.         gap: 10px;
  18.       }
  19.     </style>
  20. {% endblock style %}
  21.  
  22. {% block content %}
  23.  
  24.     <div id="chartContainer">
  25.       <div id="incomeChart"></div>
  26.       <div id="expenseChart"></div>
  27.     </div>
  28.  
  29.  
  30.     <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  31.     <script type="text/javascript">
  32.       google.charts.load('current', {'packages':['corechart']});
  33.       google.charts.setOnLoadCallback(drawChart);
  34.      
  35.  
  36.       function drawChart() {
  37.  
  38.         var incomedata = google.visualization.arrayToDataTable({{income_by_category|safe}});
  39.         var expensedata = google.visualization.arrayToDataTable({{expense_by_category|safe}});
  40.  
  41.         var incomeoptions = {
  42.           title: 'Income Distribution',
  43.           is3D: true,
  44.           'backgroundColor': 'transparent',
  45.           'legend': {
  46.             textStyle: { color: "white"}
  47.           },
  48.           'titleTextStyle': {
  49.               color: "white"
  50.             }
  51.         };
  52.  
  53.         var expenseoptions = {
  54.           title: 'Expense Distribution',
  55.           is3D: true,
  56.           'backgroundColor': 'transparent',
  57.           'legend': {
  58.             textStyle: { color: "white"}
  59.           },
  60.           'titleTextStyle': {
  61.               color: "white"
  62.             }
  63.         };
  64.  
  65.         var Incomechart = new google.visualization.PieChart(document.getElementById('incomeChart'));
  66.         var Expensechart = new google.visualization.PieChart(document.getElementById('expenseChart'));
  67.  
  68.         Incomechart.draw(incomedata, incomeoptions);
  69.         Expensechart.draw(expensedata, expenseoptions);
  70.       }
  71.     </script>
  72.  
  73.    
  74.  
  75. {% endblock content %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement