Class DataSourceChart
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
رسم بيانيلمصدرالبيانات
الوصول إلى رسم بياني حالي لمصدر بيانات وتعديله
لا تستخدِم هذه الفئة إلا مع البيانات المرتبطة بقاعدة بيانات BigQuery.
مستندات تفصيلية
cancelDataRefresh()
تلغي إعادة تحميل البيانات المرتبطة بهذا العنصر إذا كانت قيد التنفيذ حاليًا.
يوضِّح هذا المثال كيفية إلغاء إعادة تحميل صيغة.
const spreadsheet = SpreadsheetApp.getActive();
const formula = spreadsheet.getDataSourceFormulas()[0];
// Cancel the ongoing refresh on the formula.
formula.cancelDataRefresh();
يُعرِض استثناءً إذا لم يكن نوع مصدر البيانات مفعّلاً. استخدِم طرق SpreadsheetApp#enable...Execution()
لتفعيل تنفيذ البيانات لنوع محدّد من مصادر البيانات.
الإرجاع
DataSourceChart
: عنصر البيانات
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
forceRefreshData()
تؤدي هذه الطريقة إلى إعادة تحميل بيانات هذا العنصر بصرف النظر عن حالته الحالية. يُرجى الاطّلاع على refreshData()
للحصول على
مزيد من التفاصيل. إذا أردت إلغاء عملية إعادة تحميل هذا العنصر التي يتم تنفيذها حاليًا، اطّلِع على cancelDataRefresh()
.
يُعرِض استثناءً إذا لم يكن نوع مصدر البيانات مفعّلاً. استخدِم طرق SpreadsheetApp#enable...Execution()
لتفعيل تنفيذ البيانات لنوع محدّد من مصادر البيانات.
الإرجاع
DataSourceChart
: عنصر البيانات
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSource()
تحصل على مصدر البيانات المرتبط بالعنصر.
الإرجاع
DataSource
: مصدر البيانات
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getStatus()
تحصل على حالة تنفيذ البيانات للكائن.
الإرجاع
DataExecutionStatus
: حالة تنفيذ البيانات
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
refreshData()
تؤدي هذه الطريقة إلى إعادة تحميل بيانات الكائن.
يُعرِض استثناءً إذا كان حاليًا في الحالة error
. استخدِم DataSource#updateSpec()
لتعديل المواصفة. ويُفضَّل استخدام هذه الطريقة بدلاً من forceRefreshData()
لمنع إجراء تعديلات غير متوقّعة على مصدر البيانات.
يُعرِض استثناءً إذا لم يكن نوع مصدر البيانات مفعّلاً. استخدِم طرق SpreadsheetApp#enable...Execution()
لتفعيل تنفيذ البيانات لنوع محدّد من مصادر البيانات.
الإرجاع
DataSourceChart
: عنصر البيانات
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
waitForCompletion(timeoutInSeconds)
تنتظر هذه الدالة حتى اكتمال التنفيذ الحالي، وتنتهي مهلة الانتظار بعد عدد الثواني المقدَّم.
يُعرِض استثناءً إذا لم يكتمل التنفيذ عند انتهاء المهلة، ولكنّه لا يلغي
تنفيذ البيانات.
المعلمات
الاسم | النوع | الوصف |
timeoutInSeconds | Integer | وقت الانتظار لتشغيل البيانات، بالثواني ويبلغ الحد الأقصى 300
ثانية. |
الإرجاع
DataExecutionStatus
: حالة تنفيذ البيانات
التفويض
تتطلّب النصوص البرمجية التي تستخدِم هذه الطريقة الحصول على إذن واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThe \u003ccode\u003eDataSourceChart\u003c/code\u003e class allows you to programmatically access and modify existing data source charts in Google Sheets, specifically those connected to BigQuery databases.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to refresh, force refresh, and cancel data refreshes for the chart, as well as to get its linked data source and execution status.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003erefreshData()\u003c/code\u003e is generally preferred over \u003ccode\u003eforceRefreshData()\u003c/code\u003e to prevent unintentional modifications to the data source.\u003c/p\u003e\n"],["\u003cp\u003eYou can monitor the status of a refresh using \u003ccode\u003egetStatus()\u003c/code\u003e or wait for it to complete with \u003ccode\u003ewaitForCompletion()\u003c/code\u003e, subject to a maximum timeout.\u003c/p\u003e\n"],["\u003cp\u003eThis class requires specific authorization scopes to be enabled for the script to function correctly.\u003c/p\u003e\n"]]],["The `DataSourceChart` class manages data in charts connected to a BigQuery database. Key actions include: refreshing data using `refreshData()` or `forceRefreshData()`, canceling ongoing refreshes with `cancelDataRefresh()`, and monitoring execution status via `getStatus()`. You can also get the connected data source with `getDataSource()`. `waitForCompletion()` allows waiting for data operations to complete. All actions require specific authorization scopes and may throw exceptions if data source types are not enabled.\n"],null,["# Class DataSourceChart\n\nDataSourceChart\n\nAccess and modify an existing data source chart.\n\n\n**Only use this class with data that's connected to a BigQuery database.** \n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------------------------------------|---------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|\n| [cancelDataRefresh()](#cancelDataRefresh()) | [DataSourceChart](#) | Cancels the data refresh associated with this object if it's currently running. |\n| [forceRefreshData()](#forceRefreshData()) | [DataSourceChart](#) | Refreshes the data of this object regardless of the current state. |\n| [getDataSource()](#getDataSource()) | [DataSource](/apps-script/reference/spreadsheet/data-source) | Gets the data source the object is linked to. |\n| [getStatus()](#getStatus()) | [DataExecutionStatus](/apps-script/reference/spreadsheet/data-execution-status) | Gets the data execution status of the object. |\n| [refreshData()](#refreshData()) | [DataSourceChart](#) | Refreshes the data of the object. |\n| [waitForCompletion(timeoutInSeconds)](#waitForCompletion(Integer)) | [DataExecutionStatus](/apps-script/reference/spreadsheet/data-execution-status) | Waits until the current execution completes, timing out after the provided number of seconds. |\n\nDetailed documentation\n----------------------\n\n### `cancel``Data``Refresh()`\n\nCancels the data refresh associated with this object if it's currently running.\n\nThis example shows how to cancel a formula refresh.\n\n```javascript\nconst spreadsheet = SpreadsheetApp.getActive();\nconst formula = spreadsheet.getDataSourceFormulas()[0];\n// Cancel the ongoing refresh on the formula.\nformula.cancelDataRefresh();\n```\n\nThrows an exception if the data source type is not enabled. Use `Spreadsheet``App#enable...Execution()` methods to enable data execution for specific data source\ntype.\n\n#### Return\n\n\n[DataSourceChart](#) --- The data object.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `force``Refresh``Data()`\n\nRefreshes the data of this object regardless of the current state. See [refreshData()](#refreshData()) for\nmore details. If you want to cancel a currently running refresh of this object, see [cancelDataRefresh()](#cancelDataRefresh()).\n\nThrows an exception if the data source type is not enabled. Use `Spreadsheet``App#enable...Execution()` methods to enable data execution for specific data source\ntype.\n\n#### Return\n\n\n[DataSourceChart](#) --- The data object.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Data``Source()`\n\nGets the data source the object is linked to.\n\n#### Return\n\n\n[DataSource](/apps-script/reference/spreadsheet/data-source) --- The data source.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Status()`\n\nGets the data execution status of the object.\n\n#### Return\n\n\n[DataExecutionStatus](/apps-script/reference/spreadsheet/data-execution-status) --- The data execution status.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `refresh``Data()`\n\nRefreshes the data of the object.\n\nThrows an exception if currently in [error](/apps-script/reference/spreadsheet/data-execution-state#ERROR) state. Use [DataSource#updateSpec()](/apps-script/reference/spreadsheet/data-source#updateSpec(DataSourceSpec)) to update the specification. The method is\npreferred over [forceRefreshData()](#forceRefreshData()) to prevent unexpected edits on data source.\n\nThrows an exception if the data source type is not enabled. Use `Spreadsheet``App#enable...Execution()` methods to enable data execution for specific data source\ntype.\n\n#### Return\n\n\n[DataSourceChart](#) --- The data object.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `wait``For``Completion(timeoutInSeconds)`\n\nWaits until the current execution completes, timing out after the provided number of seconds.\nThrows an exception if the execution is not completed when timing out, but does not cancel the\ndata execution.\n\n#### Parameters\n\n| Name | Type | Description |\n|------------------------|-----------|------------------------------------------------------------------------------|\n| `timeout``In``Seconds` | `Integer` | The time to wait for data execution, in seconds. The maximum is 300 seconds. |\n\n#### Return\n\n\n[DataExecutionStatus](/apps-script/reference/spreadsheet/data-execution-status) --- The data execution status.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`"]]