• Edit
  • Download
  • <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="utf-8">
        <title>ZingSoft Demo</title>
    
        <script src="https://cdn.zingchart.com/zingchart.min.js"></script>
        <style>
            html,
            body {
                height: 100%;
                width: 100%;
                margin: 0;
                padding: 0;
            }
    
            #myChart {
                height: 100%;
                width: 100%;
                min-height: 150px;
            }
    
            #myChart-tooltip-text-float {
                position: relative;
                width: 200px;
                height: 200px;
            }
    
            #tooltip-chart {
                height: 200px;
                width: 200px;
                z-index: 5000;
                position: absolute;
                top: 0;
                left: 0;
                -webkit-box-shadow: 6px 4px 30px -3px rgba(66, 66, 66, 0.38);
                -moz-box-shadow: 6px 4px 30px -3px rgba(66, 66, 66, 0.38);
                box-shadow: 6px 4px 30px -3px rgba(66, 66, 66, 0.38);
            }
    
            .zc-ref {
                display: none;
            }
    
            zing-grid[loading] {
                height: 800px;
            }
        </style>
    </head>
    
    <body>
        <div id="myChart"><a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a></div>
        <script>
            ZC.LICENSE = ["b55b025e438fa8a98e32482b5f768ff5"];
            var colorsArray = ['#ff5722', '#4caf50', '#03a9f4', '#673ab7'];
            window.createCustomTooltip = function(e) {
                console.log(e);
    
                // destroy the old chart (garbage collection)
                zingchart.exec('tooltip-chart', 'destroy');
                // format pie data differently.
                var pieData = e['data-tooltip-values'].map(function(curVal, index) {
                    return {
                        values: [curVal],
                        backgroundColor: colorsArray[index]
                    }
                });
    
                var tooltipChartConfig = {
                    type: 'pie',
                    borderRadius: 5,
                    title: {
                        text: e.scaletext
                    },
                    plotarea: {
                        margin: '40 dynamic dynamic dynamic' // make margin and padding responsive
                    },
                    plot: {
                        cursor: 'pointer',
                        valueBox: {
                            fontColor: '#424242'
                        }
                    },
                    crosshairX: {},
                    series: pieData
                };
                // set a very small timeout. give time for the div tooltip-chart to render to the dom
                setTimeout(function() {
                    zingchart.render({
                        id: 'tooltip-chart',
                        height: '100%',
                        width: '100%',
                        data: tooltipChartConfig
                    });
                }, 50);
    
                // (OPTIONAL) return object. tooltip objectsthe text for this chart
                return {
    
                }
            }
    
            var myConfig = {
                type: 'bar',
                title: {
                    text: 'Quarterly Sales Overview'
                },
                plotarea: {
                    margin: '35 dynamic dynamic dynamic'
                },
                tooltip: {
                    htmlMode: true,
                    borderRadius: 5,
                    padding: '15 25',
                    sticky: true,
                    timeout: 5000,
                    placement: 'node:top', // node:top, node:left, node:bottom, node:right
                    backgroundColor: 'none',
                    text: '<p style="color:#fff;">overide</p><div id="tooltip-chart"> </div>',
                    jsRule: 'createCustomTooltip()'
                },
                scaleY: {
                    maxValue: 170
                },
                scaleX: {
                    labels: ['Q1', 'Q2', 'Q3', 'Q4']
                },
                series: [{
                    values: [35, 42, 67, 87],
                    dataTooltipValues: [
                        [1, 2, 3],
                        [3, 4, 5],
                        [5, 6, 7],
                        [8, 9, 10]
                    ],
                    styles: colorsArray
                }]
            };
    
    
            zingchart.render({
                id: 'myChart',
                data: myConfig,
                height: '100%',
                width: '100%'
            });
        </script>
    </body>
    
    </html>
    <!DOCTYPE html>
    <html>
    	<head>
        <meta charset="utf-8">
        <title>ZingSoft Demo</title>
    	
    		<script src="https://cdn.zingchart.com/zingchart.min.js"></script>
    </head>
    	<body>
    		<div id="myChart"><a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a></div>
    	</body>
    </html>
    html, body {
    	height:100%;
    	width:100%;
    	margin:0;
    	padding:0;
    }
    #myChart {
    	height:100%;
    	width:100%;
    	min-height:150px;
    }
    #myChart-tooltip-text-float {
      position:relative;
      width:200px;
      height:200px;
    }
    #tooltip-chart {
      height:200px;
      width:200px;
      z-index:5000;
      position:absolute;
      top:0;
      left:0;
      -webkit-box-shadow: 6px 4px 30px -3px rgba(66,66,66,0.38);
    -moz-box-shadow: 6px 4px 30px -3px rgba(66,66,66,0.38);
    box-shadow: 6px 4px 30px -3px rgba(66,66,66,0.38);
    }
    .zc-ref {
    	display:none;
    }
    var colorsArray =  ['#ff5722','#4caf50','#03a9f4','#673ab7'];
    window.createCustomTooltip = function(e) {
      console.log(e);
      
      // destroy the old chart (garbage collection)
      zingchart.exec('tooltip-chart', 'destroy');
      // format pie data differently.
      var pieData = e['data-tooltip-values'].map(function(curVal, index) {
        return {
          values: [curVal],
          backgroundColor:colorsArray[index]
        }
      });
      
      var tooltipChartConfig = {
        type: 'pie',
        borderRadius:5,
        title: {
          text: e.scaletext
        },
        plotarea: {
          margin: '40 dynamic dynamic dynamic' // make margin and padding responsive
        },
        plot: {
          cursor: 'pointer',
          valueBox: {
            fontColor: '#424242'
          }
        },
        crosshairX:{},
        series:pieData
      };
      // set a very small timeout. give time for the div tooltip-chart to render to the dom
      setTimeout(function() {
        zingchart.render({
          id: 'tooltip-chart',
          height:'100%',
          width:'100%',
          data: tooltipChartConfig
        });
      }, 50);
      
      // (OPTIONAL) return object. tooltip objectsthe text for this chart
      return {
     
      }
    }
     
    var myConfig = {
     	type: 'bar',
     	title: {
     	  text: 'Quarterly Sales Overview'
     	},
     	plotarea: {
     	  margin: '35 dynamic dynamic dynamic'
     	},
     	tooltip: {
     	  htmlMode: true,
     	  borderRadius: 5,
     	  padding: '15 25',
     	  sticky: true,
     	  timeout: 5000,
     	  placement: 'node:top', // node:top, node:left, node:bottom, node:right
     	  backgroundColor: 'none',
        text: '<p style="color:#fff;">overide</p><div id="tooltip-chart"> </div>',
     	  jsRule: 'createCustomTooltip()'
     	},
     	scaleY :{
     	  maxValue:170
     	},
     	scaleX: {
     	  labels: ['Q1', 'Q2', 'Q3', 'Q4']
     	},
    	series: [
    		{
    			values: [35,42,67, 87],
    			dataTooltipValues: [[1,2,3], [3,4,5], [5,6,7], [8,9,10]],
    			styles: colorsArray
    		}
    	]
    };
     
     
    zingchart.render({ 
    	id: 'myChart', 
    	data: myConfig, 
    	height: '100%', 
    	width: '100%' 
    });