插件效果:
下面是代码的使用:
public Text fengXianQuShi_biaoTi; //风险趋势标题
//下面是自定义的y轴文本,图表自带的y轴文本总是居中对齐,不好控制
public Text fengXianQuShi_Yaxis01;
public Text fengXianQuShi_Yaxis02;
public Text fengXianQuShi_Yaxis03;
public Text fengXianQuShi_Yaxis04;
public Text fengXianQuShi_Yaxis05;
//下面是自定义的x轴文本,图表自带的x轴,总是显示一些数值
public List<Text> fengXianQuShiList;
IEnumerator updateFengXianQuShi()
{
while (true)
{
int value = Random.Range(2, 4);
yield return new WaitForSeconds(value);
WWW www = new WWW("");
yield return www;
if (www.isDone && www.error == null)
{
left_Lit nn = JsonMapper.ToObject<left_Lit>(www.text);
if(nn.data.max_value <= 500)
{
sc.maxYValue = 500; //设置图表Y轴的最大值
}
else if (nn.data.max_value <=1000)
{
sc.maxYValue = 1000;
}
else if (nn.data.max_value <= 5000)
{
sc.maxYValue = 5000;
}
else if (nn.data.max_value <= 10000)
{
sc.maxYValue = 10000;
}
else if (nn.data.max_value <= 50000)
{
sc.maxYValue = 50000;
}else if (nn.data.max_value <= 100000)
{
sc.maxYValue = 100000;
}
else
{
sc.maxYValue = 200000;
}
fengXianQuShi_Yaxis01.text = sc.maxYValue / 4 * 0 + "";
fengXianQuShi_Yaxis02.text = sc.maxYValue / 4 * 1 + "";
fengXianQuShi_Yaxis03.text = sc.maxYValue / 4 * 2 + "";
fengXianQuShi_Yaxis04.text = sc.maxYValue / 4 * 3 + "";
fengXianQuShi_Yaxis05.text = sc.maxYValue / 4 * 4 + "";
if (nn.data.name.Count > 0) //说明有数据
{
Vector2 [] shuzu= new Vector2[nn.data.name.Count];
print(shuzu.Length);
for (int ii=0;ii< nn.data.name.Count; ii++)
{
shuzu[ii] = new Vector2(ii * 25, nn.data.total[ii]);
fengXianQuShiList[ii].text = nn.data.name[ii];
}
sc.chartData[0].data = shuzu;
fengXianQuShi_biaoTi.text = nn.title; //设置自定义的图表标题
}
}
sc.SetupValues(true);
sc.UpdateChart();
}
}
下面是监视器面板的设置:
QQ技术交流群:386476712