2014-06-20 45 views
5

Tôi tương đối mới với biểu đồ google, vì vậy xin hãy tha thứ cho sự thiếu hiểu biết của tôi;Thay đổi màu Tô và Màu của biểu đồ vùng?

Tôi đang xem Biểu đồ vùng và tôi muốn thay đổi màu Tô và nét. Đây là mã ...

<!-- 
You are free to copy and use this sample in accordance with the terms of the 
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html) 
--> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
     <title> 
      Google Visualization API Sample 
     </title> 
     <script type="text/javascript" src="//www.google.com/jsapi"></script> 
     <script type="text/javascript"> 
      google.load('visualization', '1', {packages: ['corechart']}); 
     </script> 
     <script type="text/javascript"> 

      function drawVisualization() { 
       // Some raw data (not necessarily accurate) 
       var data = google.visualization.arrayToDataTable([ 
        ['Month', 'Target'], 
        ['JAN', 85], 
        ['FEB', 105], 
        ['MAR', 65], 
        ['APR', 45], 
        ['MAY', 45], 
        ['JUN', 15], 
        ['JUL', 60] 
       ]); 

       // Create and draw the visualization. 
       var ac = new google.visualization.AreaChart(document.getElementById('visualization')); 
       ac.draw(data, { 
        title : '', 
        isStacked: true, 
        width: 600, 
        height: 400, 
        vAxis: {title: "Millions"}, 
        hAxis: {title: "Month"} 
       }); 
      } 

      google.setOnLoadCallback(drawVisualization); 
     </script> 
    </head> 
    <body style="font-family: Arial;border: 0 none;"> 
     <div id="visualization" style="width: 600px; height: 400px;"></div> 
    </body> 
</html> 

Phần khác của câu hỏi là, tôi có thể tìm thấy tham chiếu hoàn chỉnh để tùy chỉnh biểu đồ google ở ​​đâu?

Cảm ơn,

Trả lời

7

Màu tô và màu nét của mỗi chuỗi trong AreaChart được xác định bằng màu của chuỗi. Bạn có thể thiết lập màu sắc của hàng loạt dữ liệu bằng cách thiết lập colors tùy chọn (trong đó có một mảng các chuỗi màu HTML, giao cho loạt dữ liệu theo thứ tự cột) hoặc thông qua series.<series index>.color tùy chọn (trong đó có một chuỗi màu HTML:

colors: ['#f36daa', 'blue', '#3fc26b'] 

hay:

series: { 
    0: { 
     // set options for the first data series 
     color: '#f36daa' 
    }, 
    1: { 
     // set options for the second data series 
     color: 'red' 
    }, 
    2: { 
     // set options for the third data series 
     color: '#3fc26b' 
    } 
} 

tùy chọn Chart được (chủ yếu) được ghi lại trong tài liệu cho bảng xếp hạng cụ thể. (ví dụ: AreaChart) Một số tính năng mà span nhiều bảng xếp hạng là tài liệu riêng biệt (ví dụ: Intervals, Trendlines, Dashboards and Controls, Event Handlers, Animations). Cấu trúc dữ liệu, thao tác dữ liệu, định dạng và các lớp liên quan được ghi lại trong API Reference.

Các vấn đề liên quan