1. 10 May, 2017 4 commits
    • yungang's avatar
      add time happiness trend picture · f2f033d9
      yungang authored
      f2f033d9
    • yungang's avatar
      [from now] 2017/05/10 16:37:28 · b76da8f5
      yungang authored
      diff --git a/client/templates/chart/chart.html b/client/templates/chart/chart.html
      index 5509427..c024684 100644
      --- a/client/templates/chart/chart.html
      +++ b/client/templates/chart/chart.html
      @@ -2,4 +2,9 @@
           <div style="width: 90%">
               <canvas id="statistics" height="450" width="1500"></canvas>
           </div>
      +    <br>
      +    <br>
      +    <div style="width: 90%">
      +        <canvas id="statistics1" height="450" width="1500"></canvas>
      +    </div>
       </template>
      \ No newline at end of file
      diff --git a/client/templates/chart/chart.js b/client/templates/chart/chart.js
      index 4f0743c..8824bba 100644
      --- a/client/templates/chart/chart.js
      +++ b/client/templates/chart/chart.js
      @@ -6,11 +6,13 @@ import {HTTP} from 'meteor/http';
       import {getRandomColor} from "../../../lib/util/drawChart";
      
       let scatterChart;
      +let scatterChart1;
       let flag = true;
      
       Template.chart.onRendered(function () {
           let dictionary = {};
           let i = 1;
      +    let j = 1;
      
           scatterChart = new Chart(document.getElementById('statistics').getContext("2d"), {
               type: 'line',
      @@ -36,6 +38,30 @@ Template.chart.onRendered(function () {
               }
           });
      
      +    scatterChart1 = new Chart(document.getElementById('statistics1').getContext("2d"), {
      +        type: 'line',
      +        ticks: {
      +            autoSkip: true,
      +            maxTicksLimit: 20
      +        },
      +        data: {
      +            datasets: []
      +        },
      +        options: {
      +            responsive: true,
      +            title: {
      +                display: true,
      +                text: "Tweet trend"
      +            },
      +            scales: {
      +                xAxes: [{
      +                    type: "time"
      +
      +                }]
      +            }
      +        }
      +    });
      +
           Posts.find({}).observeChanges({
               added: function (id, record) {
                   for (let property in record.city) {
      @@ -77,6 +103,46 @@ Template.chart.onRendered(function () {
                           scatterChart.update();
                       }
                   }
      +
      +            for (let property in record.source) {
      +                if (record.source.hasOwnProperty(property)) {
      +                    // do stuff
      +                    if (!dictionary[property]) {
      +                        let color = getRandomColor();
      +                        dictionary[property] = j;
      +                        scatterChart1.data.datasets[j - 1] = {
      +                            label: property,
      +                            fill: false,
      +                            lineTension: 0.1,
      +                            borderColor: "rgba(75,192,192,1)",
      +                            borderCapStyle: 'butt',
      +                            borderDash: [],
      +                            borderDashOffset: 0.0,
      +                            borderJoinStyle: 'miter',
      +                            pointBackgroundColor: "#f0f0f0",
      +                            pointBorderWidth: 1,
      +                            pointHoverRadius: 5,
      +                            pointHoverBorderWidth: 2,
      +                            pointRadius: 1,
      +                            pointHitRadius: 10,
      +                            data: [{x: record.time, y: record.source[property]}],
      +                            spanGaps: false,
      +                        };
      +                        scatterChart1.data.datasets[j - 1].backgroundColor = color;
      +                        scatterChart1.data.datasets[j - 1].borderColor = color;
      +                        scatterChart1.data.datasets[j - 1].pointBorderColor = color;
      +                        scatterChart1.data.datasets[j - 1].pointHoverBackgroundColor = color;
      +                        j++;
      +                    } else {
      +                        let dataArray = scatterChart1.data.datasets[dictionary[property] - 1].data;
      +                        scatterChart1.data.datasets[dictionary[property] - 1].data.push({
      +                            x: record.time,
      +                            y: record.source[property] + dataArray[dataArray.length - 1].y
      +                        })
      +                    }
      +                    scatterChart1.update();
      +                }
      +            }
               }
           });
       });
      \ No newline at end of file
      diff --git a/client/templates/includes/header.html b/client/templates/includes/header.html
      index c97da04..2c9e61e 100644
      --- a/client/templates/includes/header.html
      +++ b/client/templates/includes/header.html
      @@ -12,4 +12,5 @@
                   </ul>
               </div>
           </nav>
      -</template>
      \ No newline at end of file
      +</template>
      +
      b76da8f5
    • yungang's avatar
      add statistic page and images source · d5497f6f
      yungang authored
      d5497f6f
    • yungang's avatar
      add statistic page and images source · 76e9019a
      yungang authored
      76e9019a
  2. 08 May, 2017 20 commits
  3. 07 May, 2017 16 commits