如何从Kendo条形图/柱形图中删除水平GridLines?

时间:2019-01-18 17:41:11

标签: kendo-ui kendo-chart

我想从图表背景中删除水平网格线。我能够成功删除垂直网格线。

enter image description here

majorGridLines: { visible: false}隐藏y轴的网格线。 如果我使用相同的代码隐藏xAxes网格线,则不会隐藏它。

<html>
<head>
    <base href="https://demos.telerik.com/kendo-ui/bar-charts/multiple-axes">
    <style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
    <title></title>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.common-material.min.css" />
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.material.min.css" />
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.material.mobile.min.css" />

    <script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jquery.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script>


</head>
<body>
<div id="example">
    <div class="demo-section k-content wide">
        <div id="chart"></div>
    </div>
    <script>
        function createChart() {
            $("#chart").kendoChart({
                majorGridLines: {
                    visible: false,
                },
                legend: {
                    position: "bottom"
                },
                series: [ {
                    type: "column",
                    data: [2989, 270, 420, 890, 910, 1394, 1444],
                    stack: true,
                    name: "Room Revenue",
                    color: "#4472c3",
                    majorGridLines: {
                    visible: false,
                },
                },  {
                    type: "line",
                    data: [23, 5, 6, 22, 20, 16, 40],
                    name: "Room Sold",
                    color: "#12ccbe",
                    axis: "l100km",
                    majorGridLines: {
                    visible: false,
                },
                }],
                valueAxes: [{
                    title: { text: "miles" },
                    min: 0,
                    max: 4000,
                  visible: false,
                }, {
                   // name: "km",
                   // title: { text: "km" },
                    min: 0,
                    max: 161,
                    majorUnit: 32,
                  visible: false
                }, {
                   // name: "mpg",
                   // title: { text: "miles per gallon" },
                   // color: "#ec5e0a"
                  visible: false
                }, {
                    name: "l100km",
                  //  title: { text: "liters per 100km" },
                    color: "#4e4141",
                  visible: false
                }],
                majorGridLines: {
                    visible: false,
                },
                categoryAxis: {
                    categories: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
                   majorGridLines: {
                    visible: false,
                },
                }
            });
        }

        $(document).ready(createChart);
        $(document).bind("kendo:skinChange", createChart);
    </script>
</div>


</body>
</html>

2 个答案:

答案 0 :(得分:1)

您只是将majorGridLine设置放在错误的位置。将其放在valueAxis中:

 function createChart() {
        $("#chart").kendoChart({
            legend: {
                position: "bottom"
            },
            series: [ {
                type: "column",
                data: [2989, 270, 420, 890, 910, 1394, 1444],
                stack: true,
                name: "Room Revenue",
                color: "#4472c3",
            },  {
                type: "line",
                data: [23, 5, 6, 22, 20, 16, 40],
                name: "Room Sold",
                color: "#12ccbe",
                axis: "l100km",
            }],
            valueAxes: [{
                title: { text: "miles" },
                min: 0,
                max: 4000,
                visible: false,
                majorGridLines: {
                  visible: false,
                },
            }, {
               // name: "km",
               // title: { text: "km" },
                min: 0,
                max: 161,
                majorUnit: 32,
                visible: false,
                majorGridLines: {
                  visible: false,
                },
            }, {
               // name: "mpg",
               // title: { text: "miles per gallon" },
               // color: "#ec5e0a"
               visible: false,
               majorGridLines: {
                 visible: false,
               },
            }, {
                name: "l100km",
              //  title: { text: "liters per 100km" },
                color: "#4e4141",
               visible: false,
                majorGridLines: {
                   visible: false,
                },
            }],               
            categoryAxis: {
               categories: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
               majorGridLines: {
                visible: false,
                },
            }
        });
    }

DEMO

答案 1 :(得分:0)

您尝试在下面使用吗?
yAxis:{     majorGridLines:{       颜色:“#aa00bb”,       宽度:3,       可见:错误     }   }