Giới thiệu về Thư viện nguồn dữ liệu
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Thư viện nguồn dữ liệu hình ảnh của Google giúp bạn dễ dàng tạo nguồn dữ liệu hình ảnh trực quan. Thư viện này triển khai giao thức
API của Google Visual API và ngôn ngữ truy vấn. Bạn chỉ cần viết mã cần thiết để cung cấp dữ liệu của bạn cho thư viện dưới dạng bảng dữ liệu. Bảng dữ liệu là một bảng giá trị hai chiều, trong đó mỗi cột đều thuộc một loại duy nhất. Việc viết mã bạn cần sẽ được thực hiện dễ dàng hơn
bằng cách cung cấp các lớp trừu tượng và hàm trợ giúp.
Cách triển khai đơn giản nhất của thư viện liên quan đến việc kế thừa từ một lớp duy nhất, triển khai hàm thành viên và chạy nguồn dữ liệu dưới dạng Carousel trong vùng chứa GVP. Trong cách triển khai đơn giản nhất, trình tự sự kiện sau đây sẽ diễn ra khi một hình ảnh trực quan truy vấn nguồn dữ liệu:
- Vùng chứa GVP xử lý truy vấn và chuyển
truy vấn sang thư viện Java nguồn dữ liệu.
- Thư viện sẽ phân tích cú pháp truy vấn.
- Mã triển khai – mã mà bạn viết – trả về
bảng dữ liệu cho thư viện.
- Thư viện sẽ thực thi truy vấn trên bảng dữ liệu.
- Thư viện sẽ hiển thị bảng dữ liệu vào phản hồi dự kiến bởi hình ảnh trực quan.
- Vùng chứa GVP sẽ trả về phản hồi cho hình ảnh trực quan.
Điều này được minh họa trong sơ đồ sau:

Phần Bắt đầu sử dụng nguồn dữ liệu mô tả cách triển khai loại nguồn dữ liệu này.
Bạn có thể chỉ định dữ liệu do nguồn dữ liệu phân phát trong mã triển khai. Việc này rất nhỏ đối với một lượng nhỏ dữ liệu tĩnh. Đối với các tập dữ liệu lớn hơn, bạn có nhiều khả năng sẽ cần sử dụng kho dữ liệu bên ngoài, chẳng hạn như tệp bên ngoài hoặc cơ sở dữ liệu. Nếu một nguồn dữ liệu sử dụng kho dữ liệu
bên ngoài, trình tự sự kiện sau đây sẽ diễn ra khi một hình ảnh
truy vấn nguồn dữ liệu:
- Vùng chứa GVP xử lý truy vấn và chuyển truy vấn đó đến thư viện Java nguồn dữ liệu.
- Thư viện sẽ phân tích cú pháp truy vấn.
- Mã triển khai – mã bạn viết – đọc dữ liệu được lưu giữ trong kho lưu trữ dữ liệu và trả về bảng dữ liệu cho thư viện. Nếu tập dữ liệu lớn và kho dữ liệu có khả năng truy vấn, bạn có thể tùy ý sử dụng các khả năng đó để tăng hiệu suất của nguồn dữ liệu.
- Thư viện sẽ thực thi truy vấn trên bảng dữ liệu.
- Thư viện sẽ hiển thị bảng dữ liệu vào phản hồi dự kiến bởi hình ảnh trực quan.
- Vùng chứa GVP sẽ trả về phản hồi cho hình ảnh trực quan.
Điều này được minh họa trong sơ đồ sau:

Mục Sử dụng Kho dữ liệu bên ngoài mô tả cách triển khai loại nguồn dữ liệu này.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-07-10 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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."]]