Open In App

jQWidgets jqxChart xAxis 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 & VML.

The xAxis property is used to set the x-axis of the displayed jqxChart. It is of type object and its default value is “null”.

Syntax:

$('#Selector').jqxChart({
    xAxis: {
       rangeSelector: true
     }
});

The properties of the xAxis are as follows:

  • visible: It is used to show or hide the xAxis axis.
  • unitInterval: It is used to set the interval between the units of the displayed jqxChart.
  • dataField: It is used to point toward a data field in the data source.
  • type: It is the stated type of the axis. Here, the values can be as follows:
    • default: It is used to auto-detect and switch to basic, linear, or date.
    • date: It is used to display dates.
    • basic: It is used to display all the data points consecutively.
    • linear: It is the stated linear arrangement of the values of the xAxis data field.
  • baseUnit: It is the stated base unit whenever it’s used along with the date axis.
  • valuesOnTicks: It states if the values of the axis will be aligned along with the tick marks or not.
  • dateFormat: It is the optional date format in order to parse the data from the data source.
  • axisSize: It is used to set the size of the xAxis.
  • customDraw: It is of type boolean. It determines whether to draw the axis or not.
  • flip: It states if the axis is shown in reverse order or not.
  • position: It is used to set the position of the axis.
  • padding: It is of type object. It describes the padding of the axis which is as follows:
    • top: It is the stated top padding.
    • bottom: It is the bottom padding.
  • title: It is of type object. It describes the title of the axis which is as follows:
    • visible: It is of boolean type. It determines the visibility of the title.
    • text: It is the stated text of the title.
    • class: It is the stated CSS class of the text in the title.
    • horizontalAlignment: It is the stated horizontal alignment.
    • verticalAlignment: It is the stated vertical alignment.
  • tickMarks: It is of type object. It describes the axis’s tick marks properties which are as follows:
    • visible: It is used to determine visibility.
    • step: It is the stated step.
    • dashStyle: It is the stated dash style of the tick marks.
    • lineWidth: It is the stated line width of the tick marks.
    •  size: It is the stated size of the tick marks.
    • color: It is the stated color of the tick marks.
  • gridLines: It is of type object. It describes the grid lines properties of the axis which are as follows:
    • visible: It determines the visibility.
    • step: It is the stated step.
    • dashStyle: It is the stated dash style of the grid lines.
    • lineWidth: It is the stated line width of the grid lines.
    • color: It is the color of the grid lines.
  • line: It is of type object. It describes the line properties of the axis which are as follows:
    • visible: It is of boolean type. It determines the axis line’s visibility.
    • dashStyle: It is the dash style of the line.
    • lineWidth: It is the width of the line.
    • color: It is the color of the line.
  • labels: It is of type object. It describes the properties of the labels on the axis which are as follows:
    • visible: It determines the visibility of the labels of the axis.
    • step: It is the stated step.
    • class: It is the stated CSS class.
    • angle: It is the rotation angle of the text.
    • horizontalAligment: It is the stated horizontal alignment of the labels.
    • verticalAligment: It is the vertical alignment of the labels.
    • offset: It is the stated offset of the labels.
  • logarithmicScale: It is used to determine if the logarithmic scale needs to be used or not.
  • logarithmicScaleBase: It is the stated base for the logarithmic scale.
  • alternatingBackgroundColor: It is the stated alternating background color in between the grid lines.
  • alternatingBackgroundColor2: It is the second alternating background color between the grid lines.
  • alternatingBackgroundOpacity: It is the stated opacity of the alternating background.
  • formatSettings: It is the stated settings that are used to format the shown values.
  • formatFunction: It is the stated custom function in order to format the shown values.
  • toolTipFormatSettings: It is the stated settings that are used to format the xAxis values in tooltips.
  • toolTipFormatFunction: It is the stated custom function in order to format the xAxis values in tooltips.
  • rangeSelector: It is the stated range selector on the xAxis.

Linked Files: Download jQWidgets from the given 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>

 <script type=”text/javascript” src=”jqwidgets/jqxchart.api.js”></script>

Example 1: The below example illustrates the jQWidgets jqxChart xAxis property.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <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>
  <script type="text/javascript"
            src="jqwidgets/jqxchart.api.js">
    </script>
</head>
  
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
  
        <h3>
              jQWidgets jqxChart xAxis property
          </h3>
  
        <div id='gfg1' 
             style="width:400px; 
                    height: 200px" />
    </center>
  
    <script type="text/javascript">
        $(document).ready(function () {
            var json = [
                { Day: 'Monday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Tuesday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Wednesday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Thursday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Friday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Saturday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Sunday', A: 3, B: 1, C: 2, D: 1 }
            ];
  
            var obj = {
                title: "Coding Score",
                description: "Coding Questions Solved Daily",
                source: json,
                categoryAxis: {
                    dataField: 'Day',
                    showGridLines: true
                },
                seriesGroups: [{
                    type: 'column',
                    columnsGapPercent: 30,
                    seriesGapPercent: 0,
                    xAxis: {
                        rangeSelector: true,
                        baseUnit: 'day',
                        flip: true,
                        unitInterval: 1
                    },
                    valueAxis: {
                        minValue: 0,
                        maxValue: 10,
                        unitInterval: 10,
                        description: 'Questions Solved'
                    },
                    series: [
                        { dataField: 'A', displayText: 'A' },
                        { dataField: 'B', displayText: 'B' },
                        { dataField: 'C', displayText: 'C' },
                        { dataField: 'D', displayText: 'D' }
                    ]
                }]
            };
            $('#gfg1').jqxChart(obj);
        });
    </script>
</body>
  
</html>


Output:

 

Example 2: The following is another example of the jqxChart xAxis property in jQWidgets.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <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>
  <script type="text/javascript"
            src="jqwidgets/jqxchart.api.js">
    </script>
</head>
  
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
  
        <h3>
              jQWidgets jqxChart xAxis property
          </h3>
  
        <div id='gfg1' 
             style="width:400px; 
                    height: 200px" />
    </center>
    <center>
        <input type="button" 
               id="btn" 
               value="Click Here" 
               style="padding: 5px 14px; 
                      margin-top: 15px;">
        <br>
        <div id="log"></div>
    </center>
  
    <script type="text/javascript">
        $(document).ready(function () {
            var json = [
                { Day: 'Monday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Tuesday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Wednesday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Thursday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Friday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Saturday', A: 3, B: 1, C: 2, D: 1 },
                { Day: 'Sunday', A: 3, B: 1, C: 2, D: 1 }
            ];
  
            var obj = {
                title: "Coding Score",
                description: "Coding Questions Solved Daily",
                source: json,
                categoryAxis: {
                    dataField: 'Day',
                    showGridLines: true
                },
                seriesGroups: [{
                    type: 'column',
                    columnsGapPercent: 30,
                    seriesGapPercent: 0,
                    xAxis: {
                        rangeSelector: true,
                        baseUnit: 'day',
                        flip: true,
                        unitInterval: 1
                    },
                    valueAxis: {
                        minValue: 0,
                        maxValue: 10,
                        unitInterval: 10,
                        description: 'Questions Solved'
                    },
                    series: [
                        { dataField: 'A', displayText: 'A' },
                        { dataField: 'B', displayText: 'B' },
                        { dataField: 'C', displayText: 'C' },
                        { dataField: 'D', displayText: 'D' }
                    ]
                }]
            };
            $('#gfg1').jqxChart(obj);
            $('#btn').click(function () {
                var xa = $('#gfg1').jqxChart('xAxis');
                if (xa === null) {
                    $('#log').text("Null!");
                }
                else {
                    $('#log').text("Not null!");
                }
            });
        });
    </script>
</body>
  
</html>


Output:

 

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



Last Updated : 30 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads