|
yAxis repeating ticks |
Posted by Rich on Mar-26-2014 04:19 |
|
Hi,
Can you help me understand why the primary Y Axis (left) is repeating values?
I have a similar chart with nearly identical dataset and it is not doing it, I know I am over looking something silly.
I've attached a screenshot of the chart, and below is my code.
Thanks!
Rich
<cfscript>
cd = CreateObject("java", "ChartDirector.CFChart");
labels = variables.FailureCatLabels;
for (i = 1; i LTE ListLen(variables.keylist); i = i + 1)
if (i EQ 1)
lineData = cd.ArrayMath(#variables['dataSet' & i]#);
else
lineData.add(#variables['dataSet' & i]#);
//accumulate the data
lineData.acc();
scaleFactor = lineData.max() / 100;
if (scaleFactor EQ 0) {
// Avoid division by zero error for zero data
scaleFactor = 1;
}
lineData.div2(scaleFactor);
c = cd.XYChart(#variables.ChartWidth#, 550);
title = c.addTitle("Failure Category Analysis", "Arial Bold", 12);
title.setMargin2(0, 0, 12, 0);
c.addLegend(50, title.getHeight(), False, "Arial", 8).setBackground(cd.Transparent);
c.setPlotArea(50, 60, c.getWidth() - 100, c.getHeight() - 100);
lineLayer = c.addLineLayer2();
lineLayer.addDataSet(lineData.result(), "0x000000").setDataSymbol(cd.CircleShape, 7, "0x000000", "0x000000");
lineLayer.setLineWidth(1);
lineLayer.setUseYAxis2();
lineLayer.setHTMLImageMap("", "", "title='Top {={x}+1} items: {value|2}%'");
barLayer = c.addBarLayer2(cd.Stack);
barLayer.setBarGap(0.5);
for (i = 1; i LTE ListLen(variables.keylist); i = i + 1)
barlayer.addDataSet(#variables['dataSet' & i]#, -1, #variables['dataSetNames' & i]#);
barLayer.setBorderColor(cd.Transparent, cd.softLighting(cd.Right));
barLayer.setHTMLImageMap("", "", "title='{xLabel}: {value} occurrences in {dataSetName}'");
c.xAxis().setLabels(labels);
c.xAxis().setLabelStyle("Arial","8","000000","45");
if (scaleFactor LE 0.04) {
c.yAxis2().setLinearScale(0, 100, 1 / scaleFactor);
c.yAxis2().setLabelFormat("{value|0}%");
c.yAxis().setLinearScale(0, 100 * scaleFactor, 1);
} else {
c.yAxis2().setLinearScale(0, 100, 20);
}
c.yAxis2().setLabelFormat("{value}%");
c.yAxis().setLabelFormat("{value|0}");
c.yAxis().setTitle("Frequency", "Times New Roman Bold Italic", 12);
c.yAxis2().setTitle("Cumulative Percentage", "Times New Roman Bold Italic", 12);
c.xAxis().setColors(cd.Transparent);
c.yAxis().setColors(cd.Transparent);
c.yAxis2().setColors(cd.Transparent);
c.packPlotArea(10, title.getHeight() + c.layoutLegend().getHeight(), c.getWidth() - 10, c.getHeight() - 20);
chart1URL = c.makeSession(GetPageContext(), "chart1", cd.JPG);
imageMap1 = c.getHTMLImageMap("index.cfm?drill=byCat&xlabelFrom=Catattributes.SelectedParams#");
</cfscript>
|
Re: yAxis repeating ticks |
Posted by Peter Kwan on Mar-27-2014 01:51 |
|
Hi Rich,
The label values on the y-axis are 0, 0.2, 0.4, 0.6, 0.8, 1.0, .... Because you format the
numbers with 0 decimal place, so the formatted text string is 0, 0, 0, 1, 1, 1, ....
Note that formatting a number only affects the visual display of the number. It would not
change the number of labels (just like formatting a field in an SQL query would not change
the number of rows returned). If you want the y-axis labels to be at most 1 unit apart,
please use:
c.yAxis().setMinTickInc(1);
Hope this can help.
Regards
Peter Kwan |
Re: yAxis repeating ticks |
Posted by Rich on Mar-27-2014 01:57 |
|
Peter,
Thank you very much. That resolved my issue.
Thanks again!
Rich |
|