]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
improve doughnut sample
authorVille Hämäläinen <hamalainen.ville.p@gmail.com>
Sun, 28 Feb 2016 08:15:18 +0000 (10:15 +0200)
committerVille Hämäläinen <hamalainen.ville.p@gmail.com>
Sun, 28 Feb 2016 08:15:18 +0000 (10:15 +0200)
- set title
- set same size canvas as other samples
- remove user select from canvas
- remove html legend
- remove logs

samples/doughnut.html

index 11ea3ffbc4df17034445f6a5849f6ec12d73a271..74da7d481b1dc1aa8dcf221c014933863561b000 100644 (file)
@@ -6,19 +6,16 @@
     <script src="../dist/Chart.bundle.js"></script>
     <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
     <style>
-    body {
-        padding: 0;
-        margin: 0;
-    }
-    
-    #canvas-holder {
-        width: 30%;
+    canvas {
+        -moz-user-select: none;
+        -webkit-user-select: none;
+        -ms-user-select: none;
     }
     </style>
 </head>
 
 <body>
-    <div id="canvas-holder" style="width:100%">
+    <div id="canvas-holder" style="width:75%">
         <canvas id="chart-area" />
     </div>
     <button id="randomizeData">Randomize Data</button>
     <button id="removeDataset">Remove Dataset</button>
     <button id="addData">Add Data</button>
     <button id="removeData">Remove Data</button>
-    <div>
-        <h3>Legend</h3>
-        <div id="legendContainer">
-            
-        </div>
-    </div>
     <script>
     var randomScalingFactor = function() {
         return Math.round(Math.random() * 100);
         }
     };
 
-    function updateLegend() {
-        $legendContainer = $('#legendContainer');
-        $legendContainer.empty();
-        $legendContainer.append(window.myDoughnut.generateLegend());
-    }
-
     window.onload = function() {
         var ctx = document.getElementById("chart-area").getContext("2d");
         window.myDoughnut = new Chart(ctx, config);
-        console.log(window.myDoughnut);
-
-        updateLegend();
     };
 
     $('#randomizeData').click(function() {
         });
 
         window.myDoughnut.update();
-        updateLegend();
     });
 
     $('#addDataset').click(function() {
 
         config.data.datasets.push(newDataset);
         window.myDoughnut.update();
-        updateLegend();
     });
 
     $('#addData').click(function() {
             });
 
             window.myDoughnut.update();
-            updateLegend();
         }
     });
 
     $('#removeDataset').click(function() {
         config.data.datasets.splice(0, 1);
         window.myDoughnut.update();
-        updateLegend();
     });
 
     $('#removeData').click(function() {
         });
 
         window.myDoughnut.update();
-        updateLegend();
     });
     </script>
 </body>