2

I am using CFCHART to display a basic horizontal bar chart, but the result is showing only every second label on the Y-AXIS as shown in the below screenshot. I noticed this is happening only on queries with many lines and it doesn't help if I increase the height of the bars. Even when they are huge, the labels on the Y-AXIS are 1, 3, 5, etc. Every second row.

enter image description here

The code I am using is this:

<cfchart 
            format="#chart_format#"
            chartWidth="#width#"
            chartHeight="#getCustomersBySalesReps.RecordCount * 35#"
            show3D = "#show3D#"
            showlegend="no"
        >
            <cfchartseries 
                query       = "getCustomersBySalesReps" 
                type        = "horizontalbar" 
                itemColumn  = "name" 
                valueColumn = "value"
                dataLabelStyle = "value"
                seriesLabel = "name"
            >
            </cfchartseries>
        </cfchart>
  • 1
    Try using the scale attribute [`itemsOverlap: true`](https://help.zingsoft.com/en/articles/3546391-zingchart-how-to-show-all-labels-on-my-axis) in conjunction with `max-items`. Demo https://trycf.com/gist/80457e780dc503c5655d30d28ec146ef/acf2018?theme=monokai – SOS Aug 24 '21 at 10:07
  • Yes, you're right. It's exactly how I solved the problem and I just posted the solution. Thank you for your help! – Adrian Ciocălău Aug 25 '21 at 11:47
  • Cool, glad it helped! – SOS Aug 25 '21 at 18:27

1 Answers1

1

This is how I solved the problem:

<cfset xAxis = {"max-items":"#getCustomersBySalesReps.RecordCount#","items-overlap":true}>
            <cfchart 
                format="#chart_format#"
                chartWidth="#width#"
                chartHeight="#getCustomersBySalesReps.RecordCount * 35#"
                show3D = "#show3D#"
                showlegend="no"
                xAxis = '#xAxis#'
            >
                <cfchartseries 
                    query       = "getCustomersBySalesReps" 
                    type        = "horizontalbar" 
                    itemColumn  = "name" 
                    valueColumn = "value"
                    dataLabelStyle = "value"
                    seriesLabel = "name"
                >
                </cfchartseries>
            </cfchart>