这让我疯了.我根据%值显示基于数据库中标签计数的标签云.我注意到,当一个标签被重新启动时,相关的字体大小很大(因为100%被检索),所以有人建议我这样做:
var tagSummaryNegative = from af in db.AgileFactors
join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
join s in db.Stories on psf.StoryID equals s.StoryID
join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
join pro in db.Projects on it.ProjectID equals pro.ProjectID
where pro.ProjectID == pro_id &&
pro.ProjectID == it.ProjectID &&
it.ProjectIterationID == pim.ProjectIterationID &&
pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
s.StoryID == psf.StoryID &&
psf.AgileFactorID == af.AgileFactorID
group af by af.Name into tagGroup
select new
{
Tag = tagGroup.Key,
tagCount = tagGroup.Count()
};
int maxTagFrequencyNegative = (from t in tagSummaryNegative select (int?)t.tagCount).Max() ?? 0;
var tagCloudNegative = from af in db.AgileFactors
join psf in db.ProjectStoryFactors on af.AgileFactorID equals psf.AgileFactorID
join s in db.Stories on psf.StoryID equals s.StoryID
join pim in db.ProjectIterationMembers on s.ProjectIterationMemberID equals pim.ProjectIterationMemberID
join it in db.Iterations on pim.ProjectIterationID equals it.ProjectIterationID
join pro in db.Projects on it.ProjectID equals pro.ProjectID
where pro.ProjectID == pro_id &&
pro.ProjectID == it.ProjectID &&
it.ProjectIterationID == pim.ProjectIterationID &&
pim.ProjectIterationMemberID == s.ProjectIterationMemberID && s.StoryCategoryID == 1 &&
s.StoryID == psf.StoryID &&
psf.AgileFactorID == af.AgileFactorID
group af by af.Name into tagGroup
select new
{
Tag = tagGroup.Key,
**weight = (tagGroup.Count() == 1) ? (double)1 : ((double)tagGroup.Count() / maxTagFrequencyNegative * 100)**
};
Run Code Online (Sandbox Code Playgroud)
现在,当count为1时,字体很小,但是当它为2时,它又回到了巨大的状态.具有较小计数的标签相对于具有最大计数的标签变小 - 但我需要它从小开始并继续增长.请帮忙!
public string GetTagSize(double weight)
{
if (weight >= 99)
return "36pt";
else if (weight >= 80)
return "29pt";
else if (weight >= 64)
return "23pt";
else if (weight >= 48)
return "18pt";
else if (weight >= 32)
return "14pt";
else if (weight >= 10)
return "11pt";
else
return "8pt";
}
Run Code Online (Sandbox Code Playgroud)
尝试使用
int expectedSize = 36; //Or whatever the max size should be
double size = weight / tagGroup.count();
size = max(0, min(size, 1); //bounds size to between 1 and 0 just incase
//I'm assuming tagGroup.count() returns the number of tags. replace this as need
size = size * expectedSize;
return (int)size + "pt";
Run Code Online (Sandbox Code Playgroud)
这个想法是,您获得 1 到 0 之间的标签的相对大小,然后将其乘以预期大小。
希望有帮助
| 归档时间: |
|
| 查看次数: |
937 次 |
| 最近记录: |