Charts

Last post 10-08-2009, 8:30 AM by Vimalsharma. 10 replies.
Sort Posts: Previous Next
  •  08-21-2009, 1:19 PM 194396

    Charts

    Attachment: Present (inaccessible)

    Hi,

    We are using aspose.cells on JAVA platform. I have two questions.

    1. I need to create a stacked column chart. It's a single column chart with no axis, single color and height and width is as shown in the attachement. When I tired to create it using aspose.cells apis, I couldn't get rid of axis and couldn't get the size of chart area as well as size of stacked column as shown in th attachment.

    2. Could aspose.cells convert a chart into image. I know .net version could do? If not, are there any plans to do it.

    Thanks,

    Vimal

     
  •  08-21-2009, 1:48 PM 194399 in reply to 194396

    Re: Charts

    Hi Vimal,

    1) Could you try to create your desired chart in MS Excel manually and post the excel file here, we will mimic the chart using Aspose.Cells for Java API.

    2) The feature is already scheduled and under process at the moment. It will take some time to complete the feature as the feature is quite complex to be implemented.

     

    Thank you.

     


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  08-21-2009, 2:49 PM 194403 in reply to 194399

    Re: Charts

    Attachment: Present (inaccessible)

    Thanks for the quick response. Please see attached excel spreadsheet with chart.

    Anytimelines on the creating image in Java?

     
  •  08-22-2009, 5:10 AM 194481 in reply to 194403

    Re: Charts

    Attachment: Present (inaccessible)

    Hi,

    Thanks for providing us template file containing your desired chart.

    I have created your desired chart for your need. I used your template file and utilized your data i.e.., "A1:B6" in Sheet1 as the chart's data source.

    May the following sample code help you get your desired chart, you may add or amend my code accordingly for your need. The output file containing the chart is also attached here for your reference.

    Sample code:

          Workbook workbook = new Workbook();
          workbook.open("e:\\files\\sample+chart.xls");

          //Define the light blue color
          Color color = new Color();
          color.setRed(51);
          color.setBlue(255);
          color.setGreen(102);


          Worksheets worksheets = workbook.getWorksheets();
          Worksheet dataSheet = worksheets.getSheet(0);
          Worksheet worksheet = worksheets.addSheet();
          worksheet.setName("Chart");

          //Create chart
          Charts charts = worksheet.getCharts();
          Chart chart = charts.addChart(ChartType.COLUMN_STACKED, 10, 5, 35, 17);

          //Set properies to chart borders.
          chart.getChartArea().getBorder().setVisible(false);
          chart.getPlotArea().getBorder().setVisible(false);
          chart.getChartArea().getArea().setForegroundColor(Color.WHITE);
          chart.getPlotArea().getArea().setForegroundColor(Color.WHITE);

          chart.getPlotArea().setWidth(1400);

          //Set properies to nseries
          NSeries nSeries = chart.getNSeries();
          nSeries.add("Sheet1!B1:B6", false);

          Cells cells = dataSheet.getCells();
          String temp = "";
          for (int i = 0; i < nSeries.size(); i ++)
          {
             temp = cells.getCell(i, 0).getStringValue();
             nSeries.get(i).setName(temp);
             nSeries.get(i).getDataLabels().setValueShown(true);
             nSeries.get(i).getDataLabels().setSeriesShown(true);
             nSeries.get(i).getChartPoints().getChartPoint(0).getBorder().setColor(Color.WHITE);
             nSeries.get(i).getChartPoints().getChartPoint(0).getArea().setForegroundColor(color);
          }

        chart.getSeriesAxis().setVisible(false);
        chart.getSeriesAxis().getMajorGridLines().setVisible(false);
        chart.getSeriesAxis().getMinorGridLines().setVisible(false);

        chart.getValueAxis().setVisible(false);
        chart.getValueAxis().getMajorGridLines().setVisible(false);
        chart.getValueAxis().getMinorGridLines().setVisible(false);

          //Set properies to categoryaxis
          CategoryAxis categoryAxis = chart.getCategoryAxis();
          categoryAxis.setMajorTickMark(TickMarkerType.NONE);
          categoryAxis.setTickLabelPosition(TickLabelPositionType.NONE);
          categoryAxis.getAxisLine().setVisible(false);

          //Set the legend off.
          chart.getLegend().setHeight(0);
          chart.getLegend().setWidth(0);

          workbook.save("e:\\files\\outChart.xls");
     
     
    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  08-26-2009, 9:17 AM 195137 in reply to 194481

    Re: Charts

    Attachment: Present (inaccessible)

    Hi,

    Thanks for the solution. I tried to implement the same to create OLE object and insert into Powerpoint. But for some reason the values are showing up little weird. Please see attached and let me know what's the issue?

    Thanks for the help.

    Vimal

     
  •  08-26-2009, 1:18 PM 195179 in reply to 195137

    Re: Charts

    Hi Vimal,

    Well, do you use Aspose.Slides for Java API to embed the chart generated by Aspose.Cells for Java as an OLE Object. If so, it might be an issue with Aspose.Slides for Java. To confirm, you may try to create the chart manually in MS Excel and later use Aspose.Slides for Java API only to embed it as an OLE Object if it still shows the values weird or not. If it shows the values fine, please create a sample console application, zip it and post it here to re-produce the issue. We will check it soon.

    Also, mention which version of Aspose.Cells for Java and Aspose.Slides for Java you are using?

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  10-07-2009, 6:39 PM 201403 in reply to 195179

    Re: Charts

    Attachment: Present (inaccessible)

    Hi,

    I am still having a issue with Chart resizing. Please see the attached zip file. It has a java class and a powerpoint template. The java class suppose to create a chart on slide 1 same as slide 2. Could please help me with it.

    Thanks,

    Vimal

     
  •  10-08-2009, 2:40 AM 201435 in reply to 201403

    Re: Charts

    Hi Vimal,

     

    Thank you for considering Aspose.

     

    Well, I tested your sample code and it seems to be some issue regarding Aspose.Slides as the chart is generated properly using Aspose.Cells APIs to an excel file. Please post your issue with complete details (code & template files) to the Aspose.Slides forum and they will check your issue and reply you soon. Please use the following link to post your issue on Aspose.Slides forum.

     

    http://www.aspose.com/community/forums/aspose.slides-product-family/109/showforum.aspx

     

    Thank You & Best Regards,


    Nausherwan Aslam
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  10-08-2009, 7:23 AM 201484 in reply to 201435

    Re: Charts

    There are two issues with the cells:

    a. The color of the bars was not right. I tried to adjust RGB value but it didn't work, it always came back as black.

    b. The values on the bars always get displayed in the middle of the bar. I need it at the end of the bar  (just outside)..

    Please help me to set the attribute so it appears exaclty like in slide 2 of the powerpoint.

    Thanks,

    Vimal

     
  •  10-08-2009, 8:11 AM 201491 in reply to 201484

    Re: Charts

    Hi,

    For your issues:

    a. The color of the bars was not right. I tried to adjust RGB value but it didn't work, it always came back as black.

    Well, since MS Excel standard color palette has only 56 colors by default and the color your are trying to set is not present on the palette, so you need to update and add your desired color to the palette first at some indexed position, see your following piece of code with an addition of a line for the method labeled "AddExcelChart()". I have tested and it works fine.

       private static int AddExcelChart(Workbook wb, int p_chartType, String p_dataSheet,int p_dataRows, int p_dataColumns,
                                    int chartRows, int chartCols) throws Exception {
            //Add a chart sheet
            System.out.println("AddExcelChart -start");
            Worksheet chartSheet = wb.getWorksheets().addSheet(SheetType.CHART);
            //Worksheet chartSheet = wb.getWorksheets().addSheet();
            chartSheet.setName("Chartsheet");
            int chartSheetIdx = chartSheet.getIndex();
            String[] alphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M" };      
           
            //Add a chart in ChartSheet with data series from DataSheet
            Charts charts = chartSheet.getCharts();     
            Chart chart = charts.addChart(ChartType.BAR_STACKED, 0, chartRows, 0, chartCols);
            chart.getChartArea().getBorder().setVisible(false);     
            chart.getPlotArea().getBorder().setVisible(false);     
            chart.getChartArea().getArea().setForegroundColor(Color.WHITE);     
            chart.getPlotArea().getArea().setForegroundColor(Color.WHITE);     
            chart.getPlotArea().setWidth(1400);
            //chart area
            chart.getChartArea().getArea().setForegroundColor(Color.WHITE);       
            chart.getChartArea().getBorder().setVisible(false);     
            chart.getChartArea().setAutoScaleFont(false);
            //chart.getChartShape().setWidth(1320);
            //chart.getChartShape().setHeight(1300);
           
            chart.getPlotArea().getArea().setForegroundColor(Color.WHITE); 
            chart.getPlotArea().getBorder().setVisible(false);
           
            //Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
            NSeries serieses = chart.getNSeries();
            Color color = new Color();
            color.setRed(0);     
            color.setGreen(104);
            color.setBlue(208);
           
            //Add the color to the MS Excel standard color palette first.
            wb.getPalette().setColor(55, color); 

           
            for (int i = 0; i < p_dataColumns; i++) {       
                System.out.println("AddExcelChart - RANGE=" + p_dataSheet + "!$" + alphabet[i] + "$" + 2 + ":$" + alphabet[i+1] + "$" + (p_dataRows+1));
                serieses.add(p_dataSheet + "!$" + alphabet[i] + "$" + 2 + ":$" + alphabet[i+1] + "$" + (p_dataRows+1) ,true);
                //    serieses.get(i).setName("Documents");
                serieses.get(i).getDataLabels().setValueShown(true);
                serieses.get(i).getDataLabels().setLabelPosition(LabelPositionType.INSIDE_BASE);
                serieses.get(i).getDataLabels().setSeriesShown(true);        
                serieses.get(i).getArea().setForegroundColor(color);
                serieses.get(i).getBorder().setColor(color);
            }

    ..................


    }     

    For further reference, see the document: http://www.aspose.com/documentation/java-components/aspose.cells-for-java/colors-and-palette.html


    b. The values on the bars always get displayed in the middle of the bar. I need it at the end of the bar  (just outside)..

    Well for this type of bar chart, there are only three data label positions: Center, Inside End and Inside Base (You may confirm it in MS Excel manually by opening the file into MS Excel and check the Format Label Position in Alignment tab). So you can choose any one for your requirements.


    Thank you.

    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
  •  10-08-2009, 8:30 AM 201504 in reply to 201491

    Re: Charts

    Thanks for your quick response Amjad. Hope, I hear equally quick response from Slides's team.
     
View as RSS news feed in XML