Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3997396
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:23:48+00:00 2026-05-20T07:23:48+00:00

OK, so I’m using LINQ to generate a tag cloud based on tags in

  • 0

OK, so I’m using LINQ to generate a tag cloud based on tags in my database. I have a problem that I really can’t seem to figure out. The first time I add a tag, it displays in the biggest font (36pt) – I guess because of the % value calculated, weight takes on the value of 100 and is passed to GetTagSize(). Is there a way to place an if statement where I’m doing this: weight = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
to check for count of 1 and display the smallest font? Thanks for your help!

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 = (double)tagGroup.Count() / maxTagFrequencyNegative * 100
                   };

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";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:23:49+00:00Added an answer on May 20, 2026 at 7:23 am

    Try:

    weight = (tagGroup.Count() == 1) ? (double)1 : (double)tagGroup.Count() / maxTagFrequencyNegative * 100
    

    I’m not sure if this is exactly what you need, but essentially you could use the conditional operator to work around the issue. The first param would be the smallest font, didn’t know what represents it so I set it at 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have a view passing on information from a database: def serve_article(request, id): served_article

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.