DeepthiRH
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by DeepthiRH
-
-
Hello,
I am not able to set the size of the chart (for eg i wnat a smaller chart). I tried using setHeight and width but that didnt work.
I also want to remove the outer border , setting gaps to 0 doesnt seem to help.
If anyone is aware of these things ,please help me out.
Thanks in advance.
Gap between the Y axis and chart
in Chart
Posted
Hello,
All the charts in chartfx seem to have a small gap between the Y axis and the actual chart.
Am working on an area chart.
How can i take out the gap between the Y axis and the area chart so that the chart Sticks to Y axis.
Below is my code:
The set height and width also doesnot seem to work. Please help me out
List<MarketDTO> chartList = (List<MarketDTO>) request
.getAttribute("chart");chart1.getAxisY().setAutoScale(false);Axis yaxis = chart1.getAxisY();
chart1.setGallery(Gallery.AREA);
chart1.setGrid(ChartGrid.HORZ | ChartGrid.VERT);
chart1.getSeries(0).setColor(java.awt.Color.red);
chart1.openData(COD.VALUES, 1, chartList.size());
//Find the max value to plot the Y axis and also get the chart points to plot the area graphlong maxValue = 0;long minValue = 0;MarketDTO chartDTO = chartList.get(i);
chart1.getAxisY().getTitle().setText(
"NSC Price List");chart1.setInsideColor(new java.awt.Color(66, 66, 66));chart1.setBackColor(java.awt.Color.white);
chart1.setBorder(false);chart1.setImgSizeable(true);chart1.setImgHeight(100);
chart1.setImgWidth(100);
chart1.setHeight(100);
chart1.setWidth(100);
chart1.setLeftGap(0);
chart1.setRightGap(0);
chart1.setBottomGap(0);
chart1.setTopGap(0);
Long chartValue = chartDTO.getClosePrice();
if (chartValue > maxValue)maxValue = chartValue;
if (i == 0)minValue = chartValue;
if (chartValue < minValue)minValue = chartValue;
chart1.setValue(1, i, chartValue);
} else {chart1.getAxisX().getTitle().setText(
"Time");chart1.getAxisY().getTitle().setText("BSC Price List");chart1.setInsideColor(new java.awt.Color(192, 192, 192));chart1.setBackColor(java.awt.Color.magenta);
chart1.setBorder(false);Long chartValue = chartDTO.getPrice();
maxValue = chartValue;
if (i == 0)minValue = chartValue;
if (chartValue < minValue)minValue = chartValue;
chart1.setValue(1, i, chartValue);
}
}
temp = (
int) Math.round(maxValue);int mod = 0;mod = temp % 100;
int maxresult = 0;if (mod == 0) {maxresult = temp;
} else if (mod != 0) {maxresult = temp - mod + 100;
}
//to round off minValue nearest min hundredint temp1 = 0;temp1 = (
int) Math.round(minValue);int mod1 = 0;mod1 = temp1 % 100;
int minresult = 0;if (mod1 == 0) {minresult = temp1;
} else if (mod1 != 0) {minresult = temp1 - mod1;
}
int setRange = 0;setRange = (maxresult - minresult) / 4;
out.flush();
out.write(minresult);
yaxis.setMin(minresult);
yaxis.setMax(maxresult);
yaxis.setStep(setRange);
chart1.closeData(COD.VALUES);
// Assign all labels (this will help in tooltips)
java.util.Date dateTime = new java.util.Date();java.util.GregorianCalendar cal = new java.util.GregorianCalendar();{
int hr=cal.get(cal.HOUR);if(hr>=10 || hr<11){chart1.getLegend().setItem(j, java.text.DateFormat.getTimeInstance(3).format(dateTime));
cal.setTime(dateTime);
cal.add(java.util.Calendar.MINUTE,8);
dateTime = cal.getTime();
// Set the X axis
chart1.getAxisX().setFirstLabel((short) 1); //chart1.getAxisX().setMin(10);chart1.getAxisX().setStep((short) 2); //chart1.getAxisX().setMinorStep((short) 4);chart1.getAxisX().setFont(new java.awt.Font("Verdana",java.awt.Font.ROMAN_BASELINE,9));}
else if(hr>=11 || hr<1){chart1.getLegend().setItem(j, java.text.DateFormat.getTimeInstance(3).format(dateTime));
cal.setTime(dateTime);
cal.add(java.util.Calendar.MINUTE,20);
dateTime = cal.getTime();
// Set the X axis
chart1.getAxisX().setFirstLabel((short) 1); //chart1.getAxisX().setMin(10);chart1.getAxisX().setStep((short) 5); //chart1.getAxisX().setMinorStep((short) 4);chart1.getAxisX().setFont(new java.awt.Font("Verdana",java.awt.Font.ROMAN_BASELINE,9));}
else{chart1.getLegend().setItem(j, java.text.DateFormat.getTimeInstance(3).format(dateTime));
cal.setTime(dateTime);
cal.add(java.util.Calendar.MINUTE,20);
dateTime = cal.getTime();
// Set the X axis
chart1.getAxisX().setFirstLabel((short) 1); //chart1.getAxisX().setMin(10);chart1.getAxisX().setStep((short) 20); //chart1.getAxisX().setMinorStep((short) 4);chart1.getAxisX().setFont(new java.awt.Font("Verdana",java.awt.Font.ROMAN_BASELINE,9));}
}
chart1.setOutputWriter(w);
%>
<%=
chart1.getHtmlTag("450", "280","FLASH")%>Thanks,
Deepthi