การแสดงภาพ: แผนภูมิเส้น (รูปภาพ)
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สำคัญ: ส่วนแผนภูมิรูปภาพของเครื่องมือ Google แผนภูมิได้เลิกใช้งานอย่างเป็นทางการเมื่อวันที่ 20 เมษายน 2012 และจะยังใช้งานต่อตามนโยบายการเลิกใช้งาน
ภาพรวม
แผนภูมิเส้นที่แสดงเป็นรูปภาพโดยใช้ Google Charts API
ตัวอย่าง
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["imagelinechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var chart = new google.visualization.ImageLineChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240, min: 0});
}
</script>
</head>
<body>
<div id="chart_div" style="width: 400px; height: 240px;"></div>
</body>
</html>
กำลังโหลด
ชื่อแพ็กเกจ google.charts.load
คือ "imagelinechart"
google.charts.load('current', {packages: ['imagelinechart']});
ชื่อคลาสของการแสดงภาพคือ google.visualization.ImageLineChart
var visualization = new google.visualization.ImageLineChart(container);
คอลัมน์แรกควรเป็นสตริงและมีป้ายกำกับหมวดหมู่
ตามด้วยคอลัมน์จำนวนเท่าใดก็ได้ ทั้งหมดต้องเป็นตัวเลข
แต่ละคอลัมน์จะแสดงเป็นเส้นแยกจากกัน
ตัวเลือกการกำหนดค่า
ชื่อ |
ประเภท |
ค่าเริ่มต้น |
คำอธิบาย |
backgroundColor |
string |
"#FFFFFF" (สีขาว) |
สีพื้นหลังของแผนภูมิในรูปแบบสี Chart API |
สี |
อาร์เรย์<สตริง> |
อัตโนมัติ |
ใช้เพื่อกำหนดสีที่เจาะจงให้กับชุดข้อมูลแต่ละชุด คุณระบุสีได้ในรูปแบบสีของ Chart API
สี i จะใช้กับคอลัมน์ข้อมูล i โดยล้อมรอบส่วนต้นตอ
หากมีคอลัมน์ข้อมูลมากกว่าสี หากชุดสีเดียวมีรูปแบบต่างๆ ที่ใช้ได้กับทุกชุด ให้ใช้ตัวเลือก color แทน |
enableEvents |
boolean |
false |
ทําให้แผนภูมิเกิดเหตุการณ์ที่ผู้ใช้ทริกเกอร์ เช่น คลิกหรือวางเมาส์เหนือ
รองรับเฉพาะแผนภูมิบางประเภท ดูเหตุการณ์ด้านล่าง |
ส่วนสูง |
ตัวเลข |
ความสูงของคอนเทนเนอร์ |
ความสูงของแผนภูมิเป็นพิกเซล |
คำอธิบาย |
string |
"ขวา" |
ตำแหน่งและประเภทของคำอธิบาย อาจมีสถานะใดสถานะหนึ่งดังต่อไปนี้
- "ขวา" - ทางด้านขวาของแผนภูมิ
- "ซ้าย" - ทางด้านซ้ายของแผนภูมิ
- "top" - เหนือแผนภูมิ
- "bottom" - ใต้แผนภูมิ
- "none" - ไม่แสดงคำอธิบาย
|
สูงสุด |
ตัวเลข |
อัตโนมัติ |
ค่าสูงสุดที่จะแสดงในแกน Y |
นาที |
ตัวเลข |
อัตโนมัติ |
ค่าต่ำสุดที่จะแสดงในแกน Y |
showAxisLines |
boolean |
จริง |
หากตั้งค่าเป็น "เท็จ" ให้นำเส้นแกนและป้ายกำกับออก |
showCategoryLabels |
boolean |
เหมือนกับ showAxisLines |
หากตั้งค่าเป็น "เท็จ" ให้นำป้ายกำกับของหมวดหมู่ออก (ป้ายกำกับแกน X)
|
showValueLabels |
boolean |
เหมือนกับ showAxisLines |
หากตั้งค่าเป็น "เท็จ" ให้นำป้ายกำกับของค่าออก (ป้ายกำกับแกน Y) |
title |
string |
ไม่มีชื่อ |
ข้อความที่จะแสดงเหนือแผนภูมิ |
valueLabelsInterval |
ตัวเลข |
อัตโนมัติ |
ช่วงที่จะแสดงป้ายกำกับแกนค่า ตัวอย่างเช่น หาก min คือ 0, max เท่ากับ 100 และ valueLabelsInterval คือ 20 แผนภูมิจะแสดงป้ายกำกับแกนที่ (0, 20, 40, 60, 80 100) |
ความกว้าง |
ตัวเลข |
ความกว้างของคอนเทนเนอร์ |
ความกว้างของแผนภูมิเป็นพิกเซล |
วิธีการ
วิธีการ |
ประเภทการแสดงผล |
คำอธิบาย |
draw(data, options) |
ไม่มี |
วาดแผนภูมิ |
กิจกรรม
คุณลงทะเบียนเพื่อฟังเหตุการณ์ตามที่อธิบายไว้ในหน้าแผนภูมิรูปภาพทั่วไปได้
นโยบายข้อมูล
โปรดดูนโยบายการบันทึก Chart API
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-07-10 UTC
[null,null,["อัปเดตล่าสุด 2024-07-10 UTC"],[],[],null,["# Visualization: Line Chart (Image)\n\n**Important:** The Image Charts portion of Google Chart Tools has been [officially deprecated](http://googledevelopers.blogspot.com/2012/04/changes-to-deprecation-policies-and-api.html) as of April 20, 2012. It will continue to work as per our [deprecation policy](/chart/terms). \n1. [Overview](#Overview)\n2. [Example](#Example)\n3. [Loading](#Loading)\n4. [Data Format](#Data_Format)\n5. [Configuration Options](#Configuration_Options)\n6. [Methods](#Methods)\n7. [Events](#Events)\n8. [Data Policy](#Data_Policy)\n\nOverview\n--------\n\n\nA line chart that is rendered as an image using the [Google Charts API](/chart/image/docs/gallery/line_charts).\n\nExample\n-------\n\n\\\u003cscript type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"\\\u003e\\\u003c/script\\\u003e \\\u003cscript type=\"text/javascript\"\\\u003e google.charts.load('current', {'packages':\\['imagelinechart'\\]}); \\\u003c/script\\\u003e \\\u003cdiv id=\"chart_div\" style=\"width: 400px; height: 240px;\"\\\u003e\\\u003c/div\\\u003e google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable(\\[ \\['Year', 'Sales', 'Expenses'\\], \\['2004', 1000, 400\\], \\['2005', 1170, 460\\], \\['2006', 660, 1120\\], \\['2007', 1030, 540\\] \\]); var chart = new google.visualization.ImageLineChart(document.getElementById('chart_div')); chart.draw(data, {width: 400, height: 240, min: 0}); } \n\n```html\n\u003chtml\u003e\n \u003chead\u003e\n \u003cscript type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"\u003e\u003c/script\u003e\n \u003cscript type=\"text/javascript\"\u003e\n google.charts.load(\"current\", {packages:[\"imagelinechart\"]});\n google.charts.setOnLoadCallback(drawChart);\n\n function drawChart() {\n var data = google.visualization.arrayToDataTable([\n ['Year', 'Sales', 'Expenses'],\n ['2004', 1000, 400],\n ['2005', 1170, 460],\n ['2006', 660, 1120],\n ['2007', 1030, 540]\n ]);\n\n var chart = new google.visualization.ImageLineChart(document.getElementById('chart_div'));\n\n chart.draw(data, {width: 400, height: 240, min: 0});\n }\n \u003c/script\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003cdiv id=\"chart_div\" style=\"width: 400px; height: 240px;\"\u003e\u003c/div\u003e\n \u003c/body\u003e\n\u003c/html\u003e\n```\n\nLoading\n-------\n\n\nThe `google.charts.load` package name is `\"imagelinechart\"`. \n\n```gdscript\n google.charts.load('current', {packages: ['imagelinechart']});\n```\n\n\nThe visualization's class name is `google.visualization.ImageLineChart`. \n\n```gdscript\n var visualization = new google.visualization.ImageLineChart(container);\n```\n\nData Format\n-----------\n\n\nThe first column should be a string, and contain the category label.\nAny number of columns can follow, all must be numeric.\nEach column is displayed as a separate line.\n\nConfiguration Options\n---------------------\n\n| Name | Type | Default | Description |\n|---------------------|-----------------|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| backgroundColor | string | '#FFFFFF' (white) | The background color for the chart in the [Chart API color format](/chart/image/docs/chart_params#gcharts_rgb). |\n| colors | Array\\\u003cstring\\\u003e | Auto | Use this to assign specific colors to each data series. Colors are specified in the [Chart API color format](/chart/image/docs/chart_params#gcharts_rgb). Color i is used for data column i, wrapping around to the beginning if there are more data columns than colors. If variations of a single color is acceptable for all series, use the `color` option instead. |\n| enableEvents | boolean | false | Causes charts to throw user-triggered events such as click or mouse over. Supported only for specific chart types. See [Events](#Events) below. |\n| height | number | Container's height | Height of the chart in pixels. |\n| legend | string | 'right' | Position and type of legend. Can be one of the following: - 'right' - To the right of the chart. - 'left' - To the left of the chart. - 'top' - Above the chart. - 'bottom' - Below the chart. - 'none' - No legend is displayed. |\n| max | number | automatic | The maximal value to show in the Y axis. |\n| min | number | automatic | The minimal value to show in the Y axis. |\n| showAxisLines | boolean | true | If set to false, removes axis lines and labels. |\n| showCategoryLabels | boolean | same as showAxisLines | If set to false, removes the labels of the categories (the X axis labels). |\n| showValueLabels | boolean | same as showAxisLines | If set to false, removes the labels of the values (the Y axis labels). |\n| title | string | no title | Text to display above the chart. |\n| valueLabelsInterval | number | Auto | The interval at which to show value axis labels. For example, if `min` is 0, `max` is 100, and `valueLabelsInterval` is 20, the chart will show axis labels at (0, 20, 40, 60, 80 100). |\n| width | number | Container's width | Width of the chart in pixels. |\n\nMethods\n-------\n\n| Method | Return Type | Description |\n|-----------------------|-------------|------------------|\n| `draw(data, options)` | none | Draws the chart. |\n\nEvents\n------\n\nYou can register to hear the events described on the [Generic\nImage Chart](/chart/interactive/docs/gallery/genericimagechart#Events) page.\n\nData Policy\n-----------\n\n\nPlease refer to the [Chart API logging policy](/chart/interactive/faq#logging)."]]