All Components

Bullet Charts / Basic usage

mmHg
hPa
hum
temp

HTML5/JavaScript 源码

<!DOCTYPE html>
<html>
 <head> 
  <title>Basic usage</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"> 
    <table class="history"> 
     <tbody>
      <tr> 
       <td class="item">mmHg</td> 
       <td class="chart">
        <div id="chart-mmHg"></div></td> 
      </tr> 
      <tr> 
       <td class="item">hPa</td> 
       <td class="chart">
        <div id="chart-hPa"></div></td> 
      </tr> 
      <tr> 
       <td class="item">hum</td> 
       <td class="chart">
        <div id="chart-hum"></div></td> 
      </tr> 
      <tr> 
       <td class="item">temp</td> 
       <td class="chart">
        <div id="chart-temp"></div></td> 
      </tr> 
     </tbody>
    </table> 
   </div> 
   <script>
        function createChart() {
            $("#chart-mmHg").kendoChart({
                legend: {
                    visible: false
                },
                series: [{
                    type: "bullet",
                    data: [[750, 762.5]]
                }],
                chartArea: {
                    margin: {
                        left: 0
                    }
                },
                categoryAxis: {
                    majorGridLines: {
                        visible: false
                    },
                    majorTicks: {
                        visible: false
                    }
                },
                valueAxis: [{
                    plotBands: [{
                        from: 715, to: 752, color: "#ccc", opacity: .6
                    }, {
                        from: 752, to: 772, color: "#ccc", opacity: .3
                    }],
                    majorGridLines: {
                        visible: false
                    },
                    min: 715,
                    max: 795,
                    minorTicks: {
                        visible: true
                    }
                }],
                tooltip: {
                    visible: true,
                    template: "Maximum: #= value.target # <br /> Average: #= value.current #"
                }
            });

            $("#chart-hPa").kendoChart({
                legend: {
                    visible: false
                },
                series: [{
                    type: "bullet",
                    data: [[1001, 1017]]
                }],
                chartArea: {
                    margin: {
                        left: 0
                    }
                },
                categoryAxis: {
                    majorGridLines: {
                        visible: false
                    },
                    majorTicks: {
                        visible: false
                    }
                },
                valueAxis: [{
                    plotBands: [{
                        from: 955, to: 1002, color: "#ccc", opacity: .6
                    }, {
                        from: 1002, to: 1027, color: "#ccc", opacity: .3
                    }],
                    majorGridLines: {
                        visible: false
                    },
                    min: 955,
                    max: 1055,
                    minorTicks: {
                        visible: true
                    }
                }],
                tooltip: {
                    visible: true,
                    template: "Maximum: #= value.target # <br /> Average: #= value.current #"
                }
            });

            $("#chart-hum").kendoChart({
                legend: {
                    visible: false
                },
                series: [{
                    type: "bullet",
                    data: [[45, 60]]
                }],
                categoryAxis: {
                    majorGridLines: {
                        visible: false
                    },
                    majorTicks: {
                        visible: false
                    }
                },
                valueAxis: [{
                    plotBands: [{
                        from: 0, to: 33, color: "#ccc", opacity: .6
                    }, {
                        from: 33, to: 66, color: "#ccc", opacity: .3
                    }],
                    majorGridLines: {
                        visible: false
                    },
                    min: 0,
                    max: 100,
                    minorTicks: {
                        visible: true
                    }
                }],
                tooltip: {
                    visible: true,
                    template: "Maximum: #= value.target # <br /> Average: #= value.current #"
                }
            });

            $("#chart-temp").kendoChart({
                legend: {
                    visible: false
                },
                series: [{
                    type: "bullet",
                    data: [[25, 22]]
                }],
                categoryAxis: {
                    majorGridLines: {
                        visible: false
                    },
                    majorTicks: {
                        visible: false
                    }
                },
                valueAxis: [{
                    plotBands: [{
                        from: 0, to: 10, color: "yellow", opacity: .3
                    }, {
                        from: 10, to: 20, color: "orange", opacity: .3
                    }, {
                        from: 20, to: 30, color: "red", opacity: .3
                    }],
                    majorGridLines: {
                        visible: false
                    },
                    min: 0,
                    max: 30,
                    minorTicks: {
                        visible: true
                    }
                }],
                tooltip: {
                    visible: true,
                    template: "Maximum: #= value.target # <br /> Average: #= value.current #"
                }
            });
        }

        $(document).ready(createChart);
        $(document).bind("kendo:skinChange", createChart);
    </script> 
   <style>
        .history {
            border-collapse: collapse;
            width: 100%;
            margin: 0 auto;
        }
        
        .history .k-chart {
            height: 65px;            
        }

        .history td.item {
            line-height: 65px;
            width: 20px;
            text-align: right;
            padding-bottom: 22px;
        }
    </style> 
  </div>   
 </body>
</html>