jquery - Kendo UI - 并排显示图表

标签 jquery css kendo-ui

我必须做什么才能并排显示所有图表?

我试着把它插入

"div class="row"

但它不起作用。

因此我构建了一个 little example on JSFiddle :

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.common.min.css">
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.dataviz.min.css">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.kendostatic.com/2014.3.1411/js/kendo.all.min.js"></script>              
</head>
<body>
    <div class="k-content">
        <div id="example_1"></div>
        <div id="example_2"></div>
        <div id="example_3"></div>
        <div id="example_4"></div>
        <div id="example_5"></div>
    </div>

<script>
    var seriesData = [{
        productname: "Product One",
        volume: 65.50
    }];

    $(document).ready(function() {
    // -----------------------------------------------------------------------
    function createChart(ChartType, Placeholder, MaxValue) {

        $("#" + Placeholder).kendoChart({   
            theme: "metro",
            title: {
                font: "12px Arial,Helvetica,sans-serif",
                color: "#29952D",
                text: "Name: " + Placeholder
            },
            dataSource: {
                data: seriesData
            },          
            seriesDefaults: {
                labels: {
                    template: "#=kendo.format('{0:n2}', (Math.abs(value)))# ltr",
                    position: "outsideEnd",
                    visible: true,
                    background: "transparent"
                }
            },                              
            series: [{
                type: ChartType, 
                field: "volume",
                categoryField: "productname",
            }],     
            valueAxis: [{
                min: 0,
                max: MaxValue
            }],
            chartArea: {
                width: 125,
                height: 175                 
            },
            tooltip: {
                template: "#=kendo.format('{0:n2}', (Math.abs(value)))# ltr",               
                visible: true
            },
        }) // kendoChart
    } // function
    // -------------------------------------------------------------------          
    createChart("column", "example_1", 200);    
    createChart("column", "example_2", 250);
    createChart("column", "example_3", 300);
    createChart("column", "example_4", 100);
    createChart("pie", "example_5", 450);
    // -----------------------------------------------------------------------
    }); // $(document).ready(function()
</script>       

</body>
</html>

最佳答案

您可以使用 css float: leftwidth: 20%(同时从图表中删除宽度设置并让它填充 div):

<div class="k-content">
    <div id="example_1" class="sidebyside"></div>
    <div id="example_2" class="sidebyside"></div>
    <div id="example_3" class="sidebyside"></div>
    <div id="example_4" class="sidebyside"></div>
    <div id="example_5" class="sidebyside"></div>
</div>

.sidebyside {
    width: 20%;
    float: left;
}

Updated FIDDLE

关于jquery - Kendo UI - 并排显示图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33758805/

相关文章:

javascript - 如何使所有浏览器以相同的行为和外观从相同的 css 呈现

javascript - 使用 jQuery 在 <div> 中汇总表单

javascript - 从读取它的回调函数外部访问 json 字符串

html - 为什么文本在移动设备上显示符号?

html - 自上次 chrome 更新以来,我的 HTML 输入字段默认为 "readonly"

c# - Kendo MVC Core - 网格 - 无法通过路线获取数据 - 400 错误请求

jquery - Materialise 多选选项支持使用 jquery 最多进行四次选择

html - css 滚动/触摸幻灯片 View - 如何使用 -ms-scroll-snap 等?

javascript - 带有 Kendo UI 的 AngularJS 每个都给出 "TypeError: Object [object Object] has no method ''”

javascript - 使用内联编辑和自定义编辑器下拉控件的 Kendo Grid