How to use CSS 3D transforms

Share RGraph:   

Summary
A guide for using CSS 3D transforms. Forthcoming CSS 3D transforms can be applied to your canvas

X angle:
Y angle:
Z angle:
(For best effect use Chrome or Safari)

WebKit (which is used by Google Chrome and Apple Safari) and Firefox support CSS 3D transforms. If you're tasked with only supporting these browsers then by using 3D transforms you can add 3D effects to your charts like the one shown. The effect is specified by adding a CSS property which is shown below. Because the effect changes the position of the canvas coordinates in relation to the page you must also tell RGraph to position the tooltips at the pageX/pageY coordinates which you do with the tooltipsCoordsPage option - as shown below.



<canvas id="cvs"
           width="600"
           height="250"
           style="float: right;
            -webkit-transform: rotate3d(0, 1, 0, 45deg) rotate3d(0, 0, 1, 5deg) rotate3d(1, 0, 0, -15deg);
            -moz-transform: rotate3d(0, 1, 0, 45deg) rotate3d(0, 0, 1, 5deg) rotate3d(1, 0, 0, -15deg);
            -o-transform: rotate3d(0, 1, 0, 45deg) rotate3d(0, 0, 1, 5deg) rotate3d(1, 0, 0, -15deg);
            -ms-transform: rotate3d(0, 1, 0, 45deg) rotate3d(0, 0, 1, 5deg) rotate3d(1, 0, 0, -15deg);
            transform: rotate3d(0, 1, 0, 45deg) rotate3d(0, 0, 1, 5deg) rotate3d(1, 0, 0, -15deg);
            box-shadow: 3px 3px 15px gray">[No canvas support]</canvas>
<script>
    window.onload = (function ()
    {
        var line = new RGraph.Line({
            id: 'cvs',
            data: [4,6,8,4,1,3,2,5,4,6,8],
            options: {
                labels: ['John', 'Geoff', 'Lou','Kevin','Barry','John','Alex','Nick','Dave','Hoolio','Pete'],
                hmargin: 10,
                scaleRound: true,
                tickmarks: 'arrow',
                textAccessible: false
            }
        }).expand()
    })
</script>

Note

If you use tooltips you will need to specify this:

myChart.set('tooltips.coords.page', true);

Known bugs

See also

Comments

Add a new comment...