2018-04-10
Chart.js · Chart.js documentation
http://www.chartjs.org/docs/latest/
Getting Started · Chart.js documentation
https://www.chartjs.org/docs/latest/getting-started/
Chart.js samples
http://www.chartjs.org/samples/latest/
Chart.js - cdnjs.com - The best FOSS CDN for web related libraries to speed up your websites!
https://cdnjs.com/libraries/Chart.js
目前
https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.js
https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js
https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.js
https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js
環境:
Visual Studio 2017 v15.6.5 + WebForm
參考這篇範例
http://www.chartjs.org/docs/latest/
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript" src="Scripts/Chart.min.js"></script> <canvas id="myChart" width="400" height="400"></canvas> <script> var ctx = document.getElementById("myChart").getContext('2d'); var myChart = new Chart(ctx, { type: 'bar', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero: true } }] } } }); </script> </head> <body> <form id="form1" runat="server"> <div> </div> </form> </body> </html> |
(下圖) 預設畫面非常大,請調整瀏覽器寬度,高度會自動調整
(待續)
沒有留言:
張貼留言