I’m attempting to format a pie chart and am having trouble with some of the classes and methods. I’m using coldfusion in junction with the Java API. Below is the code I’m using to create the chart, and below the code are some of my questions.
//Adding NSeries (chart data source) to the chart ranging from “A1” cell to “B3” series = chart.getNSeries(); series.add(“C3:”&startValueCol&endValueRow&"", true);
//Setting the data source for the category data of NSeries series.setCategoryData(“A3:”&startDescCol&endDescRow&"");
plotArea = chart.getPlotArea(); area = plotArea.getArea(); area.setForegroundColor(Color.BLUE);
//save the file as a different one wb.save(“E:\development\temp.xls”);
The first error I’m getting is saying that BLUE is undefined in the Element ‘Color’. What do I need to use to set the foreground color? Is there a numerical value I can pass and if so where do I find those color codes. I assume it is something similar to that of the charts.add() function where I have to pass the numerical representation of the chart type rather than the doing ‘ChartType.PIE’.
Second: How do I not display a border around the plotArea of the chart? I don’t see a function to set a boolean parameter to turn the border to OFF.
Third: Is there a way to display the point name and percentage next to the point on the chart rather than that information only being displayed when you hover over the point. Something similar to the image at this link
1,You should use com.aspose.cells.Color Object to set the color.By the way,have the Cell.setValue method in <A href="</A> bean solved? Do you use another library?</FONT></FONT></P>
<P><FONT face=Verdana>2, You can set the property of the border line Object to set the border of the plotArea.See following codes:</FONT></P>
<P><FONT face=Verdana> PlotArea plotArea = chart.getPlotArea();<BR> Line line = plotArea.getBorder();<BR> line.setVisible(true);</FONT></P>
<P><FONT face=Verdana>3,DataLabels dls = series.getDataLabels();<BR> dls.setPercentageShown(true);</FONT></P>
<P><FONT face=Verdana></FONT> </P>
Thanks for the reply Warren. I will give your suggestions a shot. Yes the cell.setValue has been corrected. I needed to us it in conjuction with the JavaCast function. Below is the code
It keeps failing at the setForegroundColor(). The coldfusion error I get is
Element WHITE is undefined in COLOR.
I am basing my code off of the following example from the Aspose Wiki site for setting Charts Appearance.
//Setting the foreground color of the plot area PlotArea plotArea = chart.getPlotArea(); Area area = plotArea.getArea(); area.setForegroundColor(Color.BLUE);
The following code is also failing.
//Adding NSeries (chart data source) to the chart ranging from “A1” cell to “B3” series = chart.getNSeries();
4, If you want to add a chart, you should use the constant member of ChartType not a numeric value. See the following code: charts.add(ChartType.PIE,7,3,20,9).
5, Which JRE version do you use? If you use JRE1.4, please use the Aspose.Cells for Java 1.4. And Please try the fix in https://forum.aspose.com/t/104295. If the error still occurs, could you post your sample project and some info about your environment? We will check it.
Yes we are using JRun 4 JRE 1.4. Are you saying I should download the hotfix Version: 1.4.3.0? The link you provided doesn’t seem to work for me, it takes me to a page that says Access Denied.
Another question, is there any way in Aspose.Cells to generate an image of the chart that is being created so I can use that image to insert into a pdf file?
As stated in my last post, we are running Coldfusion MX and Macromedias JRun Server to manage our J2EE applications. We are running JRE 1.4. I have downloaded and installed the latest version from your site which is the Aspose.Cells For Java 1.7.5.0. I unzipped the contents and then referenced the Apose.Cells.jar file in JDK 1.4 from within my JRun console. I can access the classes fine, however, some things are not there such as the getDataLabels from the chart collection. This is what is available to me when I dump out the results for series = chart.getNSeries();
gives me:
object of com.aspose.cells.NSeries
</th></tr>
<tr>
<td class="object"><br></td>
<td>
add (returns int)<br>
add (returns int)<br>
get (returns com.aspose.cells.ASeries)<br>
size (returns int)<br>
setCategoryData (returns void)<br>
changeSeriesOrder (returns void)<br>
getCategoryData (returns java.lang.String)<br>
hashCode (returns int)<br>
getClass (returns java.lang.Class)<br>
wait (returns void)<br>
wait (returns void)<br>
wait (returns void)<br>
equals (returns boolean)<br>
notify (returns void)<br>
notifyAll (returns void)<br>
toString (returns java.lang.String)</td></tr></table><br>Also when attempting to use the constant member of the Chart Type instead of the numerical value it doesn't work. Am I missing a step? Below is some of the code I am using:<br><br>//get collection of charts<br> charts = sheet.getCharts();<br> ethChartRowPos = JavaCast('int',ethStartValueRow);<br> <br> //Adding a chart to the worksheet<br> ethPieChart = charts.add(pieChart,ethChartRowPos,0,20,5); // pieChart var is set above to 64<br><br> //Accessing the instance of the newly added chart<br> chart = charts.getChart(ethPieChart);<br><br>if I try <br>ethPieChart = charts.add(ChartType.PIE,ethChartRowPos,0,20,5); <br>instead, then my code fails<br><br>Thanks again for your help.<br><br>Scott<br>
1.It is not suppored to convert chart to image now.
2.You should reference all jars in JDK 1.4 of the Aspose.Cells for Java version.
3.NSeries Object is the ASeries colletion.The getDataLabels is the method of ASeries.You shoud get ASeries Object from NSeries first,then get Datalabels from the ASeries.See following codes:
We download JRun 4 SP1a for windows.It works fine with the attached hello.jsp in our test environment.We use Sun JDK1.4.2.
Please check the libraries in your ClassPath.It seems there is a library which has the same class name with Aspose.Cells for Java library.Maybe you should point out package of the calling classes.Such as com.aspose.cells.ChartType,com.aspose.cells.Worksheet,etc.
It’s getting there slowly but surely. I’m getting my datalabels now and postitoned on the chart where I want them. I don’t see a method for setting the leader line to true anywhere in the DataLabels object or NSeries object. Is this supported in aspose.cells? Thanks again for your help.
Please try this fix.In this fix,we rename the name of the two jars ,please change your reference in the project.
1,Please call ASeries.setHasLeaderLine to set whether the series has leader lines.
2,If you want to retrieve data from another sheet , the data source's format should be "DataSheet!A1:B3".Your codes should chang to: nSeries.add("DataSheet!C3:"ðStartValueColðEndValueRow&"", true);
3,You can call Title.setX and setY method to drag Title to anywhere in the chart area.If you want to change the legend position,you can call Lengend.setPosition method.
Please try this fix.We have embedded the classes of the retrotranslator and backport-util-concurrent.So you only need to references to dom4j-1.6.1.jar and Aspose.Cells.jar.
It is caused by CMFL the the selected method could not be found.Could you use a Jsp or Servlet or a java object to call writing and openning the file.
About the method could not be found,I think that you shoud change some codes.The following is my opinion:
1 Cell.setValue method could not be found : please try Cell.setValue(JavaCast("int",ethnicity.Num )) to set int value.Because coldFusion does not use explicit types for variables,the first value type will be the variable type.
2 Color.BLUE could not be found : please try add <cfobject type="Java" class="Class" name="myColor"> code first,then call setColor(myColor.BLUE);
I really appreciate you taking the time and looking into these issues for me. It is slowly getting there. I can now see the method setHasLeaderLine being available in the aSeries object now which I have listed below:
object of com.aspose.cells.ASeries
</th></tr>
<tr>
<td class="object"><font face="Arial" size="1">Methods</font></td>
<td><font face="Arial" size="1">
getName (returns java.lang.String)<br>
setName (returns void)<br>
getType (returns int)<br>
setType (returns void)<br>
setValues (returns void)<br>
getValues (returns java.lang.String)<br>
getBorder (returns com.aspose.cells.Line)<br>
getArea (returns com.aspose.cells.Area)<br>
hasLeaderLine (returns boolean)<br>
getDataLabels (returns com.aspose.cells.DataLabels)<br>
setPlotOnSecondAxis (returns void)<br>
setMarkerStyle (returns void)<br>
getBubbleSizes (returns java.lang.String)<br>
getChartPoints (returns com.aspose.cells.ChartPoints)<br>
getMarkerBackgroundColor (returns com.aspose.cells.Color)<br>
getMarkerForegroundColor (returns com.aspose.cells.Color)<br>
getMarkerSize (returns int)<br>
getMarkerStyle (returns short)<br>
getSeriesNumber (returns int)<br>
getTrendlines (returns com.aspose.cells.Trendlines)<br>
getXErroBars (returns com.aspose.cells.ErrorBars)<br>
getXValues (returns java.lang.String)<br>
getYErroBars (returns com.aspose.cells.ErrorBars)<br>
isColorVaried (returns boolean)<br>
isPlotOnSecondAxis (returns boolean)<br>
isSmooth (returns boolean)<br>
setBubbleSizes (returns void)<br>
setColorVaried (returns void)<br>
setHasLeaderLine (returns void)<br>
setMarkerBackgroundColor (returns void)<br>
setMarkerForegroundColor (returns void)<br>
setMarkerSize (returns void)<br>
setSeriesNumber (returns void)<br>
setSmooth (returns void)<br>
setXValues (returns void)<br>
hashCode (returns int)<br>
getClass (returns java.lang.Class)<br>
wait (returns void)<br>
wait (returns void)<br>
wait (returns void)<br>
equals (returns boolean)<br>
notify (returns void)<br>
notifyAll (returns void)<br>
toString (returns java.lang.String)</font></td></tr></table><br><br>However the following code executes fine, but the leaderLines are still not showing up when opening the excel file. Below is the code for setting them.<br><br>//Adding NSeries (chart data source) to the chart from "DataSheet"<br> nSeries = chart.getNSeries();<br> <br> nSeries.add("DataSheet!C3:"ðStartValueColðEndValueRow&"", true);<br> <br> //Setting the data source for the category data of NSeries<br> nSeries.setCategoryData("DataSheet!A3:"ðStartDescColðEndDescRow&""); <br> <br> aSeries = nSeries.get(0);<br> aSeries.setHasLeaderLine(true);<br> dls = aSeries.getDataLabels(); <br> dls.setPercentageShown(true);<br> dls.setValueShown(true);<br> dls.setLabelPosition(9); //BEST_FIT<br><br>As for the COLOR and CHARTTYPE issue I was having, that has been fixed by doing the following:<br><br><cfset myChart = CreateObject("java", "com.aspose.cells.ChartType")><br><cfset myColor = CreateObject("java", "com.aspose.cells.Color")><br><br>and then referencing myChart.PIE<br><br>Thanks again for your help.<br><br>It's getting there.<br><br>Scott<br>
After working with ColdFusion , we find why the cell.setValue(int ) could not be found.It seems the ColdFusion could not handle the cell.setValue(Object).If you want to use setValue(int) method , you should build another class ,see following code:
public class MyCell { public MyCell() { }
private Cell cell; public setCell(Cell cell) { this.cell = cell; } public void setIntValue(int intValue) { cell.setValue(intValue); } public void setStringValue(String stringValue) { cell.setValue(stringValue); } public void setDoubleValue(double doubleValue) { cell.setValue(doubleValue); } ...... }
That last fix worked for the leader lines. Everything else seems to be working so far as well. At least for the pie charts, not sure yet about other charts though cause I haven’t gotten to them yet. I’ll give the custom class a shot as well, although by doing
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.