Available in the Full Version

Data Chart - Category Tooltip Layer

This sample demonstrates the Category Tooltip Layer that displays grouped tooltips for series that use a category axis. The sample options pane allows you to edit the properties of the layer, such as changing the position of the tooltip.

Category Item Highlight Options
Transition Duration
Use Interpolation
Tooltip Position:

Population data from:
U.S. Census Bureau

This sample is designed for a larger screen size.

On mobile, try rotating your screen, view full size, or email to another device.

Code View

Copy to Clipboard
<!DOCTYPE html>
<html>
<head>
    <title>Category Tooltip Layer</title>

    <!-- Ignite UI for jQuery Required Combined CSS Files -->
    <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/infragistics.css" rel="stylesheet" />
    
    <!--CSS file specific for chart styling -->
    <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/modules/infragistics.ui.chart.css" rel="stylesheet" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <!-- Ignite UI for jQuery Required Combined JavaScript Files -->
    <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.dv.js"></script>

</head>
<body>
    <style type="text/css">
    	.sliderBounds {
    	   width: 95px;
    	   margin: 6px 3px 6px 6px;
			display: inline-block;
    	}
    	.optionContainer {
    	   width: 200px;
    	   margin: 2px;
			padding: 2px;
			display: inline-block;
			border: 1px solid #e0e0e0;
			-moz-border-radius: 4px;
			-webkit-border-radius: 4px;
			border-radius: 4px;
    	}
    	.selectBounds {
    	   min-width: 120px;
    	   max-width: 132px;
    	}
    </style>

    <div id="chart"></div>
    <br/>
    
    <div>
        <fieldset id="chartOptions">
            <legend>Category Item Highlight Options</legend>
            

            <div class="optionContainer">
                Transition Duration
                <div id="transitionDurationSlider" class="sliderBounds"></div>
                <label id="transitionDurationLabel">150</label>
            </div>
            
            <div class="optionContainer">
                <input type="checkbox" id="useInterpolationCheckBox" />Use Interpolation
            </div>
            
            <div class="optionContainer" >
                Tooltip Position:
                <select id="tooltipPos">
                    <option value="auto" selected="selected">auto</option>
                    <option value="outsideEnd">outsideEnd</option>
                    <option value="outsideStart">outsideStart</option>
                    <option value="insideStart">insideStart</option>
                    <option value="insideEnd">insideEnd</option>
                </select>
            </div>

        </fieldset>
    </div>


    <br/>
    
    <div class="USCensus-attribution">
        Population data from:<br />
        <a href="http://www.census.gov/" target="_blank">U.S. Census Bureau</a>
    </div>

    <script>
        $(function () {

            var data = [
                { "CountryName": "China", "Pop1995": 1216, "Pop2005": 1297, "Pop2015": 1361, "Pop2025": 1394 },
                { "CountryName": "India", "Pop1995": 920, "Pop2005": 1090, "Pop2015": 1251, "Pop2025": 1396 },
                { "CountryName": "United States", "Pop1995": 266, "Pop2005": 295, "Pop2015": 322, "Pop2025": 351 },
                { "CountryName": "Indonesia", "Pop1995": 197, "Pop2005": 229, "Pop2015": 256, "Pop2025": 277 },
                { "CountryName": "Brazil", "Pop1995": 161, "Pop2005": 186, "Pop2015": 204, "Pop2025": 218 }
            ];

            $("#chart").igDataChart({
                width: "100%",
                height: "400px",
                title: "Population per Country",
                subtitle: "A comparison of population in 1995 and 2005",
                dataSource: data,
                axes: [
                    {
                        name: "NameAxis",
                        type: "categoryX",
                        title: "Country",
                        label: "CountryName"
                    },
                    {
                        name: "PopulationAxis",
                        type: "numericY",
                        minimumValue: 0,
                        title: "Millions of People",
                    }
                ],
                series: [
                    {
                        name: "2005Population",
                        type: "column",
                        title: "2005 Population",
                        xAxis: "NameAxis",
                        yAxis: "PopulationAxis",
                        valueMemberPath: "Pop2005",
                        isTransitionInEnabled: true,
                        isHighlightingEnabled: true,
                        showTooltip: true
                    },
                    {
                        name: "1995Population",
                        type: "column",
                        title: "1995 Population",
                        xAxis: "NameAxis",
                        yAxis: "PopulationAxis",
                        valueMemberPath: "Pop1995",
                        isTransitionInEnabled: true,
                        isHighlightingEnabled: true,
                        showTooltip: true
                    },
                    {
                        name: "categorySeries",
                        type: "categoryToolTipLayer",
                        useInterpolation: false,
                        transitionDuration: 150
                    }]
            });

            //Transition Duration Slider
            $("#transitionDurationSlider").slider({
                min: 0,
                max: 1000,
                value: 150,
                step: 50,
                slide: function (event, ui) {
                    $("#chart").igDataChart("option", "series", [{ name: "categorySeries", transitionDuration: ui.value }]);
                    $("#transitionDurationLabel").text(ui.value);
                }
            });

            //Use Interpolation
            $("#useInterpolationCheckBox").click(function (e) {
                var useInterpolationResult = $("#useInterpolationCheckBox").is(":checked") ? true : false;
                $("#chart").igDataChart("option", "series", [{ name: "categorySeries", useInterpolation: useInterpolationResult }]);
            });
            
            $("#tooltipPos").change(function (e) {
               var position = $(this).val();
               $("#chart").igDataChart("option", "series", [{ name: "categorySeries", toolTipPosition: position }]);
                
            });
            
        });
    </script>
</body>
</html>