Advertisement
Guest User

Untitled

a guest
May 25th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.03 KB | None | 0 0
  1. {% extends 'base.html' %}
  2. {%load staticfiles%}
  3. {% block content %}
  4.  
  5. <style>
  6.     select.form-control:not([size]):not([multiple]) {
  7.  
  8.     height: calc(2.25rem + 10px);
  9.  
  10. }
  11.  
  12. #graph-card {
  13.   background-color:#fff;
  14.   box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  15.   width: 98%;
  16.   min-height: 200px ;
  17.   margin: 5px;
  18.   transition: 0.3s;
  19.   border-radius: 5px;
  20.   border: 1px solid white;
  21.  
  22. }
  23. .buttontoggle {
  24.   background-color: #3d6bce; /* Green */
  25.   border: none;
  26.   color: white;
  27.   padding: 16px 32px;
  28.   text-align: center;
  29.   text-decoration: none;
  30.   display: inline-block;
  31.   font-size: 16px;
  32.   margin: 4px 2px;
  33.   -webkit-transition-duration: 0.4s; /* Safari */
  34.   transition-duration: 0.4s;
  35.   cursor: pointer;
  36. }
  37.  
  38. .buttontoogle {
  39.   background-color: white;
  40.   color: black;
  41.   border: 2px solid #008CBA;
  42. }
  43.  
  44. .button2toggle:hover {
  45.   background-color: #008CBA;
  46.   color: white;
  47. }
  48.  
  49.  
  50. </style>
  51. <meta charset="UTF-8">
  52.     <title>RFM Project</title>
  53.    
  54.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  55.  
  56.     <!-- Latest compiled JavaScript -->
  57.  
  58. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  59.  
  60.  
  61.  
  62.  
  63.             <div id="content" style="background-color: #f4f4f4">
  64.             <button onclick="topFunction()" id="myBtn" title="Go to top"><i class="glyphicon glyphicon-hand-up"></i></button>
  65.                <div>
  66.                  <button class="buttontoggle button2toggle" type="button"   id="sidebarCollapse"><i class="glyphicon glyphicon-align-left" style="color: white;"></i>
  67.                                 <span style="color: white;">Toggle Sidebar</span></button>
  68.                </div>
  69.               <br>
  70. <!---------------Start of Report ------------>
  71. <h3 style="font-family:sans-serif;" align="center" >My Influencer's : {{ user }} </h3>
  72.     <div class="col-md-12 pgraph">
  73.         <div id="treedata"></div>
  74.     </div>
  75.  
  76. <!----div class="row"------>
  77.  
  78.     <div class="col-md-12 graph ">
  79.         <h3 class="text-center">Segmentation by Influence</h3><hr>
  80.  
  81.  
  82.         <!----table -------->
  83.   <div id="graph-card">
  84.       <div class="col-md-12" id="tt_cat">
  85.           </br>
  86.           <form method="get" action="{% url 'dashboard:influencer_analysis' %}" enctype="multipart/form-data" class="cts"> {% csrf_token %}
  87.                 <select id = "category" name ="cat_sel" class="form-control" required >
  88.                     <option selected="selected">Choose Categories</option>
  89.                     {%for i in follower_cat %}
  90.                     <option name = '{{i}}' value="{{i}}">{{i}}</option>
  91.                     {% endfor %}
  92.                 </select>
  93.               <button type="submit" class="btn btn-success btn-block" style="background: #3d6bce;">Submit</button>
  94.           </form>
  95.     </div>
  96.       <!--- graphs------>
  97.     <div class="table-responsive">
  98.         <table class="table" style="font-size: 13px;">
  99.             <thead>
  100.                 <tr>
  101.                     <th scope="col">User</th>
  102.                     <th scope="col">Name</th>
  103.                     <th scope="col">Bio</th>
  104.                     <th scope="col"># of followers</th>
  105.                     <th scope="col">Last Active in Days</th>
  106.                 </tr>
  107.             </thead>
  108.             <tbody id="d1" style=""></tbody>
  109.         </table>
  110.     </div>
  111.  
  112.  
  113.  
  114.     <ul class="pager">
  115.       <li><button id='previous' class='btn btn-primary'><<</button></li>
  116.       <li><button id = 'next'   class='btn btn-primary'>>></button></li>
  117.     </ul>
  118.  
  119.  
  120.     <
  121.  </div>
  122. </div>
  123.  
  124. </div>
  125. <!---Loading on default----->
  126.  
  127. <script>
  128.  
  129. $(function(){
  130.  
  131.   var page = 1,
  132.     pagelimit = 10,
  133.     totalrecord = 0;
  134.  
  135.   fetchData();
  136.  
  137.   // handling the prev-btn
  138.   $("#previous").on("click", function(){
  139.     if (page > 1) {
  140.       page--;
  141.       fetchData();
  142.     }
  143.     console.log("Prev Page: " + page);
  144.   });
  145.  
  146.   // handling the next-btn
  147.   $("#next").on("click", function(){
  148.     if (page * 10 < totalrecord) {
  149.      page++;
  150.      fetchData();  
  151.    }
  152.    console.log("Next Page: " + page);
  153.  });
  154.  
  155.  
  156. function fetchData(){
  157.  
  158. $.ajax({
  159.          url: "{% url 'api:influencer_list' %}",
  160.          method: 'get',
  161.          data: {
  162.        page: page,
  163.      },
  164.              success:function(data){
  165.                totalrecord = data.count;
  166.                     var cat_option = ''
  167.                    for(var customer in data.results){
  168.                        cat_option+= '<tr><td><img src='+data.results[customer].t_profile_image_url +' class="img-circle" alt="image description" width="45" height="45"/></td><td><a href="http://twitter.com/'+data.results[customer].t_screen_name+'" target="_blank">'+data.results[customer].t_screen_name+'</a></td> <td>'+data.results[customer].t_description+'</td><td>'+data.results[customer].t_followers_count+'</td><td>'+data.results[customer].t_status_created_at_daydiff+'</td></tr>'
  169.                     }      
  170.                     $('#d1').html(cat_option)
  171.               },
  172.               error:function(errorData){
  173.                 console.log('error')
  174.                 console.log(errorData)
  175.               }
  176.         });
  177. }
  178. console.log(page)
  179. });
  180.  
  181.     </script>
  182.  
  183. <script></script>
  184.  
  185.  
  186. <!-- graph and customer selection with pagination -->
  187. <script>
  188.    $(document).ready(function(){
  189.    var t20 = $(".cts")
  190.    t20.submit(function(event){
  191.         event.preventDefault();
  192.         var page = 1,
  193.             pagelimit = 10,
  194.             totalrecord = 0;
  195.         fData();
  196.           // handling the prev-btn
  197.   $("#previous").on("click", function(){
  198.     if (page > 1) {
  199.       page--;
  200.       fData();
  201.     }
  202.     console.log("Prev Page cat: " + page);
  203.   });
  204.  
  205.   // handling the next-btn
  206.   $("#next").on("click", function(){
  207.     if (page * 10 < totalrecord) {
  208.      page++;
  209.      fData();  
  210.    }
  211.    console.log("Next Page cat: " + page);
  212.  });
  213.  
  214.  
  215.    function fData(){
  216.        var category = document.getElementById('category').value;
  217.        $.ajax({
  218.  
  219.              url: "{% url 'api:influencer_list' %}?cat_sel="+category,
  220.              method: 'get',
  221.              data: {
  222.                page: page,
  223.                    },
  224.              success:function(data){
  225.                     var cat_option = ''
  226.                    for(var customer in data.results){
  227.                        cat_option+= '<tr><td><img src='+data.results[customer].t_profile_image_url +' class="img-circle" alt="image description" width="45" height="45"/></td><td><a href="http://twitter.com/'+data.results[customer].t_screen_name+'" target="_blank">'+data.results[customer].t_screen_name+'</a></td> <td>'+data.results[customer].t_description+'</td><td>'+data.results[customer].t_followers_count+'</td><td>'+data.results[customer].t_status_created_at_daydiff+'</td></tr>'
  228.                     }      
  229.                     $('#d1').html(cat_option)
  230.               },
  231.               error:function(errorData){
  232.                 console.log('error')
  233.                 console.log(errorData)
  234.               }
  235.         });
  236.  
  237.                       }
  238. });
  239.  
  240.         return false;
  241.    });
  242.  
  243. </script>
  244.  
  245.  
  246.  
  247.  
  248. <!-- treemap -->
  249.  
  250. <script src="https://code.highcharts.com/highcharts.js"></script>
  251. <script src="https://code.highcharts.com/modules/treemap.js"></script>
  252. <div id="container"></div>
  253.  
  254. <style>
  255. #treedata {
  256.     min-length: 100%;
  257.     min-width: 100%;
  258.     max-width: 100%;
  259.     margin: 0 auto;
  260.  
  261. }
  262. </style>
  263.  
  264. <script>
  265.  
  266. Highcharts.chart('treedata', {
  267.     series: [{
  268.         type: "treemap",
  269.         layoutAlgorithm: 'stripes',
  270.         alternateStartingDirection: true,
  271.         levels: [{
  272.             level: 1,
  273.             layoutAlgorithm: 'sliceAndDice',
  274.             dataLabels: {
  275.                 enabled: true,
  276.                 align: 'center',
  277.                 verticalAlign: 'center',
  278.                 style: {
  279.                     fontSize: '18px',
  280.                     fontWeight: 'lighter'
  281.  
  282.                 }
  283.             }
  284.         }],
  285.         data: {{ data | safe}}
  286.     }],
  287.     title: {
  288.         text: ' '
  289.     }
  290. });
  291. </script>
  292.  
  293.  
  294. {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement