The drawing API image object

The drawing API image object which be added to your chart and provides a way for you to add images to your charts. These images can be interactive and so can provide a way for you to give your users extra information

[No canvas support]

The image object allows you to add images to your charts. The image can be used as a way to provide an extra tooltip (for example) to your users, orit is being used as a background image instead of using the background image.

The advantage in this case is that by using the image drawing object as the background image instead of specifying a background image for the Line chart (which you can do with background.image) is that you can click the background and have the events.click triggered and/or show a tooltip.


Usage example

<script>
    new RGraph.Line({
        id: 'cvs',
        data: [4,9,1,3,2,6,5],
        options: {
            xaxisLabels: ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],
            hmargin: 5,
            tickmarksStyle: 'endcircle',
            colors: ['black'],
            tooltips: ['A','B','C','D','E','F','G'],
            marginBottom: 35,
            textSize: 14
        }
    }).draw();

    var image = new RGraph.Drawing.Image({
        id: 'cvs',
        x: 30,
        y: 30,
        src: '/images/logo.png',
        options: {
            width: 32,
            height: 32,
            tooltips: ['Your logo!'],
            textSize: 14
        }
    }).draw();
</script>

Properties

Configuration properties

PropertyDescriptionDefault
widthIf you want to stretch or shrink your image - use this to set the width.null
heightIf you want to stretch or shrink your image - use this to set the height.null
halignThis dtermines the horizontal alignment of the image (left/center/right)left
valignThis dtermines the vertical alignment of the image (bottom/center/top)top

Color properties

PropertyDescriptionDefault
colorsAlphaUse this to set the alpha value (the transparency) of the image.1
colorsBackgroundThe background color for the image. This is effective if your image uses transparency.rgba(0,0,0,0)

Shadow properties

PropertyDescriptionDefault
shadowThis controls whether the shadow is enabled or not.false
shadowColorThe color of the shadow.gray
shadowOffsetxThe X offset that the shadow is drawn at.3
shadowOffsetyThe Y offset that the shadow is drawn at.3
shadowBlurThe severity of the shadow blur.5

Interactive features properties

PropertyDescriptionDefault
tooltipsThe tooltip for the circle. Even though you can only have one - this should still be an array: mycircle.set('tooltips', ['The tooltip']);null
tooltipsEventThis can be onclick or onmousemove and controls what event is used to trigger the tooltip.onclick
tooltipsHighlightThis stipulates whether the circle will be highlighted when the tooltip is shown.true
tooltipsNohideonclearNot an option that you'll need particularly often if at all. Setting this to true means that when you call the RGraph.clear() API function tooltip DO NOT get hidden.false

Event properties

PropertyDescriptionDefault
eventsClickIf you want to add your own onclick function you can do so by assigning it to this property. See here for details.null
eventsMousemoveIf you want to add your own onmousemove function you can do so by assigning it to this property. See here for details.null
eventsMouseoverIf you want to add your own onmouseover function you can do so by assigning it to this property. See here for details.null

Border properties

PropertyDescriptionDefault
borderThis controls whether a border is drawn around the image.false
borderLinewidthThis is the line width of the image.1
borderColorThis is the color of the border.black
borderRadiusThis is the severity of the curve used for the corners.0

Miscellaneous properties

PropertyDescriptionDefault
highlightStyleBy default this is null but you can set it to a function if you wish so that function is called to do the chart highlighting. Its passed the shape object as an argument.null
highlightStrokeThis is the color that the circle is highlighted (the stroke) in when the tooltip is shown.black
highlightFillThis is the color that the circle is highlighted in (the fill) when the tooltip is shown.rgba(255,255,255,0.7)