我试图用指令制作双y轴的混合图。
对于双Y轴,您遵循‘scale-y-2’模式,但它在我的AngularJS应用程序中不起作用。有人知道如何在星图中渲染两个y轴吗?
发布于 2015-12-29 23:02:58
在角指令中向ZingChart添加多尺度的y‘s与香草JavaScript相同。
首先,您需要确保在图表中包含"scale-y-2":{} object。min:max:step值应该继承您的系列值,但如果需要,可以显式设置它。
接下来,您需要确保将每一组系列值关联到适当的标度-y。要做到这一点,包括一个“刻度”:“属性”。这将接受带有两个逗号分隔值的字符串。您需要声明要与该系列相关联的标度-x和规模-y。
目前,ZingChart不接受scaleY2的camel大小写值。这必须用JSON表示为"scale-y-2“。
下面的代码应该为您提供所需的东西。我已经提供了评论,你很可能在你的图表中遗漏了哪些行。
如果您希望看到一个活动的示例,您可以运行下面的代码。
var app = angular.module('myApp',['zingchart-angularjs']);
app.controller('MainController', function($scope){
$scope.myJson = {
globals : {
shadow: false
},
type : 'bar',
plot:{
},
backgroundColor : "#fff",
scaleY :{
lineColor : "#BDBFC1",
lineWidth: "2px",
tick:{
lineWidth: "0px"
}
},
"scale-y-2" : { //add scale-y-2
},
scaleX :{
lineColor : "#BDBFC1",
lineWidth: "2px",
tick:{
lineWidth: "0px"
}
},
series : [
{
values : [54,23,34,23,43],
scales: "scale-x, scale-y", //associate scales to series
lineColor : "#D2262E",
lineWidth : "2px",
marker : {
backgroundColor: "#D2262E",
borderWidth : "0px"
}
},
{
values : [1000,1500,1600,2000,4000],
lineColor : "#2FA2CB",
scales: "scale-x, scale-y-2", //associate scales to series
lineWidth : "2px",
marker : {
backgroundColor: "#2FA2CB",
borderWidth : "0px"
}
},
]
};
});html,body{
margin: 0px;
}<script src="http://cdn.zingchart.com/zingchart.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="http://cdn.zingchart.com/angular/zingchart-angularjs.js"></script>
<body ng-app="myApp">
<div ng-controller="MainController">
<div zingchart id="chart-1" zc-json="myJson" zc-width="100%" zc-height="568px"></div>
</div>
</body>
注:我是ZingChart团队的一员。如果你还有其他问题,请告诉我。
https://stackoverflow.com/questions/33753024
复制相似问题