gpt4 book ai didi

charts - 如何在同一图表中集成折线图和面积图谷歌图表

转载 作者:行者123 更新时间:2023-12-04 02:55:46 26 4
gpt4 key购买 nike

我需要制作使用相同数据并显示折线图和面积图的图表。如何 复合折线图和面积图。 这是数据 ['年', '销售额', '费用', '总计'], ['2004', 1000, 400,600], ['2005', 1100, 200,900], ['2006', 6000, 5000,1000], ['2007', 1000, 500,500]

我需要销售和费用折线图和总面积图。

最佳答案

你可以使用 combo chart .这些图表可让您将每个系列呈现为来自以下列表的不同标记类型:折线图、区域图、条形图、烛台和阶梯区域。

要为系列分配默认标记类型,请指定 seriesType 属性。使用系列属性单独指定每个系列的属性。

有一个example在您可以编辑的链接中。你曾经能够做 compound chart但遗憾的是,这些现在已被弃用。

区域和线的例子:

 <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses', 'Total'],
['2004', 1000, 400, 600 ],
['2005', 1100, 200, 900 ],
['2006', 6000, 5000, 1000],
['2007', 1000, 500, 500 ],
]);

// Create and draw the visualization.
var ac = new google.visualization.ComboChart(document.getElementById('visualization'));
ac.draw(data, {
title : 'Sales & Expenses by Year',
width: 600,
height: 400,
vAxis: {title: "Sales"},
hAxis: {title: "Year"},
seriesType: "area",
series: {5: {type: "line"}}
});
}



google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization" style="width: 600px; height: 400px;"></div>
</body>
</html>

打印

Sales and Expenses

关于charts - 如何在同一图表中集成折线图和面积图谷歌图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16707076/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com