Visualización: gráfico de líneas (imagen)
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Importante: La sección de gráficos de imágenes de las herramientas de gráficos de Google se dio de baja oficialmente a partir del 20 de abril de 2012. Seguirá funcionando de acuerdo con nuestra política de baja.
Descripción general
Un gráfico de líneas que se renderiza como una imagen con la API de Google Charts.
Ejemplo
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["imagelinechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var chart = new google.visualization.ImageLineChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240, min: 0});
}
</script>
</head>
<body>
<div id="chart_div" style="width: 400px; height: 240px;"></div>
</body>
</html>
Cargando
El nombre del paquete google.charts.load
es "imagelinechart"
.
google.charts.load('current', {packages: ['imagelinechart']});
El nombre de clase de la visualización es google.visualization.ImageLineChart
.
var visualization = new google.visualization.ImageLineChart(container);
La primera columna debe ser una cadena y contener la etiqueta de la categoría.
Puede ir seguida de cualquier cantidad de columnas. Todas deben ser numéricas.
Cada columna se muestra como una línea separada.
Opciones de configuración
Nombre |
Tipo |
Predeterminado |
Descripción |
backgroundColor |
cadena |
'#FFFFFF' (blanco) |
El color de fondo del gráfico en el formato de color de la API de Chart. |
colores |
Arreglo<string> |
Automático |
Úsala para asignar colores específicos a cada serie de datos. Los colores se especifican en el formato de color de la API de Chart.
El color i se usa para la columna de datos i y se ajusta al principio si hay más columnas de datos que colores. Si las variaciones de un solo color son aceptables para todas las series, usa la opción color en su lugar. |
enableEvents |
boolean |
false |
Hace que los gráficos muestren eventos activados por el usuario, como un clic o el mouse.
Solo es compatible con tipos de gráficos específicos. Consulta la sección Eventos a continuación. |
height |
número |
Altura del contenedor |
Es la altura del gráfico en píxeles. |
leyenda |
cadena |
'derecha' |
Posición y tipo de leyenda. Puede ser una de las siguientes opciones:
- "right": a la derecha del gráfico.
- "left": se encuentra a la izquierda del gráfico.
- “top”: se encuentra encima del gráfico.
- "parte inferior": se encuentra debajo del gráfico.
- "none": No se muestra ninguna leyenda.
|
max |
número |
automático |
Valor máximo que se mostrará en el eje Y. |
min |
número |
automático |
El valor mínimo que se muestra en el eje Y. |
showAxisLines |
boolean |
verdadero |
Si se establece como falsa, quita las líneas y etiquetas de los ejes. |
showCategoryLabels |
boolean |
Igual que showAxisLines |
Si la estableces como falsa, se quitarán las etiquetas de las categorías (las etiquetas del eje X).
|
showValueLabels |
boolean |
Igual que showAxisLines |
Si se establece como falsa, quita las etiquetas de los valores (las etiquetas del eje Y). |
título |
cadena |
sin título |
Es el texto que se mostrará sobre el gráfico. |
valueLabelsInterval |
número |
Automático |
El intervalo en el que se muestran las etiquetas del eje de valores. Por ejemplo, si min es 0, max es 100 y valueLabelsInterval es 20, el gráfico mostrará etiquetas de eje en (0, 20, 40, 60, 80 100). |
width |
número |
Ancho del contenedor |
Es el ancho del gráfico en píxeles. |
Métodos
Método |
Tipo de datos que se muestra |
Descripción |
draw(data, options) |
ninguno |
Dibuja el gráfico. |
Eventos
Regístrate para escuchar los eventos descritos en la página Gráfico de imágenes genéricas.
Política de Datos
Consulta la política de registro de la API de Chart.
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2024-07-10 (UTC)
[null,null,["Última actualización: 2024-07-10 (UTC)"],[],[],null,["# Visualization: Line Chart (Image)\n\n**Important:** The Image Charts portion of Google Chart Tools has been [officially deprecated](http://googledevelopers.blogspot.com/2012/04/changes-to-deprecation-policies-and-api.html) as of April 20, 2012. It will continue to work as per our [deprecation policy](/chart/terms). \n1. [Overview](#Overview)\n2. [Example](#Example)\n3. [Loading](#Loading)\n4. [Data Format](#Data_Format)\n5. [Configuration Options](#Configuration_Options)\n6. [Methods](#Methods)\n7. [Events](#Events)\n8. [Data Policy](#Data_Policy)\n\nOverview\n--------\n\n\nA line chart that is rendered as an image using the [Google Charts API](/chart/image/docs/gallery/line_charts).\n\nExample\n-------\n\n\\\u003cscript type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"\\\u003e\\\u003c/script\\\u003e \\\u003cscript type=\"text/javascript\"\\\u003e google.charts.load('current', {'packages':\\['imagelinechart'\\]}); \\\u003c/script\\\u003e \\\u003cdiv id=\"chart_div\" style=\"width: 400px; height: 240px;\"\\\u003e\\\u003c/div\\\u003e google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable(\\[ \\['Year', 'Sales', 'Expenses'\\], \\['2004', 1000, 400\\], \\['2005', 1170, 460\\], \\['2006', 660, 1120\\], \\['2007', 1030, 540\\] \\]); var chart = new google.visualization.ImageLineChart(document.getElementById('chart_div')); chart.draw(data, {width: 400, height: 240, min: 0}); } \n\n```html\n\u003chtml\u003e\n \u003chead\u003e\n \u003cscript type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"\u003e\u003c/script\u003e\n \u003cscript type=\"text/javascript\"\u003e\n google.charts.load(\"current\", {packages:[\"imagelinechart\"]});\n google.charts.setOnLoadCallback(drawChart);\n\n function drawChart() {\n var data = google.visualization.arrayToDataTable([\n ['Year', 'Sales', 'Expenses'],\n ['2004', 1000, 400],\n ['2005', 1170, 460],\n ['2006', 660, 1120],\n ['2007', 1030, 540]\n ]);\n\n var chart = new google.visualization.ImageLineChart(document.getElementById('chart_div'));\n\n chart.draw(data, {width: 400, height: 240, min: 0});\n }\n \u003c/script\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003cdiv id=\"chart_div\" style=\"width: 400px; height: 240px;\"\u003e\u003c/div\u003e\n \u003c/body\u003e\n\u003c/html\u003e\n```\n\nLoading\n-------\n\n\nThe `google.charts.load` package name is `\"imagelinechart\"`. \n\n```gdscript\n google.charts.load('current', {packages: ['imagelinechart']});\n```\n\n\nThe visualization's class name is `google.visualization.ImageLineChart`. \n\n```gdscript\n var visualization = new google.visualization.ImageLineChart(container);\n```\n\nData Format\n-----------\n\n\nThe first column should be a string, and contain the category label.\nAny number of columns can follow, all must be numeric.\nEach column is displayed as a separate line.\n\nConfiguration Options\n---------------------\n\n| Name | Type | Default | Description |\n|---------------------|-----------------|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| backgroundColor | string | '#FFFFFF' (white) | The background color for the chart in the [Chart API color format](/chart/image/docs/chart_params#gcharts_rgb). |\n| colors | Array\\\u003cstring\\\u003e | Auto | Use this to assign specific colors to each data series. Colors are specified in the [Chart API color format](/chart/image/docs/chart_params#gcharts_rgb). Color i is used for data column i, wrapping around to the beginning if there are more data columns than colors. If variations of a single color is acceptable for all series, use the `color` option instead. |\n| enableEvents | boolean | false | Causes charts to throw user-triggered events such as click or mouse over. Supported only for specific chart types. See [Events](#Events) below. |\n| height | number | Container's height | Height of the chart in pixels. |\n| legend | string | 'right' | Position and type of legend. Can be one of the following: - 'right' - To the right of the chart. - 'left' - To the left of the chart. - 'top' - Above the chart. - 'bottom' - Below the chart. - 'none' - No legend is displayed. |\n| max | number | automatic | The maximal value to show in the Y axis. |\n| min | number | automatic | The minimal value to show in the Y axis. |\n| showAxisLines | boolean | true | If set to false, removes axis lines and labels. |\n| showCategoryLabels | boolean | same as showAxisLines | If set to false, removes the labels of the categories (the X axis labels). |\n| showValueLabels | boolean | same as showAxisLines | If set to false, removes the labels of the values (the Y axis labels). |\n| title | string | no title | Text to display above the chart. |\n| valueLabelsInterval | number | Auto | The interval at which to show value axis labels. For example, if `min` is 0, `max` is 100, and `valueLabelsInterval` is 20, the chart will show axis labels at (0, 20, 40, 60, 80 100). |\n| width | number | Container's width | Width of the chart in pixels. |\n\nMethods\n-------\n\n| Method | Return Type | Description |\n|-----------------------|-------------|------------------|\n| `draw(data, options)` | none | Draws the chart. |\n\nEvents\n------\n\nYou can register to hear the events described on the [Generic\nImage Chart](/chart/interactive/docs/gallery/genericimagechart#Events) page.\n\nData Policy\n-----------\n\n\nPlease refer to the [Chart API logging policy](/chart/interactive/faq#logging)."]]