ZingChart更改图CSS取决于X-Scale [英] ZingChart change plot CSS depending on X-Scale

查看:113
本文介绍了ZingChart更改图CSS取决于X-Scale的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AngularJS中使用ZingChart.

I'm using a ZingChart with AngularJS.

我有一个简单的图表,但是如果过去是过去(如果x刻度日期<当前日期),我希望绘图是红色的.

I have a simple chart, but I would like my plot to be red if it's in the past (if the x-scale date < current Date).

我发现我可以设置一些特定规则

I found out that I can set some certain rules to

"plot":{
"rules":[
    {
        "rule":"%v  20 && %v < 30",
        "line-color":"#f93",
        "line-width":"8",
        "line-style":"dashed"
    },
]

如果绘图值在20到30之间,将更改css.我的问题是-> 如何更改X比例值上的绘图背景颜色DEPENDING?我无法在绘图属性上引用x比例属性.

Which is going change css if the plot values are between 20-30. My question is -> How can I change plot background color DEPENDING on the X-scale value? I am not able to refernce x-scale propery on plot property..

推荐答案

您将在寻找%scale-key-text标记,而不是%v. %scale-key-text将以scale-x轴为目标. http://www.zingchart.com/docs/basic-elements/zingchart-令牌/

You would be looking for the %scale-key-text token instead of simply the %v. %scale-key-text will target the scale-x axis. http://www.zingchart.com/docs/basic-elements/zingchart-tokens/

var myConfig = {
 	"type": "line",
 	"title":{
 	  "text":"%scale-key-value"
 	},
 	"subtitle":{
 	  "text":"the parsed value"
 	},
 	"crosshair-x":{
 	  "plot-label":{
 	    "text":"%scale-key-value: $%v",
 	    "decimals":2,
 	    "transform":{
 	      "type":"date",
 	      "all":"%g:%i %A"
 	    }
 	  },
 	  "scale-label":{
 	    "visible":false
 	  }
 	},
 	"plot":{
 	  "tooltip":{
 	    "visible":false
 	  },
 	  "rules": [
 	    {
 	      rule: "%scale-key-text > 1457116200000",
 	      lineColor: "red"
 	    }
 	    ]
 	},
 	"utc":true,
 	"timezone":-5,
 	"scale-x":{
 	  "min-value":"1457101800000",
 	  "max-value":"1457125200000",
 	  "step":"30minute",
 	  "transform":{
 	    "type":"date",
 	    "all":"%g:%i"
 	  },
 	  "label":{
 	    "text":"Trading Day"
 	  },
 	  "item":{
 	    "font-size":10
 	  }, 
 	  "max-items":14,
 	},
 	"scale-y":{
 	  "values":"30:34:1",
 	  "format":"$%v",
 	  "label":{
 	    "text":"Price"
 	  },
 	  "item":{
 	    "font-size":10
 	  }
 	},
	"series": [
		{
		  "values":[
		    [1457101800000,30.34], //03/04/2016 at 9:30 a.m. EST (which is 14:30 in GMT)
		    [1457103600000,31.30], //10:00 a.m.
		    [1457105400000,30.95], //10:30 a.m.
		    [1457107200000,30.99], //11:00 a.m.
		    [1457109000000,32.33], //11:30 a.m.
		    [1457110800000,33.34], //12:00 p.m.
		    [1457112600000,33.01], //12:30 p.m.
		    [1457114400000,34], //1:00 p.m.
		    [1457116200000,33.64], //1:30 p.m.
		    [1457118000000,32.59], //2:00 p.m.
		    [1457119800000,32.60], //2:30 p.m.
		    [1457121600000,31.99], //3:00 p.m.
		    [1457123400000,31.14], //3:30 p.m.
		    [1457125200000,32.34], //at 4:00 p.m. EST (which is 21:00 GMT)
		  ]
		}
	]
};

zingchart.render({ 
	id : 'myChart', 
	data : myConfig, 
	height: 300, 
	width: "100%"
});

<!DOCTYPE html>
<html>
	<head>
	  <script src= "https://cdn.zingchart.com/zingchart.min.js"></script>
	</head>
	<body>
		<div id='myChart'></div>
	</body>
</html>

这篇关于ZingChart更改图CSS取决于X-Scale的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆