如何确定桑基图起始块的大小?
How can I size the Sankey Chart Starting blocks?
我想知道如何自定义单个 Sankey Chart 起始块的大小?
例如,我希望煤炭垂直起跑线连同路径比天然气垂直起跑线小一个百分比。我曾尝试查看 Google 开发文档,但我只看到有关如何展开、展开和更改桑基图颜色的参考。
这是我当前通过 JSFiddle 编写的代码:
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'From');
data.addColumn('string', 'To');
data.addColumn('number', 'Weight');
data.addRows([
[ 'Nuclear Electric Power', 'Electricity Retail Sales', 100 ],
[ 'Renewable Energy', 'Electricity System Energy Losses', 29 ],
[ 'Coal', 'Electricity System Energy Losses', 96 ],
[ 'Natural Gas', 'Electricity System Energy Losses', 44 ],
[ 'Petroleum', 'Transportation', 87 ],
[ 'Electricity System Energy Losses', 'Commercial', 69 ],
[ 'Electricity System Energy Losses', 'Residential', 69 ],
[ 'Electricity System Energy Losses', 'Industrial', 28 ],
[ 'Renewable Energy', 'Commercial', 1 ],
[ 'Renewable Energy', 'Residential', 8 ],
[ 'Renewable Energy', 'Industrial', 61 ],
[ 'Coal', 'Industrial', 4 ],
[ 'Natural Gas', 'Commercial', 12],
[ 'Natural Gas', 'Residential', 13],
[ 'Natural Gas', 'Industrial', 30],
[ 'Natural Gas', 'Transportation', 1],
[ 'Petroleum', 'Commercial', 2 ],
[ 'Petroleum', 'Residential', 2 ],
[ 'Petroleum', 'Industrial', 9 ]
//MAKE SURE TO NOT PUT A COMMA ON THE LAST BLOCK
]);
// Sets chart options.
var options = {
width: 600,
};
//var options = {
//height: 400,
//sankey: {
//node: {
//colors: colors
//},
//link: {
//colorMode: 'gradient',
//colors: colors
//}
//}
//};
// Instantiates and draws our chart, passing in some options.
var chart = new google.visualization.Sankey(document.getElementById('sankey_basic'));
chart.draw(data, options);
}
煤的垂直线(矩形称为节点)的大小基于您数据中的 value/weight。如果您查看 Coal,它的组合值是 100 ([ 'Coal', 'Electricity System Energy Losses', 96 ] + [ 'Coal', 'Industrial', 4 ])。将值从 96 减小到 50(示例),节点高度会发生变化。希望这有帮助。
我想知道如何自定义单个 Sankey Chart 起始块的大小?
例如,我希望煤炭垂直起跑线连同路径比天然气垂直起跑线小一个百分比。我曾尝试查看 Google 开发文档,但我只看到有关如何展开、展开和更改桑基图颜色的参考。
这是我当前通过 JSFiddle 编写的代码:
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'From');
data.addColumn('string', 'To');
data.addColumn('number', 'Weight');
data.addRows([
[ 'Nuclear Electric Power', 'Electricity Retail Sales', 100 ],
[ 'Renewable Energy', 'Electricity System Energy Losses', 29 ],
[ 'Coal', 'Electricity System Energy Losses', 96 ],
[ 'Natural Gas', 'Electricity System Energy Losses', 44 ],
[ 'Petroleum', 'Transportation', 87 ],
[ 'Electricity System Energy Losses', 'Commercial', 69 ],
[ 'Electricity System Energy Losses', 'Residential', 69 ],
[ 'Electricity System Energy Losses', 'Industrial', 28 ],
[ 'Renewable Energy', 'Commercial', 1 ],
[ 'Renewable Energy', 'Residential', 8 ],
[ 'Renewable Energy', 'Industrial', 61 ],
[ 'Coal', 'Industrial', 4 ],
[ 'Natural Gas', 'Commercial', 12],
[ 'Natural Gas', 'Residential', 13],
[ 'Natural Gas', 'Industrial', 30],
[ 'Natural Gas', 'Transportation', 1],
[ 'Petroleum', 'Commercial', 2 ],
[ 'Petroleum', 'Residential', 2 ],
[ 'Petroleum', 'Industrial', 9 ]
//MAKE SURE TO NOT PUT A COMMA ON THE LAST BLOCK
]);
// Sets chart options.
var options = {
width: 600,
};
//var options = {
//height: 400,
//sankey: {
//node: {
//colors: colors
//},
//link: {
//colorMode: 'gradient',
//colors: colors
//}
//}
//};
// Instantiates and draws our chart, passing in some options.
var chart = new google.visualization.Sankey(document.getElementById('sankey_basic'));
chart.draw(data, options);
}
煤的垂直线(矩形称为节点)的大小基于您数据中的 value/weight。如果您查看 Coal,它的组合值是 100 ([ 'Coal', 'Electricity System Energy Losses', 96 ] + [ 'Coal', 'Industrial', 4 ])。将值从 96 减小到 50(示例),节点高度会发生变化。希望这有帮助。