Problems with charts

Hi,

i have some problems with creating some charts.

1. The legend is shown in my diagram but the description is wrong. There is written for each “row” of my datasource “Row n” (e.g. n = 1 to 5). When resseting the datasource manual in excel the text i need is shown in the legend correct. It this a user error or a bug?

2. “chart.ValueAxis.Title.Rotation = 90;” seems not to be working!?

3. Question: In Excel i can set for the bars an description (Value, Categoryname, DataRowname). Is this with aspose possible to? I want in each bar the value of it (e.g. 20 or 42)

4. Is it possible to set the charts-painting area like the legend.x value? I want to have my barchart not on the left of the whole chart because on the left there should be other thins like legend an some other text…

Thanks for support!

-Stefan

Hi Stefan,

1. Please email me your file created by Aspose.Excel and the file created by hand. I will investigate it. And could you post your code for this issue here?

2. Yes. It doesn’t work now. But it will work in the next hotfix before the start of next week.

3. Please try the following code:

//Show value
for(int i = 0; i < chart.NSeries.Count; i ++)
{
chart.NSeries[i].DataLabels.IsValueShown = true;
}

//Show category name
for(int i = 0; i < chart.NSeries.Count; i ++)
{
chart.NSeries[i].DataLabels.IsCategoryNameShown = true;
}

Now Value and CategoryName cannot show concurrently.

3. chart.Legend.Position = LegendPositionType.Left;
Then legend shows on the left and chart shows on the right.

Hi Laurence, many thanks for your support!

1. I will e-Mail these two files in a few minutes…

2. That’s fine!

3. This code works but one adjust question: How to set the font in the bars? Now they are black and outside of my bar one the left and right! I have to set them smaller and other colored…

4. Your solution is a workarround. It will not work for me.
I have to explain:
On my sheet on the top is a table with one “descript-column” (“A”) and n “data-columns”.
The data-columns have all the same width. Now i want to set each bar exactly under the values in the table.
If i take your solution the legend is shown on the left. By giving the legend the required width it will work, you have right! But this required width is to small for my legend, the values will be multiline formatted and this is undesired. Therefore i have to set the legent on the top-right corner and under the chart. If i do this, my bar-chart (what’s the exactly name of this part of the whole chart?) appears on the left. To get it exactly under the values of my table i have to move it some columns or pixel to the right, but how to do this?

One more time many thanks for support!

Regards, Stefan

p.s. I will e-Mail the two excel-files to excel@aspose.com

Hi Stefan,

Now I understand your need. About 3 and 4, I will provide api to set font for data labels and set position of chart. It will be availabe before the end of next week.

Thanks for your patience.

Stefan,

I got your file. I will investigate it right now.

About your another question:

I have inquired before some weeks how to set the sheetname with " ", “-” and some other chars. Is this corrected yet?

The answer is yes. A hotfix including this feature will be released before the start of next week.

Hi Stefan,

About the legend of series, please try these:

chart.NSeries[0].Name = “=A3”;
chart.NSeries[1].Name = “=A4”;

or

chart.NSeries[0].Name = “Test”;
chart.NSeries[1].Name = “Gesamtstückzahl”;

Hi Laurence,
your Solution for my legends works great!

Posted by Laurence:
"Now I understand your need. About 3 and 4, I will provide api to set font for data labels and set position of chart. It will be availabe before the end of next week."

Maybe you can add in this step setting width and height of the inner-chart [with inner-chart i mean the part with the bars or lines…]
This would be great!

Thanks and Regards, Stefan

Hi Stefan,

Please try the following code:

chart.Legend.Position = LegendPositionType.Top;

Hotfix 1.8.7 is release. It fixed the Range.SetOutlineBorder issue and you can use “chart.ValueAxis.Title.Rotation = 90;”.
Please download it and have a try.

Now I am working on your other feature requests.

Hi Laurence,

i have downloaded this new hotfix 1.8.7 but “chart.ValueAxis.Title.Rotation = 90;” isn’t working for me!

My code:
<BR>chart.CategoryAxis.Title.Text = "Kalenderwochen"; <BR>chart.ValueAxis.Title.Rotation = 90;<BR>chart.ValueAxis.Title.Text = "Anzahl Fzg. (Anlieferung Montage) pro KW";<BR>

For the other features (1. set font for data labels, 2. set position of chart (! inner-chart !) and maybe 3. “Conditional Formatting” for cellvalues) you have called a release-date end of week (03/21/2004). Is this deadline supportable? My question is because of i have to outreach this date.

Regards, Stefan

It’s a small bug for rotation. I will fix it in the next release.

Now please change your code to the following and rotation will take effect.

chart.CategoryAxis.Title.Text = “Kalenderwochen”;
chart.ValueAxis.Title.Rotation = 90;
chart.ValueAxis.Title.Text = “Anzahl Fzg. (Anlieferung Montage) pro KW”;
chart.ValueAxis.Title.TextFont.Color = Color.Black;

About other features you mentioned, you are right. The deadline will be 03/21/2004. Now thanks for your waiting.

Hi Laurence,

sorry for numerous questions!!!

Is following code already supported by api? It has no effect for my charts.

chart.ValueAxis.Title.X = 0;
chart.ValueAxis.Title.Y = 100;
chart.ValueAxis.Title.Height = 50;
chart.ValueAxis.Title.Width = 200;
chart.ValueAxis.Title.TextHorizontalAlignment = TextAlignmentType.Left;

Much obliged, Stefan

Hi Stefan,

I will do it ASAP. If possible, it will be included in this week’s release. Otherwise, it will be available in next week.

@WebJumper,
Aspose.Cells has replaced the previous product Aspose.Excel which is deprecated now. Using this new product Aspose.Cells you can manage all types of charts which are supported by different versions of MS Excel. An example is given here for your reference which demonstrates creating a simple chart.

// Instantiating a Workbook object
Workbook workbook = new Workbook();

// Adding a new worksheet to the Excel object
int sheetIndex = workbook.Worksheets.Add();

// Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];

// Adding sample values to cells
worksheet.Cells["A1"].PutValue(50);
worksheet.Cells["A2"].PutValue(100);
worksheet.Cells["A3"].PutValue(150);
worksheet.Cells["B1"].PutValue(4);
worksheet.Cells["B2"].PutValue(20);
worksheet.Cells["B3"].PutValue(50);

// Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Pyramid, 5, 0, 15, 5);

// Accessing the instance of the newly added chart
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];

// Adding SeriesCollection (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);

// Saving the Excel file
workbook.Save(dataDir + "output.xls");

A detailed document is available which provides ready to run code snippets here:
Creating and customizing charts

The latest version of this new product is available here:
Aspose.Cells for .NET (Latest Version)

Give this product a try using a ready to run solution here.