我们使用 dotNETCHARTING 来描绘我们的图表,他们接受 Series
作为其 SeriesCollection
。这是我正在制作的一个新图表,所有之前的图表在显示的值和提取的值之间都有 1:1 的关系。现在我有一个值列表要显示为值列表 12:12。
我目前有 2 个数据列表(过去 12 个月的实际数据与预算数据) - 但在一个 Series
中,它们应该是 2 个 Series
。我已根据需要对数据进行了排序和列出,几乎列出正确。
限制:.NET 3.5 (VS2008)、dotNETCHARTING。
如果我必须为每个月创建 12 个 SQL 并为预算创建 12 个 SQL,这将是一个非常悲伤的解决方案。据我所知,一旦我找到一种方法将每个列表分成单独的Series
,就没有必要了。
每个模块都有一个 List
,我尝试使用 Dictionary>
以便每个值系列(12个月)可以有一个单独的列表。
我已经尝试过对于每个值列表,将列表中的每个值添加到Series
,重复直到超出值列表。 (Foreach
in a Foreach
)
我的问题是:任何人都可以给我一些可能的解决方案的指示。下图是正确的,如果没有一个接一个地排列,而是在同一时间范围(月)开始和结束。例如,一月的预算与一月的实际情况进行比较。我不是在询问 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);
}
这个逻辑是旧逻辑,应该保持原样 - 因为所有其他图表都依赖它。
可以作为参考点。考虑这个逻辑被锁定。
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;
}
这是新的逻辑,应该进行更改以反映所需的逻辑。尽可能将其视为免费。
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;
}
这是不应该的,在连续行中列出数据。尽管它显示它拥有所有必需的数据。
如果您能添加任何内容,我将不胜感激。谢谢。
We are using the dotNETCHARTING to portray our charts, they accepts Series
for their SeriesCollection
. This is a new chart I'm working on, all the previous ones have a 1:1 relation between value shown and value extracted. Now I have a list of values to show as a list of values 12:12.
I currently have my 2 lists of data showing (Actual vs Budgetted over the past 12 months) - but in a single Series
, where they should be 2 Series
. I have the data sorted and listed as needed, well almost listed right.
Restrictions: .NET 3.5 (VS2008), dotNETCHARTING.
It will be a very sad solution if I had to create 12 SQLs for each month and 12 for the budgetted. From what I see that is not necessary, as soon as I find a way to seperate each list into seperate Series
.
Each Module has a List<ModuleValue>
, I have tried with a Dictionary<int, List<ModuleValue>>
so that each series of values (12months) could have a seperate List.
I have tried the For each list of Values, add each value in the list to a Series
, repeat until out of List of values. (Foreach
in a Foreach
)
My question is: Can anyone give me some pointers to a possible solution. Graph below is per say correct, if there weren't lined up one after the other, but started and ended at the same timeframe (month). Eg budget for Jan compares to actual for Jan. I'm not asking about the dotNETCHARTING module, they have plenty of help. I'm asking for this mid-between and how it feeds the data to the module.
Main logic body:
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);
}
This logic is the old logic, should remain as is - because all the other charts rely on it.
Can be used as a point of reference. Consider this logic locked.
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;
}
This is the new Logic and should be changed to reflect the desired logic. Consider this as free as can be.
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;
}
This is how it shouldn't be, listing data in a sequal line. Though it shows it has all the required data.
I'd appreciate anything you could add. Thank you.
发布评论
评论(1)
您需要两个
Series
对象:我假设您有某种方法来测试 if 语句的点是实际的还是预算的。
You need two
Series
objects:I'm assuming you have some way of testing whether the points are actual or budgetted for the if statement.