From: Vikram R. <VikramR@PLANETASIA.COM> - 2003-08-26 13:55:16
|
Pal, w.r.t. to the axis labels, there is a length allocated to each label and jCharts calculates whether all labels can be fitted into the charts. If not, the labels are displayed selectively - alternate labels may be displayed, or every third label may be displayed, or every fourth ... depending on the size of the label. The size of the label is a function of the font size, font and the number of characters in the label string. There is a code submission in the developer's list which will help you get around the label problem by truncating labels and appending a "..." to them. It will also let you image map the label text so that when the user does a mouse over on the label, the complete string will be displayed. hope this helps, Vikram -----Original Message----- From: Pal Perinbam [mailto:pal...@ya...] Sent: Tuesday, August 26, 2003 7:07 PM To: jch...@li... Subject: [jCharts-users] Problems in Barchart and Line Chart Hi, As I told you earlier, I herewith send the code sample. Please run this by setting font size in the code. We are using Jcharts to generate charts for our project. We have a problem while printing the charts. The charts are fine on the screen but when we print that it looks blurred. We suspect it may be due to the Jpeg encoding. We encode the chart object into jpeg image using the Jpegencoder13 provided with jcharts. Is there a way to create BMP or any other high quality image from jcharts, or can we improve image quality by some other means. We also face another problem. When we increase the X Axis label font size of a line chart or bar chart, most of the Xaxis labels disappear. I've attached a sample to simulate this. In the below Sample. the chart is fine when the font size is 10, but when it is changed to 11 the labels disappear. Expecting your earliest reply. import org.jCharts.properties.LegendProperties; import org.jCharts.properties.ChartProperties; import org.jCharts.properties.util.ChartStroke; import org.jCharts.properties.util.ChartFont; import org.jCharts.properties.BarChartProperties; import org.jCharts.properties.AxisProperties; import org.jCharts.properties.DataAxisProperties; import org.jCharts.chartData.AxisChartDataSet; import org.jCharts.chartData.interfaces.IAxisDataSeries; import org.jCharts.chartData.DataSeries; import org.jCharts.axisChart.AxisChart; import org.jCharts.types.ChartType; import org.jCharts.encoders.JPEGEncoder13; import java.awt.Color; import java.awt.Paint; import java.awt.Font; import java.awt.BasicStroke; import java.io.FileOutputStream; class createBarChart { public static void main(String[] args) { try { int fontSize=10; //Font Size int width = 300; int height = 200; LegendProperties legendProperties=null; ChartProperties chartProperties = new ChartProperties(); AxisProperties axisProperties = new AxisProperties( false ); FileOutputStream objFOS = new FileOutputStream("mychart.jpg"); ChartFont axisScaleFont = new ChartFont( new Font( "Arial", Font.PLAIN,fontSize), Color.black ); ChartStroke CSAxis = new ChartStroke(new BasicStroke(1.0f),Color.black); axisProperties.getXAxisProperties().setScaleChartFont(axisScaleFont); axisProperties.getXAxisProperties().setShowEndBorder(false); axisProperties.getXAxisProperties().setPaddingBetweenXAxisLabels(0f); axisProperties.getXAxisProperties().setAxisStroke(CSAxis); axisProperties.getXAxisProperties().setShowGridLines(DataAxisProperties.GRID _LINES_NONE); axisProperties.getYAxisProperties().setScaleChartFont(axisScaleFont); axisProperties.getYAxisProperties().setShowEndBorder(false); axisProperties.getYAxisProperties().setAxisStroke(CSAxis); axisProperties.getYAxisProperties().setShowGridLines(DataAxisProperties.GRID _LINES_NONE); String title=null; String[] legendLabels = {" "}; Paint[] paints = new Paint[]{Color.blue}; double[][] data = new double[][]{{2.4305638 , 76.2283304 , 59.5653992 , 12.9185693 , -94.4018601 , 41.8006188 , 45.009868 , -63.0464611 , 0.4272433 , 17.0886599 , 48.8614666 , 89.5960671 , 44.107602 , 1.8919965 , -22.7345809 , 97.4517988 , 95.248644 , 58.0654687 , 82.1011746 , 36.7686102 , 25.6530842 , 60.0724961 , -93.1170484 , 23.6652036 , 37.0968087 , 48.8910213 , 79.85264 , 53.9105076, 95.248644 , 58.0654687 , 82.1011746 , 36.7686102 , 59.5653992 , 12.9185693 , -94.4018601 , 41.8006188, 0.4272433 , 17.0886599 , 48.8614666 , 89.5960671}}; String[] xAxisLabels = {"93"," "," "," ","94"," "," "," ","95"," "," "," ","96"," "," "," ","97"," "," "," ","98"," "," "," ","99"," "," "," ","00"," "," "," ","01"," "," "," ","02"," "," "," "}; DataAxisProperties dataAxisProperties = (DataAxisProperties) axisProperties.getYAxisProperties(); dataAxisProperties.setUserDefinedScale(-100,50); dataAxisProperties.setNumItems(5); dataAxisProperties.setShowZeroLine(true); BarChartProperties barChartProperties = new BarChartProperties(); barChartProperties.setShowOutlinesFlag(false); String xAxisTitle = null; String yAxisTitle = null; IAxisDataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title ); dataSeries.addIAxisPlotDataSet( new AxisChartDataSet( data, legendLabels, paints, ChartType.BAR, barChartProperties ) ); AxisChart axisChart = new AxisChart( dataSeries, chartProperties, axisProperties, legendProperties, width, height ); JPEGEncoder13.encode( axisChart, 1.0f, objFOS ); } catch( Exception exp ) { exp.printStackTrace(); } } } Thanks, Pal _____ Do you Yahoo!? SBC <http://pa.yahoo.com/*http://rd.yahoo.com/evt=1207/*http://promo.yahoo.com/s bc/> Yahoo! DSL - Now only $29.95 per month! |