From: Pal P. <pal...@ya...> - 2003-08-26 13:37:25
|
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 Yahoo! DSL - Now only $29.95 per month! |