using System;
using System.Collections.Generic;
namespace HDL_ON.UI
{
///
/// 曲线图
///
public class EchartsOption_BrokenLine
{
///
/// x轴数据
///
public string XvalueText = "";
///
/// Y轴数据
///
public string YvalueText = "";
///
/// x轴标题
///
public string xTitle = "";
///
/// y轴标题
///
public string yTitle = "";
///
/// 组装Option数据
///
///
public string InitOption()
{
//组装Value
var newstring = optionString.Replace("{0}", XvalueText);
newstring = newstring.Replace("{1}", YvalueText);
newstring = newstring.Replace("{10}", xTitle);
newstring = newstring.Replace("{20}", yTitle);
newstring = newstring.Replace(",,",",");
return newstring;
}
///
///
///
/// 显示比例 0-100,比如设置了30,只显示30%,可以左右拖动显示其他
///
public string InitOption(int displayScale, bool isBar = false)
{
//组装Value
var newstring = optionString2.Replace("{0}", XvalueText);
newstring = newstring.Replace("{1}", YvalueText);
newstring = newstring.Replace("{10}", xTitle);
if (isBar)
{
newstring = newstring.Replace("{11}", "true");
}
else {
newstring = newstring.Replace("{11}", "false");
}
newstring = newstring.Replace("{20}", yTitle);
newstring = newstring.Replace("{30}", displayScale.ToString());
newstring = newstring.Replace(",,", ",");
return newstring;
}
///
/// 组装x轴文本
///
///
public void InitXdataText(List xData)
{
XvalueText = "";
foreach (var data in xData)
{
XvalueText += "'" + data + "',";
}
}
///
/// 组装y轴文本
///
///
public string InitYdataText(string name, List yData, string color)
{
//组装Value
yTitle = name;
string valueText = string.Empty;
var YvalueTextItem = @"{name:'{0}',
data:[{1}],
type:'line',
smooth:0.6,
symbol:'none',
color:'{2}'}
";
YvalueTextItem = YvalueTextItem.Replace("{0}", name);
foreach (var data in yData)
{
valueText += "'" + data.fieldValue + "',";
}
YvalueTextItem = YvalueTextItem.Replace("{1}", valueText);
YvalueTextItem = YvalueTextItem.Replace("{2}", color);
if (YvalueText == "")
{
YvalueText = YvalueTextItem;
}
else
{
YvalueText += "," + YvalueTextItem;
}
return YvalueTextItem;
}
///
/// 组装y轴文本
///
///
public string InitYdataText2(string name, List yData, string color, bool isBar)
{
//组装Value
yTitle = name;
string valueText = string.Empty;
var YvalueTextItem = @"{
data:[{1}],
type:'{333}',
smooth:0.6,
symbol:'none',
color:'{2}'}
";
if (isBar)
{
YvalueTextItem = YvalueTextItem.Replace("{333}", "bar");
}
else
{
YvalueTextItem = YvalueTextItem.Replace("{333}", "line");
}
YvalueTextItem = YvalueTextItem.Replace("{0}", name);
foreach (var data in yData)
{
valueText += "'" + data.fieldValue + "',";
}
YvalueTextItem = YvalueTextItem.Replace("{1}", valueText);
YvalueTextItem = YvalueTextItem.Replace("{2}", color);
if (YvalueText == "")
{
YvalueText = YvalueTextItem;
}
else
{
YvalueText += "," + YvalueTextItem;
}
return YvalueTextItem;
}
///
/// 组装y轴文本
///
///
public string InitYdataTextLinearGradient(string name, List yData, string color)
{
//组装Value
yTitle = name;
string valueText = string.Empty;
//string rColor = color.Substring(1, 2);
//string gColor = color.Substring(3, 2);
//string bColor = color.Substring(5, 2);
var YvalueTextItem = @"{name:'{0}',
data:[{1}],
smooth:0.6,
symbol:'none',
color:'{2}CC',
areaStyle: {
opacity: 0.8,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: '{2}AA'
},
{
offset: 1,
color: '{2}66'
}
])
},}
";
YvalueTextItem = YvalueTextItem.Replace("{0}", name);
foreach (var data in yData)
{
valueText += "'" + data.fieldValue + "',";
}
YvalueTextItem = YvalueTextItem.Replace("{1}", valueText);
YvalueTextItem = YvalueTextItem.Replace("{2}", color);
//YvalueTextItem = YvalueTextItem.Replace("{111}", rColor);
//YvalueTextItem = YvalueTextItem.Replace("{222}", gColor);
//YvalueTextItem = YvalueTextItem.Replace("{333}", bColor);
if (YvalueText == "")
{
YvalueText = YvalueTextItem;
}
else
{
YvalueText += "," + YvalueTextItem;
}
return YvalueTextItem;
}
#if __IOS__
public string optionString = @"{
tooltip: {
trigger: 'axis',
textStyle: {
fontSize: 30
},
padding:40,
},
grid: {
top: '10%',
left: '10%',
right: '10%',
bottom: '10%',
},
xAxis: {
name: '{10}',
nameTextStyle: {
fontSize: 30
},
type: 'category',
boundaryGap: false,
data: [{0}],
axisLabel : {
fontSize:30,
},
},
yAxis: {
name: '{20}',
nameGap:30,
nameTextStyle: {
fontSize: 30
},
type: 'value',
axisLabel : {
fontSize:30,
},
},
series: [
{1}
]
}";
#else
public string optionString = @"{
tooltip: {
trigger: 'axis'
},
grid: {
top: '15%',
left: '13%',
right: '12%',
bottom: '10%',
},
xAxis: {
type: 'category',
boundaryGap: false,
data: [{0}],
name: '{10}'
},
yAxis: {
type: 'value',
name: '{20}'
},
series: [
{1}
]
}";
#endif
#if __IOS__
public string optionString2 = @"{
tooltip: {
trigger: 'axis',
padding:40,
textStyle: {
fontSize: 30
},
},
grid: {
top: '10%',
left: '10%',
right: '10%',
bottom: '10%',
},
xAxis: {
name: '{10}',
nameTextStyle: {
fontSize: 30
},
type: 'category',
boundaryGap: {11},
data: [{0}],
axisLabel : {
fontSize:30,
},
},
yAxis: {
name: '{20}',
nameGap:30,
nameTextStyle: {
fontSize: 30
},
type: 'value',
axisLabel : {
fontSize:30,
},
},
dataZoom: [{
type: 'inside',
xAxisIndex: 0,
start: 0,
end: {30}
}],
series: [
{1}
]
}";
#else
public string optionString2 = @"{
tooltip: {
trigger: 'axis'
},
grid: {
top: '15%',
left: '13%',
right: '12%',
bottom: '10%',
},
xAxis: {
type: 'category',
boundaryGap: {11},
data: [{0}],
name: '{10}'
},
yAxis: {
type: 'value',
name: '{20}'
},
dataZoom: [{
type: 'inside',
xAxisIndex: 0,
start: 0,
end: {30}
}],
series: [
{1}
]
}";
#endif
///
/// 颜色列表
///
///
public List ColorList()
{
var list = new List();
return list;
}
}
}