Ta usługa umożliwia użytkownikom tworzenie wykresów za pomocą narzędzi Google Charts i ich renderowanie po stronie serwera.
Jeśli chcesz renderować wykresy w przeglądarce, użyj interfejsu Google Charts API.
W tym przykładzie tworzymy podstawową tabelę danych, wypełniamy nią wykres obszarowy i dodajemy go do strony internetowej jako obraz:
functiondoGet(){vardata=Charts.newDataTable().addColumn(Charts.ColumnType.STRING,'Month').addColumn(Charts.ColumnType.NUMBER,'In Store').addColumn(Charts.ColumnType.NUMBER,'Online').addRow(['January',10,1]).addRow(['February',12,1]).addRow(['March',20,2]).addRow(['April',25,3]).addRow(['May',30,4]).build();varchart=Charts.newAreaChart().setDataTable(data).setStacked().setRange(0,40).setTitle('Sales per Month').build();varhtmlOutput=HtmlService.createHtmlOutput().setTitle('My Chart');varimageData=Utilities.base64Encode(chart.getAs('image/png').getBytes());varimageUrl="data:image/png;base64,"+encodeURI(imageData);htmlOutput.append("Render chart server side: <br/>");htmlOutput.append("<img border=\"1\" src=\""+imageUrl+"\">");returnhtmlOutput;}
Określa, czy kontroler powinien pasować tylko do dokładnych wartości (MatchType.EXACT), prefiksów rozpoczynających się od początku wartości (MatchType.PREFIX) lub dowolnego podciągu (MatchType.ANY).
Określa, czy kontrola ma działać za każdym razem, gdy użytkownik naciśnie klawisz, czy tylko wtedy, gdy pole wprowadzania „zmieni się” (czyli gdy straci fokus lub użytkownik naciśnie klawisz Enter).
Dodaje podstawową obsługę języków zapisywanych od prawej do lewej (np. arabskiego lub hebrajskiego) przez odwrócenie kolejności kolumn tabeli, tak aby kolumna 0 była kolumną najbardziej na prawo, a ostatnia kolumna – najbardziej na lewo.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2024-12-06 UTC."],[[["The Google Apps Script Charts Service enables server-side rendering of charts using Google Charts Tools, offering an alternative to the client-side Google Charts API."],["Charts are built using a structured process involving data table creation, chart construction with specific configurations like type, data source, and styling, and HTML output generation for display."],["The Charts Service provides a range of chart types, including AreaChart, BarChart, ColumnChart, LineChart, PieChart, ScatterChart, and TableChart, each with corresponding builder classes for customization."],["Comprehensive documentation details various classes and methods for data manipulation, visual styling, axes configuration, and interactive element creation, empowering developers to tailor charts to their needs."],["Developers can leverage methods from ScatterChartBuilder, StringFilterBuilder, TableChartBuilder, TextStyle, and TextStyleBuilder to fine-tune chart axes, filtering, table layouts, and text styles, enhancing chart customization and functionality."]]],["This service renders server-side charts using Google Charts Tools. Users create charts through builders like `AreaChartBuilder`, `BarChartBuilder`, etc. Data is structured in `DataTable` objects via `DataTableBuilder`. Charts can be converted to static images using `Chart.getAs()`. Customization includes setting colors, titles, dimensions, legends, axis styles, and data ranges. `ChartOptions` allow for advanced configurations. The `Charts` class provides the creation entry point and enums define chart, data, and styling options.\n"]]