我需要在绘图js热图大标签。它需要大约9-11个字符。我尝试增加它使用的不同svg元素的宽度。
在下面的代码笔中,将y轴内容替换为y:‘上午我的文本’,‘下午我的文本’,‘晚上我的文本’,
https://codepen.io/plotly/pen/4cff7f15035142f88f62c9a4700c1d70
结果显示"ing My Text“。莫恩被藏起来了。
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div id="myDiv"><!-- Plotly chart will be drawn inside this DIV --></div>
<script>
<!-- JAVASCRIPT CODE GOES HERE -->
</script>
</body>
var data = [
{
z: [[1, 20, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, -10, 20]],
x: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
y: ['Morning My Text', 'Afternoon My Text', 'Evening My Text'],
type: 'heatmap'
}
];
Plotly.newPlot('myDiv', data);
发布于 2018-03-29 21:02:21
您可以将包含布局信息的第二个参数传递给Plotly.newPlot
。例如:Plotly.newPlot('myDiv', data, {yaxis: {automargin: true}});
将拉伸打印边距以适合Y轴标签。
请参阅https://plot.ly/javascript/plotlyjs-function-reference/和https://plot.ly/javascript/reference
发布于 2020-06-26 20:06:26
您可以动态设置页边距长度。
var maxLabelLength = 20;
const letterWidth = 7;
var layout = {
title: 'Bar Chart',
margin:{
l: maxLabelLength * letterWidth
}
};
https://stackoverflow.com/questions/49554484
复制相似问题