关于dojox图表X轴标签

时间:2016-08-01 10:16:44

标签: dojox.charting

我的 x轴数据是过去24小时,我想标记小时。对于带有“0”的小时值,我想用更大的字体大小显示它并用Date标记它。有没有办法设置x轴的标签样式? 我的代码就像打击一样:

<!DOCTYPE html>
<html >
<head>


    <link rel="stylesheet"  href="http://localhost/arcgis_js_api/library/3.14/3.14/dijit/themes/claro/claro.css">

    <script>var dojoConfig = {
        parseOnLoad:true,
        packages: [{
            "name": "myModules",
            "location": location.pathname.replace(/\/[^/]+$/, "") + "/"
        }]
    };
    </script>
    <script src="http://localhost/arcgis_js_api/library/3.14/3.14/init.js" data-dojo-config="isDebug: 1, async: 1, parseOnLoad: 1" charset="utf-8"></script>
    <script>
        require(["dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/Lines", "dojo/ready"],
                function(Chart, Default, Lines, ready){
                    ready(function(){
                        var chart1 = new Chart("simplechart", {
                            title: "压力",
                            titlePos: "top"});
                        chart1.addPlot("default", {type: Lines, labels: true,labelStyle: "outside", labelOffset: 25,Stroke:{color: "blue", width: 1},markers: true});
                        chart1.addAxis("x",{ majorLabels: true, majorTicks: true,
                            minorLabels: true, minorTicks:true, minorTick:{length:1},
                            microTicks: true,
                            majorTickStep:12,
                            minorTickStep:1,

                            labels: [{value: 1, text: "10"}, {value: 2, text: "11",length:"20"},
                                {value: 3, text: "12"}, {value: 4, text: "0"},
                                {value: 5, text: "May"}, {value: 6, text: "Jun"},
                                {value: 7, text: "Jul"}, {value: 8, text: "Aug"},
                                {value: 9, text: "Sep"}, {value: 10, text: "Oct"},
                                {value: 11, text: "Nov"}, {value: 12, text: "Dec"}]
                        });

                        chart1.addAxis("y", {vertical: true,microTickStep:1});
                        chart1.addSeries("Series 1", [{x: 1, y: 5}, {x: 2, y: 1.7},
                            {x: 3, y: 9}, {x: 4, y: 3}],{plot: "default", stroke: {color:"blue"}});
                        chart1.render();
                    });
                });
    </script>
</head>
<body class="claro">
<div id="simplechart" style="width: 250px; height: 150px; margin: 5px auto 0px auto;"></div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您可以使用主题更改轴样式。如果您想为不同的轴使用不同的主题,请使用轴的类型属性。

this.addAxis("y", {type: "Wetland",
                  vertical: true,
                  } 
             );

Wetland是dojo / dojox / charting / themes中主题的名称 那里有很多主题。但是如果它们都不能满足你,你可以通过修改一些默认值来创建自己的主题。

您不能仅在其中一个轴标签上设置特定样式。即,轴的所有标签都具有相同的样式。