0

I have many cfcharts in my application. There are 32 X-axis labels, in one of my cfcharts, but only 18 of them are displaying. Other than that, the chart displays properly, but the x-axis labels are missing.

I have used JSON style for applying styles to chart and the Items-Overlap attribute of ScaleX is set to false.

How do I display all labels in X-axis without skipping any?

Edit

 <cfchart  
        format="jpg"
        chartheight="320"  
        chartwidth="690"  showborder="yes" 
        title="Trend In Subject Rents"  style="20currency.js"  name="Qtr1">
        <cfchartseries type="line" 
            serieslabel="Gross"
            seriescolor="navy"  markerStyle="diamond" paintStyle="plain" >
            <cfloop query="qry_subproperty">
                <cfset variables.Yearquarter=ObjPropDetails.JoinYearQuarter(qry_subproperty.Yearquarter)>
                <cfchartdata item="#variables.Yearquarter#" value="#round(qry_subproperty.Gross)#" >
            </cfloop>
        </cfchartseries>
        <cfchartseries type="line" 
            serieslabel="Net"
            seriescolor="red"  markerstyle="rectangle">
            <cfloop query="qry_subproperty">
                <cfset variables.Yearquarter=ObjPropDetails.JoinYearQuarter(qry_subproperty.Yearquarter)>
                <cfchartdata item="#variables.Yearquarter#" value="#round(qry_subproperty.Net)#" >
            </cfloop>
        </cfchartseries>
        <cfchartseries type="line" 
            serieslabel="Economic"
            seriescolor="green" markerstyle="triangle">
            <cfloop query="qry_subproperty">
                <cfset variables.Yearquarter=ObjPropDetails.JoinYearQuarter(qry_subproperty.Yearquarter)>
                <cfchartdata item="#variables.Yearquarter#" value="#round(qry_subproperty.Economic)#" >
            </cfloop>
        </cfchartseries>
     </cfchart>

Edit JS Style

{
"graphset":[
    { 

       "legend":{
        "layout":"x4",
            "border-color":"#CCCCCC",
            "background-color":"#FFFFFF",
           "position":"50% 100%",
             "margin-bottom":5,
             "width":"250",

            "shadow":false,
            "adjust-layout":true,
            "item":{
                "font-family":"Arial",
                "font-size":"12px",
                "font-color":"#777878"
            }


        },

        "background-color":"#ffffff",
        "type":"mixed",
        "scale-x":{
        "items-overlap":false,
         "item":{ 

         "font-angle":90,
         "guide":{
        "visible":false
    }


    }

        },

        "scale-y":{

             "format":"$%v",
             "negation":"currency",
            "guide":{
        "visible":false
    }



        },
         "title":{

            "font-color":"#000000",
            "background-color":"#ffffff",
            "background-color-2":"#000000"
            },

     "plot":{

            "line-width" : "1px"
        },
        "series":[
           {
               "tooltip":{
      "background-color":"navy",
      "padding":"5 10",
      "border-color":"#009",
      "border-width":2,
      "border-radius":5,
      "alpha":0.75,
      "text":"The Gross Rent in this Qtr is %v ."
    }  



            },
            {
             "tooltip":{
      "background-color":"red",
      "padding":"5 10",
      "border-color":"#009",
      "border-width":2,
      "border-radius":5,
      "alpha":0.75,
      "text":"The Net Rent in this Qtr is %v ."
    }
            },
             {
             "tooltip":{
      "background-color":"green",
      "padding":"5 10",
      "border-color":"#009",
      "border-width":2,
      "border-radius":5,
      "alpha":0.75,
      "text":"The Economic Rent in this Qtr is %v ."
    }
            }



        ]
    }
]
}
Lakshmi
  • 19
  • 9
  • can you post a sample chart code and style – Alan Bullpitt Sep 22 '14 at 22:06
  • @AlanBullpitt I have posted my cf code and js Style, please see.I noticed one more thing when i changed the format of cfchart to html it displayed all x axis labels and my mouseHover also worked. But when i changed to jpg my hovers and labels didnt work as i expected.Please help me on this .It is very urgent – Lakshmi Sep 23 '14 at 11:57
  • @AlanBullpitt i need to use these chart to view in pdf.as you know the cfchart willnot display in cfdocument .But when i changed the format to jpg (and saved)then its worked inside cfdocument. – Lakshmi Sep 23 '14 at 12:06
  • Is it possible to save the cfchart same as that viewed when the the format is html to the pdf. If we can do this we don't need to change the format to jpeg and the label issue will be resolved. – Lakshmi Sep 23 '14 at 12:35
  • @AlanBullpitt Thanks for the fast reply.the below code worked.Please let me know if you are there in any blogs so that i can post my questions to you directly. Thank you very much – Lakshmi Sep 24 '14 at 14:15

1 Answers1

0

You can do it 2 ways. One is through the js style sheet but you need to know the number of xAxis items. For your example of 32 you add "max-items":"32" to the scale-x style.

"scale-x":{
        "max-items":"32",
        "items-overlap":false,
        "item":{ 
            "font-angle":90,
            "guide":{
                    "visible":false
                }
             }
}

But it sounds like you need to make this more dynamic. So you will need to determine the number of xAxis prior to creating the chart. Set this value through the xAxis attribute of cfchart like the example below.

<!--- set max-items to recordcount of qry_subproperty --->
<cfset xAxis = {"max-items":"#qry_subproperty.recordcount#"}>
<cfchart  
    format="jpg"
    chartheight="320"  
    chartwidth="690"  showborder="yes" 
    title="Trend In Subject Rents"  style="20currency.js"  name="Qtr1"  xAxis='#xAxis#'>
    <cfchartseries type="line" 
        serieslabel="Gross"
        seriescolor="navy"  markerStyle="diamond" paintStyle="plain" >
        <cfloop query="qry_subproperty">
            <cfset variables.Yearquarter=ObjPropDetails.JoinYearQuarter(qry_subproperty.Yearquarter)>
            <cfchartdata item="#variables.Yearquarter#" value="#round(qry_subproperty.Gross)#" >
        </cfloop>
    </cfchartseries>
    <cfchartseries type="line" 
        serieslabel="Net"
        seriescolor="red"  markerstyle="rectangle">
        <cfloop query="qry_subproperty">
            <cfset variables.Yearquarter=ObjPropDetails.JoinYearQuarter(qry_subproperty.Yearquarter)>
            <cfchartdata item="#variables.Yearquarter#" value="#round(qry_subproperty.Net)#" >
        </cfloop>
    </cfchartseries>
    <cfchartseries type="line" 
        serieslabel="Economic"
        seriescolor="green" markerstyle="triangle">
        <cfloop query="qry_subproperty">
            <cfset variables.Yearquarter=ObjPropDetails.JoinYearQuarter(qry_subproperty.Yearquarter)>
            <cfchartdata item="#variables.Yearquarter#" value="#round(qry_subproperty.Economic)#" >
        </cfloop>
    </cfchartseries>
 </cfchart>
Alan Bullpitt
  • 456
  • 4
  • 13
  • Can you please tell me is there any way to make the y axis more dynamic with json in coldfusion11 i have posted my question and code – Lakshmi Oct 03 '14 at 05:01