3 Replies Latest reply: Apr 13, 2012 8:02 AM by BKBK RSS

    Stacked Bar Chart Issue

    berniemiller Community Member

      Hello, with ColdFusion 8 this code produces duplicate stacked bars. The two chartseries are required to produce the stacked affect. One bar stack is labeled "Programs" and the second is labeled "Enrolled Programs". They are identical and both contain the data I wish to display so obviously I only want one of them. Suggestions? Thanks.

       

      <cfchart format="flash" showlegend="yes"

            chartheight="350"

            chartwidth="350"

            showxgridlines="no"

            showygridlines="no" 

            showborder="no"

            fontsize="12"

            fontbold="no"

            fontitalic="no"

            xaxistitle=""

            yaxistitle="Count"

            show3d="yes"

            rotated="no"

            sortxaxis="no"

            showmarkers="yes" seriesplacement="stacked">

            <cfchartseries type="bar" query="qAllProgramsCount" seriescolor="blue" itemcolumn="title" valuecolumn="prgCount" serieslabel="Programs" >

            <cfchartseries type="bar" query="qEnrolled" seriescolor="red" itemcolumn="title" valuecolumn="prgCount" serieslabel="Enrolled Programs" >  

      </cfchart>

        • 1. Re: Stacked Bar Chart Issue
          berniemiller Community Member

          It never fails that as soon as I post a question I figure it out...anyway, it was differenciating on the "title" in my two queries. I made them the same and viola, one bar! Hope this helps someone.

          • 2. Re: Stacked Bar Chart Issue
            berniemiller Community Member

            I also figured out that the query data must be arranged in columns not rows. At first I had the values for each stack piece on a separate row. This would work for a single bar but adding multiple bars would just duplicate the first. The trick was each bar should be a single row with each piece of the stack a separate column. Once I put the survey response counts into columns I could feed the query into the chartseries like so and I got the desired stacked bar chart for each subquestion.

             

            <cfchartseries type="bar" query="qChartData" seriescolor="red" itemcolumn="subquestion" valuecolumn="disagree" serieslabel="Disagree" > </cfchartseries>

            <cfchartseries type="bar" query="qChartData" seriescolor="yellow" itemcolumn="subquestion" valuecolumn="somewhatagree" serieslabel="Somewhat Agree"></cfchartseries>     

            <cfchartseries type="bar" query="qChartData" seriescolor="green" itemcolumn="subquestion" valuecolumn="agree"  serieslabel="Agree" ></cfchartseries>

            <cfchartseries type="bar" query="qChartData" seriescolor="blue" itemcolumn="subquestion" valuecolumn="stronglyagree" serieslabel="Strongly Agree" ></cfchartseries>

            • 3. Re: Stacked Bar Chart Issue
              BKBK CommunityMVP

              berniemiller wrote:

               

              It never fails that as soon as I post a question I figure it out...anyway, it was differenciating on the "title" in my two queries. I made them the same and viola, one bar! Hope this helps someone.

              It surely will, if you mark the question as answered!