C# 我需要从一个系列转到两个系列
我们使用dotNETCHARTING来描绘我们的图表,他们接受C# 我需要从一个系列转到两个系列,c#,.net,charts,logic,C#,.net,Charts,Logic,我们使用dotNETCHARTING来描绘我们的图表,他们接受系列的系列集合。这是我正在研究的一个新图表,所有以前的图表在显示的值和提取的值之间都有1:1的关系。现在,我有一个值列表,显示为12:12的值列表 我目前有两个数据列表(过去12个月的实际数据与预算数据),但都是在一个系列中,它们应该是2个系列。我已经根据需要对数据进行了分类和列出,几乎正确地列出了这些数据 限制:.NET 3.5(VS2008),点网络图表 如果我必须为每个月创建12个SQL,为预算中的项目创建12个SQL,这将是一
系列
的系列集合
。这是我正在研究的一个新图表,所有以前的图表在显示的值和提取的值之间都有1:1的关系。现在,我有一个值列表,显示为12:12的值列表
我目前有两个数据列表(过去12个月的实际数据与预算数据),但都是在一个系列中,它们应该是2个系列
。我已经根据需要对数据进行了分类和列出,几乎正确地列出了这些数据
限制:.NET 3.5(VS2008),点网络图表
如果我必须为每个月创建12个SQL,为预算中的项目创建12个SQL,这将是一个非常悲哀的解决方案。从我所看到的情况来看,这是不必要的,只要我找到一种方法将每个列表分成单独的系列
每个模块都有一个列表
,我尝试使用字典
,这样每个系列的值(12个月)都可以有一个单独的列表
我已经尝试了针对每个值列表,将列表中的每个值添加到系列
,重复此操作,直到超出值列表。(Foreach
中的Foreach
)
我的问题是:谁能给我一些可能的解决方案的建议。如果不是一个接一个地排列,而是在同一时间段(月)开始和结束,下面的图表是正确的。1月份的预算与1月份的实际情况相比,我不是在问dotNETCHARTING模块,他们有很多帮助。我要问的是中间层,以及它是如何将数据提供给模块的
主要逻辑体:
protected override void CreateChildControls()
{
base.CreateChildControls();
//_chart.Type = ChartType.Combo;
_chart.DefaultSeries.Type = SeriesType.Line;
// Up for change - between here
IList listSeries = new List();
listSeries.Add(GetSeries(_module)); // This line should be listSeries = GetMultipleSeries(_module); or to that effect.
foreach (var series in listSeries)
{
_chart.SeriesCollection.Add(series);
}
// Up for change - and here
// This shows the title above the chart:
_chart.Title = _module.Title;
// This shows the title below the chart:
//_chart.XAxis.Label = new Label(_module.Title);
_chart.TitleBox.Line.Color = Charter.BackgroundColor;
base.SetAreaStyles();
base.SetLinkUrl(_module.LinkUrl);
}
受保护的覆盖无效CreateChildControls()
{
base.CreateChildControls();
//_chart.Type=ChartType.Combo;
_chart.DefaultSeries.Type=SeriesType.Line;
//在这里换车
IList listSeries=新列表();
Add(GetSeries(_module));//这一行应该是listsseries=GetMultipleSeries(_module);或者是这样。
foreach(listSeries中的var系列)
{
_图表.系列集合.添加(系列);
}
//等待改变——在这里
//这显示了图表上方的标题:
_chart.Title=\u module.Title;
//这显示了图表下方的标题:
//_chart.XAxis.Label=新标签(_module.Title);
_chart.TitleBox.Line.Color=Charter.BackgroundColor;
base.SetAreaStyles();
base.SetLinkUrl(_module.LinkUrl);
}
这个逻辑是旧的逻辑,应该保持原样,因为所有其他图表都依赖它。
可作为参考点。考虑这个逻辑被锁定。
protected Series GetSeries(FrontModule module)
{
Series series = new Series(module.Title);
foreach (var value in module.Values)
{
string sFieldTitle = value.Text;
Element element = new Element(sFieldTitle, value.Value);
element.Color = Charter.GetColor(value.ColorIndex);
series.Elements.Add(element);
string sToolTip = string.Format
("{0}: {1:N0}"
, value.Tooltip
, value.Value);
element.ToolTip = sToolTip;
if (!string.IsNullOrEmpty(value.LinkUrl))
{
element.URL = Page.ResolveUrl(value.LinkUrl);
}
ChartTooltip += string.Concat(sToolTip, ", ");
}
ChartTooltip += "\n";
return series;
}
受保护系列GetSeries(FrontModule)
{
系列=新系列(模块名称);
foreach(module.Values中的var值)
{
字符串sFieldTitle=value.Text;
元素=新元素(sFieldTitle,value.value);
element.Color=Charter.GetColor(value.ColorIndex);
系列。元素。添加(元素);
string stoottip=string.Format
(“{0}:{1:N0}”
,value.Tooltip
,价值。价值);
element.ToolTip=stootip;
如果(!string.IsNullOrEmpty(value.LinkUrl))
{
element.URL=Page.ResolveUrl(value.LinkUrl);
}
ChartTooltip+=string.Concat(stoottip,“,”);
}
图表工具提示+=“\n”;
返回序列;
}
这是新的逻辑,应进行更改以反映所需的逻辑。认为这是免费的。
protected List GetMultipleSeries(FrontModule module)
{
List listSeries = new List();
Series series = new Series(module.Title);
foreach (var keyPair in module.DictionaryValues)
{
string sFieldTitle = keyPair.Value.Text;
Element element = new Element(sFieldTitle, keyPair.Value.Value);
element.Color = Charter.GetColor(keyPair.Value.ColorIndex);
series.Elements.Add(element);
string sToolTip = string.Format
("{0}: {1:N0}"
, keyPair.Value.Tooltip
, keyPair.Value.Value);
element.ToolTip = sToolTip;
if (!string.IsNullOrEmpty(keyPair.Value.LinkUrl))
{
element.URL = Page.ResolveUrl(keyPair.Value.LinkUrl);
}
ChartTooltip += string.Concat(sToolTip, ", ");
}
listSeries.Add(series);
ChartTooltip += "\n";
return listSeries;
}
受保护列表GetMultipleSeries(FrontModule)
{
List listSeries=新列表();
系列=新系列(模块名称);
foreach(模块中的var密钥对。字典值)
{
字符串sFieldTitle=keyPair.Value.Text;
元素=新元素(sFieldTitle,keyPair.Value.Value);
element.Color=Charter.GetColor(keyPair.Value.ColorIndex);
系列。元素。添加(元素);
string stoottip=string.Format
(“{0}:{1:N0}”
,keyPair.Value.Tooltip
,keyPair.Value.Value);
element.ToolTip=stootip;
如果(!string.IsNullOrEmpty(keyPair.Value.LinkUrl))
{
element.URL=Page.ResolveUrl(keyPair.Value.LinkUrl);
}
ChartTooltip+=string.Concat(stoottip,“,”);
}
添加(系列);
图表工具提示+=“\n”;
返回列表系列;
}
这是不应该的,在sequal行中列出数据。虽然它显示它拥有所有必需的数据
如果你能补充什么,我将不胜感激。谢谢。您需要两个系列
对象:
protected List GetMultipleSeries(FrontModule module)
{
List listSeries = new List();
Series seriesActual = new Series(module.Title);
Series seriesBudgetted = new Series(module.Title);
foreach (var keyPair in module.DictionaryValues)
{
string sFieldTitle = keyPair.Value.Text;
Element element = new Element(sFieldTitle, keyPair.Value.Value);
element.Color = Charter.GetColor(keyPair.Value.ColorIndex);
// Is is actual or budgetted
if (keyPair.Value.IsActual)
seriesActual.Elements.Add(element);
else
seriesBudgetted.Elements.Add(element);
string sToolTip = string.Format
("{0}: {1:N0}"
, keyPair.Value.Tooltip
, keyPair.Value.Value);
element.ToolTip = sToolTip;
if (!string.IsNullOrEmpty(keyPair.Value.LinkUrl))
{
element.URL = Page.ResolveUrl(keyPair.Value.LinkUrl);
}
ChartTooltip += string.Concat(sToolTip, ", ");
}
listSeries.Add(seriesActual);
listSeries.Add(seriesBudgetted);
ChartTooltip += "\n";
return listSeries;
}
我假设您有某种方法来测试if语句中的点是实际的还是预算的。Ohh u'r在那里说了些什么。让我来测试一下。多斯塔夫:很高兴我能帮上忙。