你好,我使用SpreadChart做图表,添加了1个柱状图、2个折线图。
柱状图的最小值和最大值相关太大时,Y轴会出现非常多的刻度线,如下图
请问这些线可以以隐藏吗,或者设置成和背景相同的颜色
附上代码:
//柱状图
BarSeries bar = new BarSeries();
bar.YAxisId = 0;
bar.LabelVisible = true;
//最大工作时间折线图
LineSeries maxLine = new LineSeries();
maxLine.PointMarker = new BuiltinMarker(MarkerShape.Diamond, 2.0F);
maxLine.YAxisId = 0;
maxLine.LabelVisible = false;
maxLine.LineBorder = new SolidLine(Color.Red,1.5F);
//定时工作时间折线图
LineSeries stdLine = new LineSeries();
stdLine.PointMarker = new BuiltinMarker(MarkerShape.Diamond, 2.0f);
stdLine.YAxisId = 0;
stdLine.LabelVisible = false;
stdLine.LineBorder = new SolidLine(Color.Orange, 1.5f);
for (int x = 2; x < _myTblData.Columns.Count; x++)
{
var dc = _myTblData.Columns[x];
var that = data.FirstOrDefault(s => s.WORK_DATE == Convert.ToDateTime(dc.ColumnName) && s.DATA_TYPE == type);
if (that != null)
{
bar.Values.Add(Convert.ToDouble(ToHours(that.WORK_TIME_ACT)));
stdLine.Values.Add(Convert.ToDouble(ToHours(that.WORK_TIME_STD)));
maxLine.Values.Add(Convert.ToDouble(ToHours(that.WORK_TIME_MAX)));
}
else
{
bar.Values.Add(0);
stdLine.Values.Add(0);
maxLine.Values.Add(0);
}
}
//折线图设置
ValueAxis axisConfig = new ValueAxis();
axisConfig.AxisId = 1;
axisConfig.AutoMaximum = true;
axisConfig.AutoMinimum = true;
//隐藏折线图Y轴
axisConfig.LabelVisible = false;
axisConfig.Location = AxisLocation.Far;
//Y绘图区
YPlotArea plotArea = new YPlotArea();
plotArea.Location = new PointF(0, 0.19F);
plotArea.Size = new SizeF(1, 0.8F);
plotArea.Series.Add(bar);
plotArea.Series.Add(stdLine);
plotArea.Series.Add(maxLine);
//隐藏左边Y轴标尺
plotArea.YAxes[0].RulerLine = new NoLine();
//隐藏X轴下的数字
plotArea.XAxis.LabelVisible = false;
plotArea.XAxis.RulerLine = new NoLine();
//隐藏柱状图Y轴数字
plotArea.YAxes[0].LabelVisible = false;
plotArea.YAxes.Add(axisConfig);
ChartModel model = new ChartModel();
model.PlotAreas.Add(plotArea);
var chart = new FarPoint.Win.Spread.Chart.SpreadChart();
chart.CanMove = FarPoint.Win.Spread.DrawingSpace.Moving.None;
chart.CanSize = FarPoint.Win.Spread.DrawingSpace.Sizing.None;
chart.Size = new Size((_mySheet.ColumnCount - 2) * 30, _spanRowHeight * 4);
int chartY = Convert.ToInt32((_oneAreaMiniRows + type.Count()) * _rowHeihgt) + (_oneAreaMiniRows + type.Count) * 2 + 2;
if (i > 0)
{
chartY = chartY + Convert.ToInt32(_spanRowHeight * 4 + 1);
}
chart.Location = new Point(_spreadCol1HeaderWidth * 2, chartY);
chart.Model = model;
_mySpread.ActiveSheet.Charts.Add(chart);