Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在plotly.js的堆积面积图中显示值和名称?_Javascript_Charts_Plotly_Stacked Area Chart - Fatal编程技术网

Javascript 如何在plotly.js的堆积面积图中显示值和名称?

Javascript 如何在plotly.js的堆积面积图中显示值和名称?,javascript,charts,plotly,stacked-area-chart,Javascript,Charts,Plotly,Stacked Area Chart,在下面链接中@emackey提供的解决方案中,它只显示解决方案中的值,而不显示跟踪的名称。如何显示名称,而不仅仅是值 //此代码由emackey在stackoverflow中提供 var stacksDiv=document.getElementByIdmyDiv; 变量跟踪=[ {x:[1,2,3],y:[2,1,4],fill:'tozeroy'}, {x:[1,2,3],y:[1,1,2],fill:'tonexty'}, {x:[1,2,3],y:[3,0,2],fill:'tonex

在下面链接中@emackey提供的解决方案中,它只显示解决方案中的值,而不显示跟踪的名称。如何显示名称,而不仅仅是值

//此代码由emackey在stackoverflow中提供 var stacksDiv=document.getElementByIdmyDiv; 变量跟踪=[ {x:[1,2,3],y:[2,1,4],fill:'tozeroy'}, {x:[1,2,3],y:[1,1,2],fill:'tonexty'}, {x:[1,2,3],y:[3,0,2],fill:'tonexty'} ]; 函数stackedAreatraces{ varⅠ,j;
对于i=0;i您只需更改一行:

traces[i].hoverinfo = 'text';
应该成为

traces[i].hoverinfo = 'text+name';

非常感谢@Dan Raps。