我有一个向下钻取的 HBar 图表。第一个图表的高度为 6.000,但向下钻取应该小得多,大约 400 像素,但我只能在同一画布上绘制第二个,高度相同。当我单击其中一个栏时,是否可以重新调整画布的尺寸?
<canvas id="<?php echo $Geocanvas; ?>" width="900" height="6000" style="border: 1px solid #ddd">[No canvas support]</canvas>
<script>
window.onload = function ()
{
var ca = document.getElementById("<?php echo $Geocanvas; ?>");
var data = <?php echo $data; ?>;
var labels =<?php echo $labels; ?>;
var YMax =<?php echo $YMax; ?>;
var Geocanvas =<?php echo $Geocanvas; ?>;
var data_drilldown = [<?php echo implode(',', $data_drill) ?>];
var labels_drilldown = [<?php echo implode(',', $labels_drill) ?>];
var bar = DrawMainChart();
/**
* Draws the main chart
*/
function DrawMainChart ()
{
RGraph.Reset(ca);
var bar = new RGraph.HBar(Geocanvas, data)
.Set('labels', labels)
.Set('bevel', true)
.Set('grouping', 'stacked')
.Set('ymax', YMax)
.Set('shadow', true)
.Set('shadow.color', ['#3897c5'])
.Set('shadow.offsety', 0)
.Draw();
bar.onclick = function (e, shape)
{
var obj = e.target.__object__;
var ca = obj.canvas;
var idx = shape.index;
/**
* Slide the old bar out
*/
RGraph.Effects.Fade.Out(obj, null, function ()
{
RGraph.Reset(ca);
var bar = new RGraph.Bar(Geocanvas, data_drilldown[idx])
.Set('labels', labels_drilldown[idx])
;
RGraph.Effects.Fade.In(obj);
});
}
/**
* The onmousemove event to change the cursor
*/
bar.onmousemove = function (e, shape)
{
e.target.style.cursor = 'pointer';
}
return bar;
}
document.getElementById("butBack").onclick = function (e)
{
var obj = ca.__object__;
RGraph.Effects.Fade.Out(obj,null,function ()
{
var bar = DrawMainChart();
RGraph.Effects.Fade.In(bar);
});
}
}
</script>