using System;
using System.Collections.Generic;
namespace HDL_ON.UI
{
public class EchartsOption_Histogram
{
///
/// x轴数据
///
private string XvalueText = "";
///
/// Y轴数据
///
private string YvalueText = "";
///
/// x轴标题
///
public string xTitle = "";
///
/// y轴标题
///
public string yTitle = "";
public EchartsOption_Histogram()
{
}
///
/// 组装Option数据
///
///
public string InitOption()
{
//组装Value
var newstring = optionString.Replace("{xData}", XvalueText);
newstring = newstring.Replace("{yData}", YvalueText);
newstring = newstring.Replace("{xName}", xTitle);
newstring = newstring.Replace("{yName}", yTitle);
newstring = newstring.Replace(",,", ",");
return newstring;
}
///
/// 组装x轴文本
///
///
public void InitXdataText(List xData)
{
XvalueText = "";
foreach (var data in xData)
{
XvalueText += "'" + data + "',";
}
}
///
/// 组装y轴文本
///
///
public string InitYdataText(List yData)
{
YvalueText = "";
foreach (var data in yData)
{
YvalueText += "'" + data.fieldValue + "',";
}
return YvalueText;
}
#if __ANDROID__
public string optionString = @"{
tooltip: {
trigger: 'axis',
axisPointer: {
crossStyle: {
color: '#999'
}
}
},
grid: {
top: '10%',
left: '15%',
right: '15%',
bottom: '10%',
},
xAxis: {
data: [{xData}],
axisTick: {
show: false
},
axisLine: {
show: false
},
name:'{xName}',
nameGap:5,
nameTextStyle:{
color:'#7C8590',
fontSize:10
},
axisLabel: {
color: '#7C8590',
fontSize:10
}
},
yAxis: {
name:'{yName}',
nameGap:12,
nameTextStyle:{
color:'#030D1C',
fontSize:10
},
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
color: '#7C8590',
fontSize:10
}
},
dataZoom: [
{
type: 'inside'
}
],
series: [
{
type: 'bar',
showBackground: false,
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: '#6AB7F9' },
{ offset: 0.5, color: '#5AA6FF' },
{ offset: 1, color: '#6B97F9' }
])
},
data: [{yData}]
}
]
}";
#else
public string optionString = @"{
tooltip: {
trigger: 'axis',
axisPointer: {
crossStyle: {
color: '#999'
}
}
},
grid: {
top: '10%',
left: '10%',
right: '10%',
bottom: '10%',
},
xAxis: {
data: [{xData}],
axisTick: {
show: false
},
axisLine: {
show: false
},
name:'{xName}',
nameTextStyle:{
color:'#7C8590',
fontSize:24
},
axisLabel: {
color: '#7C8590',
fontSize:20
}
},
yAxis: {
name:'{yName}',
nameGap:35,
nameTextStyle:{
color:'#030D1C',
fontSize:24
},
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
color: '#7C8590',
fontSize:20
}
},
dataZoom: [
{
type: 'inside'
}
],
series: [
{
type: 'bar',
showBackground: false,
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: '#6AB7F9' },
{ offset: 0.5, color: '#5AA6FF' },
{ offset: 1, color: '#6B97F9' }
])
},
data: [{yData}]
}
]
}";
#endif
}
}