Open In App

jQWidgets jqxChart backgroundImage Property

Improve
Improve
Like Article
Like
Save
Share
Report

jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful and optimized framework, platform-independent, and widely supported. jqxChart is a lightweight and powerful chart widget written 100% in JavaScript. It offers many advanced features and supports three different rendering technologies – SVG, HTML5 Canvas, and VML.

The backgroundImage Property is used to set the background image of the chart. This property accepts string type values and its default value is empty ().

Syntax:

  • Set the backgroundImage property.
$('Selector').jqxChart({backgroundImage: 'image.jpg'});
  • To refresh the element of the chart:
$('Selector').jqxChart('refresh');

Linked Files: Download jQWidgets from the link. In the HTML file, locate the script files in the downloaded folder:

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxchart.core.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdraw.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdata.js”></script>

Example: The below example illustrates the jqxChart backgroundImage Property in jQWidgets.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" type="text/css"
          href="jqwidgets/styles/jqx.base.css"  />
    <script type="text/javascript"
            src="scripts/jquery-1.11.1.min.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxcore.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxchart.core.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxdraw.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxdata.js">
    </script>
</head>
  
<body>
    <center>
        <h1 style="color:green">
            GeeksforGeeks
        </h1>
        <h3>
            jQWidgets jqxChart backgroundImage Property
        </h3>
        <div id='chartContainer' 
             style="width:700px; 
                    height:500px">
        </div>
    </center>
    <script type="text/javascript">
        $(document).ready(function() {
            var Data = [{
                name: 'A',
                ques: 1,
            }, {
                name: 'B',
                ques: 1,
            }, {
                name: 'C',
                ques: 3,
            }, {
                name: 'D',
                ques: 21,
            }];
            
            // Prepare jqxChart settings
            var settings = {
                backgroundImage: 
                showLegend: true,
                enableCrosshairs: false,
                enabled: false,
                title: "Coding Questions",
                description: "Solved Daily",
                source: Data,
                categoryAxis: {
                    dataField: 'name'
                },
                seriesGroups: [{
                    type: 'line',
                    orientation: 'horizontal',
                    columnsGapPercent: 10,
                    valueAxis: {
                        unitInterval: 10,
                        maxValue: 15,
                        displayValueAxis: true,
                        description: '',
                    },
                    series: [{
                        dataField: 'ques',
                        displayText: 'Question Solved'
                    }]
                }]
            };
            $('#chartContainer').jqxChart(settings);
        });
    </script>
</body>
</html>


Output:

 

Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxchart/jquery-chart-api.htm?search=



Last Updated : 23 May, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads