ui.Chart.onClick
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ลงทะเบียน Callback ที่จะทริกเกอร์เมื่อคลิกแผนภูมิ
แสดงผลรหัสที่ส่งไปยัง unlisten() เพื่อยกเลิกการลงทะเบียนแฮนเดิลการเรียกกลับ
การใช้งาน | การคืนสินค้า |
---|
Chart.onClick(callback) | สตริง |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
ดังนี้ ui.chart | ui.Chart | อินสแตนซ์ ui.Chart |
callback | ฟังก์ชัน | Callback ที่จะเริ่มทำงานเมื่อมีการคลิกแผนภูมิ ระบบจะส่งอาร์กิวเมนต์ 3 รายการไปยังฟังก์ชันเรียกกลับ ได้แก่ ค่า x, ค่า y และชื่อชุดข้อมูล ค่าเวลาจะแสดงในหน่วยมิลลิวินาทีของ Epoch UTC เช่น ค่า "system:time_start" ในชิ้นงาน หากผู้ใช้คลิกรายการคำอธิบายเพื่อเลือกทั้งชุด ค่า x และ y จะเป็นค่าว่าง หากผู้ใช้คลิกจุดที่เลือกไว้แล้ว อาร์กิวเมนต์ทั้งหมดจะเป็นค่าว่าง ซึ่งบ่งบอกว่าระบบล้างการเลือกแล้ว |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-29 UTC
[null,null,["อัปเดตล่าสุด 2025-07-29 UTC"],[[["\u003cp\u003eThe \u003ccode\u003eChart.onClick()\u003c/code\u003e method registers a callback function that is triggered when a user clicks on a chart.\u003c/p\u003e\n"],["\u003cp\u003eThis function returns a unique ID that can be used with \u003ccode\u003eunlisten()\u003c/code\u003e to remove the registered callback.\u003c/p\u003e\n"],["\u003cp\u003eThe callback function receives the x-value, y-value, and series name as arguments, providing information about the clicked point on the chart.\u003c/p\u003e\n"],["\u003cp\u003eClicking on a legend entry to select a series results in null x and y values, while clicking an already-selected point results in all null arguments indicating selection clearance.\u003c/p\u003e\n"]]],[],null,["# ui.Chart.onClick\n\n\u003cbr /\u003e\n\nRegisters a callback that's fired when the chart is clicked.\n\n\u003cbr /\u003e\n\nReturns an ID which can be passed to unlisten() to unregister the callback.\n\n| Usage | Returns |\n|---------------------------|---------|\n| Chart.onClick`(callback)` | String |\n\n| Argument | Type | Details |\n|------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `ui.chart` | ui.Chart | The ui.Chart instance. |\n| `callback` | Function | The callback to fire when the chart is clicked. The callback is passed three arguments: the x-value, the y-value, and the series name. Time values are represented in UTC epoch milliseconds, like \"system:time_start\" values on assets. If the user clicks on a legend entry to select an entire series, the x- and y-values are null. If the user clicks an already-selected point, all arguments are null, indicating the selection was cleared. |"]]