I am working on creating a couple of charts and I cannot figure out why there is so much empty space on the left and right side of the chart. I have a Winforms Chart, ChartArea, and Series and there is always a good inch to the left and right side of the chart that seems like wasted space. What setting do I need to change to reduce the size of this empty space? I have included a screenshot of the chart with empty space with this post as well as the code that I use to create it. Thanks in advance.
if (listBoxCharts.SelectedItems.Count == 1)
{
switch (listBoxCharts.SelectedItem.ToString().Trim())
{
case "Incomplete Work Orders By Status":
ChartArea chartArea = new ChartArea();
Series series = new Series();
Title title = new Title();
chartArea.Area3DStyle.Enable3D = true;
chartArea.Area3DStyle.LightStyle = LightStyle.Realistic;
chartArea.Area3DStyle.Rotation = 10;
chartArea.Area3DStyle.WallWidth = 3;
chartArea.BorderColor = Color.Transparent;
chartArea.Name = "IncompleteWorkOrdersByStatus_ChartArea";
// Fix this hack
ChartContainer.ChartAreas.Clear();
this.ChartContainer.ChartAreas.Add(chartArea);
this.ChartContainer.Dock = DockStyle.Fill;
this.ChartContainer.Location = new Point(2, 21);
this.ChartContainer.Name = "Charts";
this.ChartContainer.PaletteCustomColors = new Color[] { Color.LemonChiffon };
series.ChartArea = "IncompleteWorkOrdersByStatus_ChartArea";
series.ChartType = SeriesChartType.StackedColumn;
series.CustomProperties = "DrawingStyle=Cylinder";
series.EmptyPointStyle.BorderDashStyle = ChartDashStyle.NotSet;
series.IsXValueIndexed = true;
series.Name = "IncompleteWorkOrdersByStatus_Series";
List<WorkOrder> incompleteWorkOrders = woDao.getIncompleteWorkOrders();
var uniqueStatuses = (
from statuses in incompleteWorkOrders
select statuses.fkOrderStatus).Distinct().ToList();
int xVal = 1;
foreach (var status in uniqueStatuses)
{
var count = (
from wo in incompleteWorkOrders
where wo.fkOrderStatus == status
select wo).Count();
DataPoint dPoint = new DataPoint(xVal, count);
if (status == null)
{
dPoint.AxisLabel = "No Status";
}
else
{
dPoint.AxisLabel = status.codedesc;
}
dPoint.ToolTip = count + " " + dPoint.AxisLabel;
series.Points.Add(dPoint);
xVal++;
}
this.ChartContainer.Series.Clear();
this.ChartContainer.Series.Add(series);
title.DockedToChartArea = "IncompleteWorkOrdersByStatus_ChartArea";
title.IsDockedInsideChartArea = false;
title.Name = "IncompleteWorkOrdersByStatus_Title";
title.Text = "Incomplete Work Orders By Status";
this.ChartContainer.Titles.Clear();
this.ChartContainer.Titles.Add(title);
break;
default:
break;
}
}
Try playing with the InnerPlotPosition settings:
chart1.ChartAreas[0].InnerPlotPosition.X = 0;
Related
I need to select a specific block/border on the drawing and print that block/border as a PDF. I can find border by name but I can not take border coordination or at least one point to select the border and then print only that border. I will insert a code snippet that I have. It's messy - in development. Not familiar with DraftSight and DraftSight API.
I'm sure it's several different ways to do it.
Any help will be appreciated.
public static void BlockSelection()
{
DraftSight.Interop.dsAutomation.Application dsApp;
Document dsDoc = default(Document);
PrintManager dsPrintMgr = null;
//Connect to DraftSight application
dsApp = (DraftSight.Interop.dsAutomation.Application)Marshal.GetActiveObject("DraftSight.Application");
dsApp.AbortRunningCommand(); // abort any command currently running in DraftSight to avoid nested commands
//Get active document
dsPrintMgr = dsApp.GetPrintManager();
dsDoc = (Document)dsApp.GetActiveDocument();
object[] dsVarBlkDefinitions = null;
BlockDefinition dsBlkDefinition = default(BlockDefinition);
object[] dsBlock = null;
DraftSight.Interop.dsAutomation.Viewport dsViewport = default(DraftSight.Interop.dsAutomation.Viewport);
MathUtility dsMathUtility = default(MathUtility);
MathPoint startCorner = default(MathPoint);
MathPoint oppositeCorner = default(MathPoint);
Model dsModel = default(Model);
SketchManager dsSketchManeger = default(SketchManager);
ViewManager dsViewManager = default(ViewManager);
object[] dsSheets = null;
Sheet dsSheet = default(Sheet);
string SheetName = null;
int count = 0;
string blockName = "BLOCK1";
string outputFileLocationName = $#"C:\\TestOutput\\fileName";
//Get all Block definitions in the drawing
dsVarBlkDefinitions = (object[])dsDoc.GetBlockDefinitions();
dsBlock = new object[dsVarBlkDefinitions.Length];
for (int index = 0; index < dsVarBlkDefinitions.Length; index++)
{
for (index = dsVarBlkDefinitions.GetLowerBound(0); index <= dsVarBlkDefinitions.GetUpperBound(0); index++)
{
dsBlkDefinition = (BlockDefinition)dsVarBlkDefinitions[index];
var name = dsBlkDefinition.GetName();
Debug.Print($#"Block name: {name}");
// found block that I need to select and print
if (dsBlkDefinition.GetName().Contains(blockName))
{
object[] blocks = dsBlkDefinition.GetBlockInstances();
SelectionManager dsSelectionManager = dsDoc.GetSelectionManager();
SelectionFilter dsSelectionFilter = dsSelectionManager.GetSelectionFilter();
dsSelectionFilter.Clear();
dsSelectionFilter.AddEntityType(dsObjectType_e.dsBlockInstanceType);
dsSelectionFilter.Active = true;
dsSelectionManager.ClearSelections(dsSelectionSetType_e.dsSelectionSetType_Previous);
//if (dsCommandMessage.PromptForSelection(true, "Select dynamic block", errorMessage)) //
count = 0;
count = dsSelectionManager.GetSelectedObjectCount(dsSelectionSetType_e.dsSelectionSetType_Previous);
dsObjectType_e entityType = dsObjectType_e.dsObjectUndefinedType;
//object selObject = dsSelectionManager.GetSelectedObject(dsSelectionSetType_e.dsSelectionSetType_Previous, index, out entityType);
// tried to find any point of the block - not sure how to do that..
MathPoint point = ;
// Pathing that point into the SelectByPoint method.
object selObject = dsSelectionManager.SelectByPoint(point);
BlockInstance dsBlockInstance = selObject as BlockInstance;
// Printer set up
double top = .25;
double bottom = .25;
double left = .25;
double right = .25;
/////dsPrintMgr.PaperSize = "ANSI_A_(8.50_x_11.00_Inches)"; //this overrides the paper size of "Letter" DO NOT USE FOR NITRO
dsPrintMgr.PaperSize = "Letter";
dsPrintMgr.Quality = 4000;
dsPrintMgr.PrintOnCenter = true;
dsPrintMgr.PrintInBackground = true;
dsPrintMgr.ScaleLineWeight = false;
dsPrintMgr.UseAssignedLineWeight = false;
dsPrintMgr.StyleTable = "monochrome.ctb";
dsPrintMgr.SetPrintRange(dsPrintRange_e.dsPrintRange_SpecifyWindow, "", true, 0D, 0D, 0D, 0D);
dsPrintMgr.ScaleToFit = true;
dsPrintMgr.SetPrintMargins(top, bottom, left, right);
dsPrintMgr.PrintOut(1, outputFileLocationName);
// end of printer set up
}
}
}
}// end of BlockSelection method
My goal is to create a chart that will sit inside of a panel restricting it's size.
I managed to achieve this some time ago but today I noticed that the chart was growing inside of the panel, not allowing the data to be seen.
I have attached a picture bellow which should help understand the issue.
UPDATE
I noticed that if I rmeove 'bottom' from the Anchor property of the panel the chart does not exceed the parent panel but it does not increase with the change of the form which is what I'm looking for.
I also noticed that there was also another chart on the form that was exceeding the parent form, this time the chart would extend to the right not allowing to see the data.
This is the code that generates this second chart and places is inside of the parent panel.
panel_chart.Controls.Clear();
chart1 = new Chart();
chart1.MouseMove += chart1_MouseMove;
chart1.ChartAreas.Add(new ChartArea("chartArea1"));
chart1.Series.Clear();
chart1.Titles.Clear();
var serieOEE = new Series("OEE");
serieOEE.ChartType = SeriesChartType.Line;
serieOEE.XValueType = ChartValueType.String;
var serieProd = new Series("Prod");
serieProd.ChartType = SeriesChartType.Column;
serieProd.XValueType = ChartValueType.String;
var serieDisp = new Series("Disp");
serieDisp.ChartType = SeriesChartType.Column;
serieDisp.XValueType = ChartValueType.String;
var serieQual = new Series("Qual");
serieQual.ChartType = SeriesChartType.Column;
serieQual.XValueType = ChartValueType.String;
DateTime DataReg = DateTime.MinValue;
List<AreaOEE> listaChart = new List<AreaOEE>();
foreach (var item in ListaGrafico) //listaOEE
{
if (item.Designacao == DesignacaoLista)
{
listaChart.Add(item);
}
}
listaChart = listaChart.OrderBy(a => a.IDReg).ToList();
DateTime DataUltimoReg = DateTime.MinValue;
int j = 0;
foreach (var item in listaChart)
{
string HoraGraf = Convert.ToDateTime(item.Hora).ToString("HH:mm");
if (j == 0 || j == listaChart.Count - 1 ||
Math.Abs(Convert.ToDateTime(item.Hora).Subtract(DataUltimoReg).TotalMinutes) >= 30)
{
serieOEE.Points.AddXY(HoraGraf, item.OEE);
serieProd.Points.AddXY(HoraGraf, item.Produtividade);
serieQual.Points.AddXY(HoraGraf, item.Qualidade);
serieDisp.Points.AddXY(HoraGraf, item.Disponibilidade);
DataUltimoReg = Convert.ToDateTime(item.Hora);
if (j == listaChart.Count - 2)
{
break;
}
}
j++;
}
//Adicionar o ultimo
foreach (var item in listaOEE)
{
if (item.Designacao == DesignacaoLista)
{
string sHora = "";
try
{
sHora = item.Hora.Substring(1, 5);
}
catch (Exception ex)
{
string sEx = ex.Message;
}
foreach (var itemOee in serieOEE.Points)
{
if (itemOee.AxisLabel == sHora)
{
itemOee.YValues[0] = item.OEE;
}
}
foreach (var itemP in serieProd.Points)
{
if (itemP.AxisLabel == sHora)
itemP.YValues[0] = item.Produtividade;
}
foreach (var itemD in serieDisp.Points)
{
if (itemD.AxisLabel == sHora)
itemD.YValues[0] = item.Disponibilidade;
}
foreach (var itemQ in serieQual.Points)
{
if (itemQ.AxisLabel == sHora)
itemQ.YValues[0] = item.Qualidade;
}
}
}
chart1.Series.Add(serieProd);
chart1.Series.Add(serieQual);
chart1.Series.Add(serieDisp);
chart1.Series.Add(serieOEE);
serieOEE.BorderWidth = 4;
chart1.ChartAreas[0].AxisX.LabelStyle.Angle = 90;
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisY.Minimum = 0;
chart1.ChartAreas[0].AxisY.Maximum = 140;
chart1.Legends.Clear();
chart1.Legends.Add(serieOEE.Legend);
chart1.Titles.Add(DesignacaoLista + " " + DataTitulo.ToString("dd-MM HH:mm"));
chart1.Titles[0].Font = new Font("Arial", 13, FontStyle.Bold);
chart1.Visible = true;
chart1.Dock = DockStyle.Fill;
panel_chart.Controls.Add(chart1);
you can change the size of Chart with Chart.Size:
Chart1.Size = new Size(1000, 200); //1000px * 200px
for (int i = 0; i < 5; i += 1)
{
ShowReports(0);
}
private void ShowReports(int ComboID)
{
Graph.Series["Series1"].ChartType = SeriesChartType.Line;
Graph.Series["Series1"].BorderWidth = 2;
Graph.Series["Series1"].MarkerStyle = MarkerStyle.Circle;
Graph.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "dd-MMM-yyy";
Graph.ChartAreas["ChartArea1"].AxisX.Title = "Date";
Graph.ChartAreas["ChartArea1"].AxisY.Title = "Average Score (%) ";
Graph.ChartAreas["ChartArea1"].AxisY.Minimum = 0;
Graph.ChartAreas["ChartArea1"].AxisY.Maximum = 100;
Graph.ChartAreas["ChartArea1"].AxisY.Interval = 10;
Graph.Series["Series1"].ToolTip = "Date :#VALX Avg Score(%) :#VALY";
Graph.Titles.Add(dtReportDetails.Rows[0].ItemArray[1].ToString());
Graph.Titles.Add(SetGraphTitile());
Graph.Titles[0].Font = new System.Drawing.Font("Arial", 20);
Graph.Titles[0].ForeColor = System.Drawing.Color.Black;
Graph.Titles[1].Font = new System.Drawing.Font("Arial", 13);
Graph.Titles[1].ForeColor = System.Drawing.Color.Black;
Graph.Titles[1].Visible = false;
// Graph.Series[0].Points.AddXY(DateTime.Parse(dtReportDetails.Rows[0].ItemArray[4].ToString()), dtReportDetails.Rows[0].ItemArray[5].ToString());
Graph.Series[0].XValueMember = dtReportDetails.Rows[0].ItemArray[4].ToString();
Graph.Series[0].YValueMembers = dtReportDetails.Rows[0].ItemArray[5].ToString();
Graph.Series[0].MarkerStyle = MarkerStyle.Circle;
Graph.Legends.Add("Legend1");
Graph.Legends[0].Enabled = false;
Graph.Legends[0].Docking = Docking.Bottom;
Graph.Legends[0].Alignment = System.Drawing.StringAlignment.Center;
Graph.DataSource = dv;
Graph.DataBind();
}
else if (dtReportDetails.Rows[0].ItemArray[7].ToString() == "Bar")
{
Graph.Series["Series1"].ChartType = SeriesChartType.Column;
Graph.Series["Series1"].BorderWidth = 2;
//Graph.Series["Series1"].MarkerStyle = MarkerStyle.Circle;
//Graph.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "dd-MMM-yyy";
//Graph.ChartAreas["ChartArea1"].AxisX.Title = "Date";
//Graph.ChartAreas["ChartArea1"].AxisY.Title = "Average Score (%) ";
Graph.Series["Series1"].ToolTip = "(#VALX,#VALY)";
Graph.Titles.Add(dtReportDetails.Rows[0].ItemArray[1].ToString());
Graph.Titles.Add(SetGraphTitile());
Graph.Titles[0].Font = new System.Drawing.Font("Arial", 20);
Graph.Titles[0].ForeColor = System.Drawing.Color.Black;
Graph.Titles[1].Font = new System.Drawing.Font("Arial", 13);
Graph.Titles[1].ForeColor = System.Drawing.Color.Black;
Graph.Titles[1].Visible = false;
Graph.ChartAreas["ChartArea1"].AxisX.Title = "Learning Domains";
Graph.ChartAreas["ChartArea1"].AxisY.Title = "Covered";
// Graph.Series[0].Points.AddXY(DateTime.Parse(dtReportDetails.Rows[0].ItemArray[4].ToString()), dtReportDetails.Rows[0].ItemArray[5].ToString());
Graph.Series[0].XValueMember = dtReportDetails.Rows[0].ItemArray[4].ToString();
Graph.Series[0].YValueMembers = dtReportDetails.Rows[0].ItemArray[5].ToString();
// Graph.Series[0].MarkerStyle = MarkerStyle.Circle;
Graph.Legends.Add("Legend1");
Graph.Legends[0].Enabled = false;
Graph.Legends[0].Docking = Docking.Bottom;
Graph.Legends[0].Alignment = System.Drawing.StringAlignment.Center;
Graph.DataSource = dv;
Graph.DataBind();
Random random = new Random();
foreach (var item in Graph.Series[0].Points)
{
System.Drawing.Color c = System.Drawing.Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255));
item.Color = c;
}
Graph.Series[0]["PointWidth"] = "0.2";
Graph.Series[0]["BarLabelStyle"] = "Center";
Graph.Series[0]["PixelPointDepth"] = "99";
Graph.Series[0]["DrawingStyle"] = "Cylinder";
}
This is my code for creating graph,for creating 1 graph i have no problem ,but creating more than one i will get error:A chart element with the name 'Legend1' already exists in the 'LegendCollection'.because i am creating same legends each time.So can you help to get rid of this problem.
Getting around the issue of the legend object name should be as simple as setting it via a string that takes your ComboID parameter into account.
string myLegendTitle = "Legend" + ComboID;
Graph.Legends.Add(myLegendTitle);
In order to create multiple charts - on the assumption you're using Microsoft Chart controls would look something like
for (int i = 0; i < 5; i += 1)
{
ShowReports(0);
}
private void ShowReports(int ComboID)
{
var myNewGraph = new System.Windows.Forms.DataVisualization.Charting.Chart();
myNewGraph .Series["Series1"].ChartType = SeriesChartType.Line;
myNewGraph .Series["Series1"].BorderWidth = 2;
myParentControl.Controls.Add(myNewGraph);
}
The key points being to instantiate a new Chart in your ShowReports method, then set all the properties specifically as before BUT on the new graph / chart object. Then ensure you add the control to the appropriate container if it's not already there.
If you know you will have, for example, 5 charts, then another approach is to build them at design time instead, and use a switch approach to set your variable, eg.
private void ShowReports(int ComboID)
{
Chart myNewGraph;
switch (ComboID)
{
case 1:
myNewGraph = Graph1;
break;
}
myNewGraph .Series["Series1"].ChartType = SeriesChartType.Line;
myNewGraph .Series["Series1"].BorderWidth = 2;
}
Is the code for create 5 graphs..
for(int i=0;i< 6;i++)
{
Chart1.Series.Add("Series1" + t.ToString());
Chart1.ChartAreas.Add("ChartArea1" + t.ToString());
Chart1.Legends.Add("Legend1" + t.ToString());
Chart1.Series[t].ChartArea = "ChartArea1" + t.ToString();
Chart1.Series[t].ChartType = SeriesChartType.Column;
Chart1.Series[t].BorderWidth = 2;
Chart1.Series[t].ToolTip = "(#VALX,#VALY)";
Chart1.ChartAreas["ChartArea1" + t.ToString()].AxisX.Title = "Learning Domains";
Chart1.ChartAreas["ChartArea1" + t.ToString()].AxisY.Title = "Covered";
}
I have 2 problems:
I want the names from the datatable but it is showing me in numeric form.
I would like a gap between the two bars but I can't find a way.
Here is the code:
private void InitializeGraph (DataTable poDt)
{
Telerik.Charting.ChartSeries chartseries = new Telerik.Charting.ChartSeries();
try
{
chartseries.Type = Telerik.Charting.ChartSeriesType.Bar;
Telerik.Charting.ChartSeriesItem csItem;
RadChart1.PlotArea.XAxis.AutoScale = true;
RadChart1.PlotArea.XAxis.DataLabelsColumn = "Name";
for (int iRow = 0; iRow < poDt.Rows.Count; iRow++)
{
chartseries = new Telerik.Charting.ChartSeries();
chartseries.Type = Telerik.Charting.ChartSeriesType.Bar;
chartseries.Name = poDt.Rows[iRow]["Name"].ToString().Trim();
csItem = new Telerik.Charting.ChartSeriesItem();
csItem.Name = poDt.Rows[iRow]["Name"].ToString();
csItem.Label.TextBlock.Text = poDt.Rows[iRow]["Value"].ToString();
RadChart1.PlotArea.XAxis.Appearance.TextAppearance.AutoTextWrap = Telerik.Charting.Styles.AutoTextWrap.True;
csItem.YValue = Int32.Parse(poDt.Rows[iRow]["Value"].ToString());
chartseries.AddItem(csItem);
RadChart1.Series.Add(chartseries);
}
RadChart1.PlotArea.XAxis.AddRange(1, poDt.Rows.Count, 1);
RadChart1.PlotArea.XAxis[poDt.Rows.Count].TextBlock.Text = chartseries.Name;
poDt.Rows.Count.ToString();
RadChart1.PlotArea.XAxis.AutoShrink = false;
RadChart1.PlotArea.XAxis.AutoShrink = true;
RadChart1.Series.Add(chartseries);
RadChart1.PlotArea.Appearance.Border.Visible = false;
RadChart1.Appearance.Border.Visible = true;
RadChart1.PlotArea.YAxis.IsLogarithmic = true;
RadChart1.PlotArea.YAxis.AutoScale = true;
RadChart1.PlotArea.YAxis.Appearance.ValueFormat=Telerik.Charting.Styles.ChartValueFormat.Number;
RadChart1.Appearance.BarWidthPercent = 50;
RadChart1.Chart.Appearance.FillStyle.MainColor = System.Drawing.Color.Red;
RadChart1.Chart.Appearance.FillStyle.MainColor = System.Drawing.Color.Transparent;
RadChart1.Legend.Appearance.FillStyle.MainColor = System.Drawing.Color.Transparent;
}
catch (Exception Ex)
{
//throw;
}
finally
{
poDt.Clear();
poDt = null;
chartseries = null;
}
}
Sorry, I do not believe there is a way to display two X-axis at the same time.
My suggestion is you use a CategoricalAxis for your X axis and create a custom bar chart that has a legend which differentiates the two values. I don't have any working samples, however you can use this Telerik Silverlight demo for starters.
Also, switch to RadChartView if you can. Because I would then suggest an easier approach, which is using a Categorical X-Axis and create multiple Y axes. If you go that route, you can do something like this for a DateTimeContinuous (or Categorical) X-axis with multiple Y-axes :
int count = 0;
LineSeries lineSeries = new LineSeries();
lineSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "TimeStamp" };
lineSeries.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" };
lineSeries.VerticalAxis = new LinearAxis()
{
Title = "Title Here"
};
lineSeries.ItemsSource = yourCollection.Values;
//First Y-axis to be placed on the left of X-axis,
//additional Y-axes to be placed on right
if (count > 0 )
{
lineSeries.VerticalAxis.HorizontalLocation = Telerik.Charting.AxisHorizontalLocation.Right;
}
count++;
chartName.Series.Add(lineSeries);
Hope this helps.
I want to make a survey with asp.net and c#.
It is clear that I can do it. But for the results I want to show them in a pie-chart and histogram.
The questions have only two answers "yes" and "no".
In pie-chart the whole percentage of "yes" and percentage of "no" like %55 "yes", %45 "no".
In histogram I want to show each question which is divided into 2 part ("yes" and "no").
In order to do these (pie-chart and the histogram), should I use component like Telerik?
Or can I do this with drawing library in .NET?
You can use Asp.net Chart controls for representing the data in pie charts......and it also depends on databinding.
if you are using datatable to get data from database then asp.net chart controls much better ...
would you pls take a look at this link for more information....
https://web.archive.org/web/20211020111731/https://www.4guysfromrolla.com/articles/120804-1.aspx
EDIT
This is function getting data from database..
public DataTable GetVisits(System.DateTime startdate , System.DateTime enddate)
{
const string sql = #"SELECT CONCAT(UPPER(SUBSTRING(visit_Status, 1, 1)), SUBSTRING(visit_Status FROM 2)) as Status, COUNT('x') AS Visits
FROM visits
WHERE visit_Date BETWEEN #startdate AND #enddate
GROUP BY visit_Status";
return sqlexecution(startdate, enddate, sql);
}
I am representing this data in stackcolumn chart.
if you want to represent in pie chart , you can change in code
public void DrawMembersvisits(Chart targetchartcontrol, DateTime startdate, DateTime enddate)
{
chart1 = targetchartcontrol;
Series series = null;
Title title;
string area = null;
chart1.ChartAreas.Clear();
chart1.Series.Clear();
chart1.Titles.Clear();
DataTable membervisits = null;
area = "Visits";
chart1.ChartAreas.Add(area);
series = chart1.Series.Add(area);
series.ChartArea = area;
title = chart1.Titles.Add("Member Visits");
title.Alignment = ContentAlignment.MiddleCenter;
title.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);
title.DockedToChartArea = area;
chart1.Titles.Add("").DockedToChartArea = area;
foreach (Title titles in chart1.Titles)
{
titles.IsDockedInsideChartArea = false;
}
foreach (ChartArea areas in chart1.ChartAreas)
{
areas.Area3DStyle.Enable3D = true;
areas.AxisX.LabelStyle.IsEndLabelVisible = false; areas.AxisX.LabelStyle.Angle = -90;
areas.AxisX.LabelStyle.IsEndLabelVisible = true;
areas.AxisX.LabelStyle.Enabled = true;
}
foreach (Legend legends in chart1.Legends)
{
legends.Enabled = false;
}
foreach (Series serie in chart1.Series)
{
serie.ChartType = SeriesChartType.StackedColumn;
// change here to get the pie charts
// charttypes.ChartType = SeriesChartType.Pie;
// charttypes["LabelStyle"] = "Outside";
// charttypes["DoughnutRadius"] = "30";
// charttypes["PieDrawingStyle"] = "SoftEdge";
// charttypes.BackGradientStyle = GradientStyle.DiagonalLeft;
serie["LabelStyle"] = "Outside";
serie["ColumnDrawingStyle"] = "SoftEdge";
serie["LabelStyle"] = "Top";
serie.IsValueShownAsLabel = true;
serie.BackGradientStyle = GradientStyle.DiagonalLeft;
}
membervisits = visistsdataf.GetVisits(startdate, enddate);
chart1.Series[0].Points.DataBindXY(membervisits.Rows, "Status", membervisits.Rows, "Visits");
foreach (Series chartSeries in chart1.Series)
{
foreach (DataPoint point in chartSeries.Points)
{
switch (point.AxisLabel)
{
case "Accepted": point.Color = Color.Green; break;
case "Refused": point.Color = Color.Red; break;
}
point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel);
}
}
}