📄 stackbargraph3d.cs
字号:
// Disclaimer and Copyright Information
// StackBarGraph3D.cs :
//
// All rights reserved.
//
// Written by Pardesi Services, LLC
// Version 1.01
//
// Distribute freely, except: don't remove our name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to
// softomatix@CommonComponent.com
///////////////////////////////////////////////////////////////////////////////
//
using System;
using System.Diagnostics;
using System.Drawing;
using System.Collections;
namespace CommonComponent.CommonChart
{
/// <summary>
///
/// </summary>
public class StackBarGraph3D : CommonChart.BarGraph3D
{
public StackBarGraph3D()
{
this.m_GraphType = Type.StackBarGraph3D;
this.m_QuadrantToShow = QuadrantType.Quad1;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
override protected bool DrawData()
{
//TODO: For now we will process only first array of data list. Later
// on implementation needs to take into account that there may
// be more than one list.
ArrayList dataList = (ArrayList)this.m_obIslandList[0];
if (null == dataList || dataList.Count == 0)
{
throw new Exception("There is no data list present in the array.");
}
int nCount = dataList.Count;
CalculateBarWidth(nCount);
CalculateBarHeightScale();
if (this.UseRandomColors)
{
ColorUtil.GenerateRandomColors(nCount, out m_arrColors);
}
else
{
ColorUtil.GenerateColorValues(this.Colors, out m_arrColors);
}
int nStartX = (int)(this.m_ChartAxis.Origin.X + m_fIslandSpacing/2.0F);
PointF pt = new PointF();
double dThickness = this.m_iYAxisSpan * 0.05;
int nHeight = 0;
int nWidth = 0;
for (int nIdx = 0; nIdx < this.m_obDataIslandNodes.Count; nIdx++)
{
ArrayList obIslandDataList = (ArrayList)this.m_obIslandList[nIdx];
nCount = obIslandDataList.Count;
pt.Y = this.m_ChartAxis.Origin.Y;
pt.X = (int)(nStartX + nIdx*(this.m_fIslandWidth + this.m_fIslandSpacing));
for (int i = 0; i < nCount; i++)
{
Color fillColor = (Color)this.m_arrColors[i];
SolidBrush obBrush = new SolidBrush(fillColor);
GraphDataObject obData = (GraphDataObject)obIslandDataList[i];
if (null != obData)
{
// First draw the front rectangle.
nHeight = (int)(obData.Y * this.m_dBarHeightScale);
nWidth = (int)this.m_dDrawBarWidth;
pt.Y -= nHeight;
this.DrawBar(this.m_obGraphics, (int)pt.X, (int)pt.Y, nWidth, nHeight, dThickness, fillColor);
}
obBrush.Dispose();
}
}
return true;
}
/// <summary>
///
/// </summary>
/// <param name="barCount"></param>
/// <returns></returns>
override protected bool CalculateBarWidth(int barCount)
{
// Now we need to calculate data about islands.
CalculateIslandDrawData();
m_dDrawBarWidth = m_dEqualBarWidth = this.m_fIslandDrawWidth;
// TODO: Provide attribuye to set the spacing between bars.
// For now its fixed to about 85% of the width.
m_dDrawBarWidth *= 0.85;
return true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -