View unanswered posts | View active topics
It is currently Sat Dec 21, 2024 9:52 am
|
Page 1 of 1
|
[ 7 posts ] |
|
Author |
Message |
John Lemur
|
Pie charts
How can I generate advanced pie charts in a web project?
|
Wed Jun 14, 2006 3:29 am |
|
|
tavi
Joined: Fri Feb 03, 2006 12:23 pm Posts: 3
|
Pie chart
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using EasyXLS;
using EasyXLS.Constants;
namespace TestWebEasyXLS
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
/*--------License Information --------*/
public static string sLicense = "License";
public static string sLicenseKey = "LicenseKey";
private void Page_Load(object sender, System.EventArgs e)
{
Response.Write("Tutorial 17 adapted<br>-----------<br>");
//Create an instance of the object that generates Excel files
ExcelDocument xls = new ExcelDocument();
//Add one worksheet
xls.easy_addWorksheet("SourceData");
// ----------------------------------------------------------------------
//Insert values
ExcelTable xlsTable1 = ((ExcelWorksheet)xls.easy_getSheet("SourceData")).easy_getExcelTable();
xlsTable1.easy_getCell(0, 0).setValue("Show Date");
xlsTable1.easy_getCell(0, 1).setValue("Available Places");
xlsTable1.easy_getCell(0, 2).setValue("Available -");
xlsTable1.easy_getCell(0, 3).setValue("Sold -");
xlsTable1.easy_getCell(1, 0).setValue("03/13/2005 00:00:00");
xlsTable1.easy_getCell(1, 0).setFormat(EasyXLS.Constants.Format.FORMAT_DATE);
xlsTable1.easy_getCell(2, 0).setValue("03/14/2005 00:00:00");
xlsTable1.easy_getCell(2, 0).setFormat(EasyXLS.Constants.Format.FORMAT_DATE);
xlsTable1.easy_getCell(3, 0).setValue("03/15/2005 00:00:00");
xlsTable1.easy_getCell(3, 0).setFormat(EasyXLS.Constants.Format.FORMAT_DATE);
xlsTable1.easy_getCell(4, 0).setValue("03/16/2005 00:00:00");
xlsTable1.easy_getCell(4, 0).setFormat(EasyXLS.Constants.Format.FORMAT_DATE);
xlsTable1.easy_getCell(1, 1).setValue("10000");
xlsTable1.easy_getCell(2, 1).setValue("5000");
xlsTable1.easy_getCell(3, 1).setValue("8500");
xlsTable1.easy_getCell(4, 1).setValue("1000");
xlsTable1.easy_getCell(1, 2).setValue("8000");
xlsTable1.easy_getCell(2, 2).setValue("4000");
xlsTable1.easy_getCell(3, 2).setValue("6000");
xlsTable1.easy_getCell(4, 2).setValue("1000");
xlsTable1.easy_getCell(1, 3).setValue("920");
xlsTable1.easy_getCell(2, 3).setValue("1005");
xlsTable1.easy_getCell(3, 3).setValue("342");
xlsTable1.easy_getCell(4, 3).setValue("967");
xlsTable1.easy_getColumnAt(0).setWidth(100);
xlsTable1.easy_getColumnAt(1).setWidth(100);
xlsTable1.easy_getColumnAt(2).setWidth(100);
xlsTable1.easy_getColumnAt(3).setWidth(100);
//-------------------------------------
//Add the chart xls.easy_addChart("Chart", "=SourceData!$A$1:$B$5", Chart.SERIES_IN_COLUMNS); ExcelChartSheet xlsChart = (ExcelChartSheet)xls.easy_getSheetAt(1); xlsChart.easy_setChartType(Chart.CHART_TYPE_PIE_3D_EXPLODED);
//Generate the file
Response.Write("Writing file Tutorial17.xls.");
xls.easy_WriteExcelFile("C:\\Inetpub\\wwwroot\\Tutorial17.xls", sLicense, sLicenseKey);
/*//Or write directly in Response and you don't need any permissions
//Start to prepare the Response
Response.AppendHeader("content-disposition", "attachment; filename=Tutorial17.xls");
Response.ContentType = "application/octetstream";
Response.Clear();
//Generate the file and prompt the "Open or Save Dialog Box"
xls.easy_WriteExcelFile(Response.OutputStream, sLicense, sLicenseKey);*/
//Confirm generation
String sError = xls.easy_getError();
if (sError.Equals(""))
Response.Write("<br>File successfully created.");
else
Response.Write("<br>Error encountered: " + sError);
//Dispose memory
Response.End();
xls.Dispose();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
|
Thu Jun 15, 2006 8:21 am |
|
|
MrRipley
|
Pie options
Yes, but is it possible to change de colors of each pieces by code? And how can you indicate de type of legends?
Making a pie chart from Excel, colors are assignated automatically, but from EasyXLS I always get then blue. And I don't know how to tell chart to show legends in percentage or how to access to the options of each category (I can get refereces to series, but in a pie chart usually you only have a single serie). It is easy from Excel, but is it possible by code?
I think rows and columns charts are quite more versatile with EasyXLS.
(My version of control is 5.1)
Greetings (and sorrry for my english; I'm spanish)
|
Mon Nov 20, 2006 8:28 am |
|
|
mihaionescu
Joined: Mon Nov 20, 2006 9:59 am Posts: 1
|
Please download and install the new trial version EasyXLS 5.3. In this version the chart pie is generated in different colors. This colors cannot be changed from the code. Here is some code that and I hope it can help you.
|
Mon Nov 20, 2006 10:50 am |
|
|
Guest
|
I will try. About changing categories colours, I have seen Excel does not allow it neither and apply them automatically...
|
Mon Nov 20, 2006 11:12 am |
|
|
djamraam
Joined: Tue May 13, 2008 3:32 am Posts: 2
|
pie charts
What can I do if I want to create a piechart whith several cells not with a cell range? i.e. with A1;G4;F32;H15
Thank you!
|
Fri May 16, 2008 6:12 am |
|
|
oana
Joined: Wed Nov 07, 2007 4:42 am Posts: 67
|
Pie Chart
Here is the code that you need:
|
Thu May 22, 2008 5:49 am |
|
|
|
Page 1 of 1
|
[ 7 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|