ข้อมูลเบื้องต้นเกี่ยวกับไลบรารีแหล่งข้อมูล
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ไลบรารีแหล่งข้อมูลภาพของ Google ช่วยให้
สร้างแหล่งข้อมูลการแสดงภาพได้อย่างง่ายดาย ไลบรารีนี้จะนําโปรโตคอลสายเคเบิลของ Google คุณสามารถไปที่ API และภาษาในการค้นหา คุณเขียนเฉพาะโค้ดที่จําเป็นต่อการทําให้ข้อมูลพร้อมใช้งานสําหรับคลังในรูปแบบตารางข้อมูล ตารางข้อมูลคือตารางค่าสองมิติที่ทุกคอลัมน์อยู่ในประเภทเดียว การเขียนรหัสที่ต้องการนั้นทําได้ง่ายๆ ด้วยการจัดสรรชั้นเรียนนามธรรมและตัวช่วย
การปรับไลบรารีให้เรียบง่ายที่สุดคือการรับช่วงมาจากคลาสเดียว โดยใช้ฟังก์ชันสมาชิกและเรียกใช้แหล่งข้อมูลเป็นเซิร์ฟเล็ตภายในคอนเทนเนอร์เซิร์ฟเล็ต ในการใช้งานที่ง่ายที่สุด ลําดับเหตุการณ์ต่อไปนี้จะเกิดขึ้นเมื่อการแสดงภาพค้นหาแหล่งข้อมูล
- คอนเทนเนอร์ของเซิร์ฟเล็ตจะจัดการคําค้นหาและส่งไปยังไลบรารี Java ของแหล่งข้อมูล
- ไลบรารีจะแยกวิเคราะห์การค้นหา
- โค้ดที่ใช้หรือโค้ดที่คุณเขียนจะส่งตารางข้อมูลกลับไปยังไลบรารี
- ไลบรารีจะดําเนินการค้นหาในตารางข้อมูล
- ไลบรารีจะแสดงผลตารางข้อมูลลงในคําตอบที่
ต้องการของภาพ
- คอนเทนเนอร์ของเซิร์ฟเล็ตจะแสดงการตอบกลับไปยังการแสดงภาพ
ซึ่งจะแสดงอยู่ในแผนภาพต่อไปนี้

ส่วนการเริ่มต้นใช้งานแหล่งข้อมูลอธิบายวิธีใช้แหล่งข้อมูลประเภทนี้
ข้อมูลที่แสดงโดยแหล่งข้อมูลจะระบุอยู่ในโค้ดการนําไปใช้ของคุณ ซึ่งใช้ได้กับข้อมูลคงที่เพียงเล็กน้อย สําหรับชุดข้อมูลขนาดใหญ่ คุณอาจต้องใช้ที่เก็บข้อมูลภายนอก เช่น ไฟล์หรือฐานข้อมูลภายนอก หากแหล่งข้อมูลใช้ที่เก็บข้อมูลภายนอก ลําดับเหตุการณ์ต่อไปนี้จะเกิดขึ้นเมื่อมีการแสดงภาพแหล่งข้อมูล
- คอนเทนเนอร์ของเซิร์ฟเล็ตจะจัดการคําค้นหาและส่งไปยังไลบรารี Java ของแหล่งข้อมูล
- ไลบรารีจะแยกวิเคราะห์การค้นหา
- โค้ดการใช้งาน - โค้ดที่คุณเขียนจะอ่านข้อมูลที่เก็บไว้ในที่เก็บข้อมูลและแสดงผลตารางข้อมูลไปยังไลบรารี หากชุดข้อมูลมีขนาดใหญ่และที่เก็บข้อมูลมีความสามารถในการค้นหา คุณสามารถใช้ความสามารถดังกล่าวเพื่อเพิ่มประสิทธิภาพของแหล่งข้อมูลได้
- ไลบรารีจะดําเนินการค้นหาในตารางข้อมูล
- ไลบรารีจะแสดงผลตารางข้อมูลลงในคําตอบที่
ต้องการของภาพ
- คอนเทนเนอร์ของเซิร์ฟเล็ตจะแสดงการตอบกลับไปยังการแสดงภาพ
ซึ่งจะแสดงอยู่ในแผนภาพต่อไปนี้

ส่วนการใช้ที่เก็บข้อมูลภายนอกอธิบายวิธีนําแหล่งข้อมูลประเภทนี้ไปใช้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-07-10 UTC
[null,null,["อัปเดตล่าสุด 2024-07-10 UTC"],[[["\u003cp\u003eThe Google Visualization Data Source Library simplifies the creation of visualization data sources by implementing the Google Visualization API wire protocol and query language.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers primarily need to write code to make their data available as a data table, leveraging the library's abstract classes and helper functions.\u003c/p\u003e\n"],["\u003cp\u003eData sources can be implemented as servlets, handling queries from visualizations and returning data tables for rendering.\u003c/p\u003e\n"],["\u003cp\u003eFor larger datasets, the library supports using external data stores like files or databases, enabling efficient querying capabilities.\u003c/p\u003e\n"],["\u003cp\u003eThe library handles query parsing, data table execution, and rendering into the response format expected by the visualization.\u003c/p\u003e\n"]]],[],null,["# Introduction to the Data Source Library\n\n[Visit\nthe library project page!](http://code.google.com/p/google-visualization-java/)\n\nThe Google Visualization Data Source Library makes\nit easy to create a visualization data source. The library implements\nthe Google Visualization API wire\nprotocol and query language. You write only the code that is required to\nmake your data available to the library in the form of a data\ntable. A data table is a two-dimensional table of values where every\ncolumn is of a single type. Writing the code that you need is made easier\nby the provision of abstract classes and helper functions.\n\nThe simplest implementation of the library involves inheriting from\na single class, implementing a member function and running the\ndata source as a servlet within a servlet container. In the simplest\nimplementation, the following sequence of events takes place\nwhen a visualization queries the data source:\n\n1. The servlet container handles the query and passes it to the data source Java library.\n2. The library parses the query.\n3. The implementation code - the code that you write - returns a data table to the library.\n4. The library executes the query on the data table.\n5. The library renders the data table into the response expected by the visualization.\n6. The servlet container returns the response to the visualization.\n\nThis is illustrated in the following diagram:\n\nThe [Getting Started with Data Sources](/chart/interactive/docs/dev/dsl_get_started) section describes\nhow to implement this type of data source.\n\nThe data\nthat is served by a data source can be specified in your implementation\ncode, which is fine for small amounts of static data. For larger\ndata sets it is more likely you will need to use an external data store\nsuch as an external file or database. If a data source uses an external\ndata store, the following sequence of events takes place when a visualization\nqueries the data source:\n\n1. The servlet container handles the query and passes it to the data source Java library.\n2. The library parses the query.\n3. The implementation code - the code you write - reads the data held in the data store and returns a data table to the library. If the data set is large, and the data store has querying [capabilities](/chart/interactive/docs/dev/dsl_key_concepts#capabilities), you can optionally use those capabilities to increase the efficiency of your data source.\n4. The library executes the query on the data table.\n5. The library renders the data table into the response expected by the visualization.\n6. The servlet container returns the response to the visualization.\n\nThis is illustrated in the following diagram:\n\nThe [Using an External Data Store](/chart/interactive/docs/dev/dsl_csv) section describes how to implement this\ntype of data source."]]