All Components

Chart API / Methods

API Functions

refresh() will be called on each configuration change

HTML5/JavaScript 源码

<!DOCTYPE html>
<html>
 <head> 
  <title>Methods</title> 
  <meta charset="utf-8"> 
  <link href="../content/shared/styles/examples-offline.css" rel="stylesheet"> 
  <link href="../../styles/kendo.common.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.rtl.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.default.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.default.min.css" rel="stylesheet"> 
  <script src="../../js/jquery.min.js"></script> 
  <script src="../../js/kendo.all.min.js"></script> 
  <script src="../content/shared/js/console.js"></script> 
  <script>
        
    </script> 
 </head> 
 <body> 
  <a class="offline-button" href="../index.html">Back</a> 
  <div id="example"> 
   <div class="demo-section k-content wide"> 
    <div id="chart"></div> 
   </div> 
   <div class="box wide"> 
    <div class="box-col"> 
     <h4>API Functions</h4> 
     <ul class="options"> 
      <li> <input id="typeColumn" name="seriesType" type="radio" value="column" checked autocomplete="off"> <label for="typeColumn">Columns</label> </li> 
      <li> <input id="typeBar" name="seriesType" type="radio" value="bar" autocomplete="off"> <label for="typeBar">Bars</label> </li> 
      <li> <input id="typeLine" name="seriesType" type="radio" value="line" autocomplete="off"> <label for="typeLine">Lines</label> </li> 
      <li> <input id="stack" type="checkbox" autocomplete="off" checked> <label for="stack">Stacked</label> </li> 
     </ul> 
     <p> <strong>refresh()</strong> will be called on each configuration change </p> 
    </div> 
   </div> 
   <script>
        var series = [{
            name: "Total Visits",
            data: [56000, 63000, 74000, 91000, 117000, 138000],

            // Line chart marker type
            markers: { type: "square" }
        }, {
            name: "Unique visitors",
            data: [52000, 34000, 23000, 48000, 67000, 83000]
        }];

        function createChart() {
            $("#chart").kendoChart({
                title: {
                    text: "Site Visitors Stats /thousands/"
                },
                legend: {
                    position: "bottom"
                },
                seriesDefaults: {
                    type: "column",
                    stack: true
                },
                series: series,
                valueAxis: {
                    line: {
                        visible: false
                    }
                },
                categoryAxis: {
                    categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
                    majorGridLines: {
                        visible: false
                    }
                },
                tooltip: {
                    visible: true,
                    format: "{0}"
                }
            });
        }

        $(document).ready(function() {
            createChart();
            $(document).bind("kendo:skinChange", createChart);
            $(".options").bind("change", refresh);
        });

        function refresh() {
            var chart = $("#chart").data("kendoChart"),
                type = $("input[name=seriesType]:checked").val(),
                stack = $("#stack").prop("checked");

            for (var i = 0, length = series.length; i < length; i++) {
                series[i].stack = stack;
                series[i].type = type;
            };

            chart.setOptions({
                series: series
            });
        }
    </script> 
  </div>   
 </body>
</html>