Creating multiple chart in c# - c#

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";
}

Related

Blank space being produced from for loop for dates

I have a loop that iterates through each date between two selected dates.
It creates a panel for each product on that date and then moves on.
That works fine, but if I run the loop again, it produces a blank space between the new panels and the old panels. Here is a example:
(small cause of my small screen)
The black lines indicate what I'm speaking about. The short one is the normal spacing between each panel and the long one indicates when I run the loop again.
The reason I'm worried is because if you want to add products after your initial add, it will be the second or third or fourth time the loop runs and leave that gap which just creates an unpleasant view.
Can someone please tell me what is causing this gap, here is the code for this section(i know about the SQL injections, i do send parameters to a DAL but for the sake of this question I'm using a SQL query):
for (DateTime date = dtpSDate.Value; date.Date <= dtpCDate.Value; date = date.AddDays(1))
{
pnlReport.Controls.Add(new Label { Text = date.ToString(), Height = 20, Width = 150, Name = date.ToString(), Location = new Point(20, globalY), Font = new Font("Arial", 10, FontStyle.Bold) });
globalY += 30;
foreach (DataRowView lstvItem in chkListProducts.CheckedItems)
{
DataTable ProdTmp2 = new DataTable();
string sqlP2 = "SELECT * FROM Product WHERE ProdID = '" + lstvItem[this.chkListProducts.ValueMember] + "'";
ProdTmp2 = db.GetDataTable(sqlP2);
if (Side == "Left")
{
Panel pnltmp = new Panel();
pnltmp.Size = new Size(472, 120);
pnltmp.Location = new Point(5, globalY);
pnltmp.BackColor = Color.Green;
pnltmp.Name = ProdTmp2.Rows[0][1].ToString();
Label l = new Label();
l.Text = ProdTmp2.Rows[0][1].ToString();
l.Location = new Point(5, 5);
pnltmp.Controls.Add(l);
pnlReport.Controls.Add(pnltmp);
Side = "Right";
last = ProdTmp2.Rows[0][1].ToString();
}
else
{
Panel pnltmp = new Panel();
pnltmp.Size = new Size(472, 120);
pnltmp.Location = new Point(487, globalY);
pnltmp.BackColor = Color.Red;
pnltmp.Name = ProdTmp2.Rows[0][1].ToString();
Label l = new Label();
l.Text = ProdTmp2.Rows[0][1].ToString();
l.Location = new Point(5, 5);
pnltmp.Controls.Add(l);
pnlReport.Controls.Add(pnltmp);
Side = "Left";
globalY += 140;
last = ProdTmp2.Rows[0][1].ToString();
}
}
if (Side == "Right")
{
Side = "Left";
globalY += 170;
}
}
Extra Info: The bigger the date gap. The larger the blank space gap.
So the end Code looks like this and the space is now non existent.
Thanx to all.
private void AddProducts()
{
foreach (Panel p in pnlReport.Controls.OfType<Panel>())
{
if (p.Name == last)
{
globalY = p.Location.Y + 140;
}
}
for (DateTime date = dtpSDate.Value; date.Date <= dtpCDate.Value; date = date.AddDays(1))
{
pnlReport.Controls.Add(new Label { Text = date.ToString(), Height = 20, Width = 150, Name = date.ToString(), Location = new Point(20, globalY), Font = new Font("Arial", 10, FontStyle.Bold) });
globalY += 30;
foreach (DataRowView lstvItem in chkListProducts.CheckedItems)
{
string table = "";
string select = "";
if (Regex.IsMatch(lstvItem[this.chkListProducts.DisplayMember].ToString(), #"^[a-hA-H]"))
{
table = "ProductHistoryAH";
}
else if (Regex.IsMatch(lstvItem[this.chkListProducts.DisplayMember].ToString(), #"^[i-qI-Q]"))
{
table = "ProductHistoryIQ";
}
else if (Regex.IsMatch(lstvItem[this.chkListProducts.DisplayMember].ToString(), #"^[r-zR-Z]"))
{
table = "ProductHistoryRZ";
}
DataTable ProdTmp1 = new DataTable();
string sqlP1 = "SELECT * FROM " + table + " WHERE ProdID = '" + lstvItem[this.chkListProducts.ValueMember] + "' AND ProdHDate = '" + date.ToString(#"yyyy\/MM\/dd") + "'";
ProdTmp1 = db.GetDataTable(sqlP1);
DataTable ProdTmp2 = new DataTable();
string sqlP2 = "SELECT * FROM Product WHERE ProdID = '" + lstvItem[this.chkListProducts.ValueMember] + "'";
ProdTmp2 = db.GetDataTable(sqlP2);
if (Side == "Left")
{
Panel pnltmp = new Panel();
pnltmp.Size = new Size(472, 120);
pnltmp.Location = new Point(5, globalY);
pnltmp.BackColor = Color.Green;
pnltmp.Name = ProdTmp2.Rows[0][1].ToString() + count.ToString();
//Name
Label lblName = new Label();
lblName.Text = lstvItem[this.chkListProducts.DisplayMember].ToString();
lblName.Location = new Point(5, 5);
pnltmp.Controls.Add(lblName);
int Location = 0;
//Count
if (chkPCount.Checked)
{
Label lblCount = new Label();
if(ProdTmp1.Rows.Count>0)
{
lblCount.Text = "Count: " + ProdTmp1.Rows[0][4].ToString();
}
else
{
lblCount.Text = "Count: 0";
}
lblCount.Location = new Point(17, 32);
pnltmp.Controls.Add(lblCount);
}
pnlReport.Controls.Add(pnltmp);
Side = "Right";
}
else if(Side == "Right")
{
Panel pnltmp = new Panel();
pnltmp.Size = new Size(472, 120);
pnltmp.Location = new Point(487, globalY);
pnltmp.BackColor = Color.Red;
pnltmp.Name = ProdTmp2.Rows[0][1].ToString() + count.ToString();
//Name
Label lblName = new Label();
lblName.Text = lstvItem[this.chkListProducts.DisplayMember].ToString();
lblName.Location = new Point(5, 5);
pnltmp.Controls.Add(lblName);
//Count
if (chkPCount.Checked)
{
Label lblCount = new Label();
if (ProdTmp1.Rows.Count > 0)
{
lblCount.Text = "Count: " + ProdTmp1.Rows[0][4].ToString();
}
else
{
lblCount.Text = "Count: 0";
}
lblCount.Location = new Point(17, 32);
pnltmp.Controls.Add(lblCount);
}
pnlReport.Controls.Add(pnltmp);
Side = "Left";
globalY += 140;
}
last = ProdTmp2.Rows[0][1].ToString() + count.ToString();
}
if (Side == "Right")
{
Side = "Left";
globalY += 140;
}
}
count++;
}
and the output:

Radgridview visual issue

I have problem displaying the columns correctly,
some columns have some gap in between
I wanted to attach a picture but I need 10 reputation points to post image
See picture link below!!
Here is my code:
private void UpdateProducts()
{
MyPharmacyDataContext db = new MyPharmacyDataContext();
int tabid = Convert.ToInt32(radRibbonBar1.SelectedCommandTab.Name);
var list = from g in db.OutOfStocks
where g.ListID == tabid
select new { g.ID, g.Product.CName, g.Required, g.Product.Price, g.Product.Disscount, g.Product.BuyPrice, g.TotalBuy, Stock = g.Product.Available + "," + g.Product.AvailableMid + "," + g.Product.AvailableSmall,g.Product.Supplier.Title };
if (list.Count() > 0)
{
radGridView1.SummaryRowsBottom.Clear();
radGridView1.Columns.Clear();
radGridView1.Visible = true;
radGridView1.TableElement.TableHeaderHeight = 60;
GridViewTextBoxColumn num = new GridViewTextBoxColumn();
num.MaxWidth = 50;
num.Name = "num";
num.HeaderText = "م";
num.DataType = typeof(int);
radGridView1.Columns.Add(num);
radGridView1.DataSource = list;
radGridView1.Columns[1].IsVisible = false;
radGridView1.Columns[2].Width = 350;
radGridView1.Columns[2].HeaderText = "اسم المنتج";
radGridView1.Columns[2].Name = "Name";
radGridView1.Columns[2].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[3].MaxWidth = 60;
radGridView1.Columns[3].HeaderText = "عدد";
radGridView1.Columns[3].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[3].Name = "Q";
radGridView1.Columns[4].MaxWidth = 90;
radGridView1.Columns[4].HeaderText = "السعر";
radGridView1.Columns[4].Name = "Price";
radGridView1.Columns[4].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[4].FormatString = "{0:G29}";
radGridView1.Columns[5].MaxWidth = 80;
radGridView1.Columns[5].HeaderText = "الخصم";
radGridView1.Columns[5].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[5].FormatString = "{0:G29}";
radGridView1.Columns[6].MaxWidth = 100;
radGridView1.Columns[6].HeaderText = "سعر\nالشراء";
radGridView1.Columns[6].Name = "BuyPice";
radGridView1.Columns[6].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[6].FormatString = "{0:G29}";
radGridView1.Columns[7].MaxWidth = 100;
radGridView1.Columns[7].HeaderText = "اجمالي\nالشراء";
radGridView1.Columns[7].Name = "TotalBuyPice";
radGridView1.Columns[7].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[7].FormatString = "{0:G29}";
radGridView1.Columns[8].MaxWidth = 80;
radGridView1.Columns[8].MinWidth = 80;
radGridView1.Columns[8].Name = "Stock";
radGridView1.Columns[8].HeaderText = "الرصيد";
radGridView1.Columns[8].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[9].MaxWidth = 100;
radGridView1.Columns[9].MinWidth = 100;
radGridView1.Columns[9].Name = "Supplier";
radGridView1.Columns[9].HeaderText = "افضل\nمورد";
radGridView1.Columns[9].TextAlignment = ContentAlignment.MiddleCenter;
GridViewCheckBoxColumn checkbox = new GridViewCheckBoxColumn();
checkbox.MaxWidth = 30;
checkbox.HeaderText = "";
checkbox.DataType = typeof(bool);
checkbox.Name = "Ordered";
radGridView1.Columns.Add(checkbox);
var allpro = from g in db.OutOfStocks
where g.ListID == tabid
select g;
foreach (OutOfStock p in allpro)
{
foreach (GridViewRowInfo row in radGridView1.Rows)
{
if ((int)row.Cells[1].Value == p.ID)
{
if (p.Ordered == 'y')
row.Cells["Ordered"].Value = true;
else
row.Cells["Ordered"].Value = false;
}
}
}
GridViewSummaryItem total = new GridViewSummaryItem("Name", "الاجمالي", GridAggregateFunction.Avg);
GridViewSummaryItem price = new GridViewSummaryItem();
price.Name = "Price";
price.AggregateExpression = "(Sum(Q*Price))";
price.FormatString = "{0:G29}";
// GridViewSummaryItem price = new GridViewSummaryItem("Price", "{0}", GridAggregateFunction.Sum);
GridViewSummaryItem buypice = new GridViewSummaryItem("TotalBuyPice", "{0:G29}", GridAggregateFunction.Sum);
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(new GridViewSummaryItem[] { total, price, buypice });
radGridView1.SummaryRowsBottom.Add(summaryRowItem);
radGridView1.Focus();
}
else
{
radGridView1.Visible = false;
}
if (radGridView1.Rows.Count() > 0)
radGridView1.ChildRows.Last().IsCurrent = true;
}
Here is the pic
https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpa1/v/t34.0-12/10893575_742987025776952_423788280_n.jpg?efg=eyJpIjoidCJ9&oh=c69f42a8f47d6529f2b9d89ab2782711&oe=54A71C8A&gda=1420210517_66e1b08ccf9c00fd3dcff31e1854b3cc

The call is ambiguous between the following methods when I want use a class

I defined a class in my ASP.NET webform page:
namespace AdsignInt_V0._2.AdvertiserZone.ChartReports
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<string> XAxisItems = new List<string>();
XAxisItems.Add("Monday");
XAxisItems.Add("Tuesday");
XAxisItems.Add("Wednesday");
XAxisItems.Add("Thursday");
XAxisItems.Add("Friday");
XAxisItems.Add("Saturday");
XAxisItems.Add("Sunday");
SeriesItem series1 = new SeriesItem("Week 1", Color.Red);
for (int i = 1; i < 8; i++)
series1.Items.Add(i * 10);
SeriesItem series2 = new SeriesItem("Week 2", Color.Blue);
for (int i = 1; i < 8; i++)
series2.Items.Add(100 - i * 10);
List<SeriesItem> SeriesItems = new List<SeriesItem>();
SeriesItems.Add(series1);
SeriesItems.Add(series2);
makeChart(XAxisItems, SeriesItems);
}
void makeChart(List<string> XAxisItems, List<SeriesItem> SeriesItems)
{
MyChart.Appearance.FillStyle.BackgroundColor = Color.White;
MyChart.ChartTitle.Text = "Server CPU Load By Days";
MyChart.ChartTitle.Appearance.Align = ChartTitleAlign.Center;
MyChart.ChartTitle.Appearance.BackgroundColor = Color.White;
MyChart.ChartTitle.Appearance.Position = ChartTitlePosition.Top;
MyChart.Legend.Appearance.BackgroundColor = Color.White;
MyChart.Legend.Appearance.Position = ChartLegendPosition.Bottom;
MyChart.PlotArea.Appearance.FillStyle.BackgroundColor = Color.White;
{ //XAxis
MyChart.PlotArea.XAxis.AxisCrossingValue = 0;
MyChart.PlotArea.XAxis.Color = Color.Black;
MyChart.PlotArea.XAxis.MajorTickType = TickType.Outside;
MyChart.PlotArea.XAxis.MinorTickType = TickType.Outside;
MyChart.PlotArea.XAxis.Reversed = false;
MyChart.PlotArea.XAxis.LabelsAppearance.DataFormatString = "{0}";
MyChart.PlotArea.XAxis.LabelsAppearance.RotationAngle = 0;
MyChart.PlotArea.XAxis.LabelsAppearance.Skip = 0;
MyChart.PlotArea.XAxis.LabelsAppearance.Step = 1;
MyChart.PlotArea.XAxis.MajorGridLines.Color = Color.Gray;
MyChart.PlotArea.XAxis.MinorGridLines.Color = Color.Gray;
MyChart.PlotArea.XAxis.TitleAppearance.Text = "Days";
MyChart.PlotArea.XAxis.TitleAppearance.Position = AxisTitlePosition.Center;
MyChart.PlotArea.XAxis.TitleAppearance.RotationAngle = 0;
foreach (string item in XAxisItems)
MyChart.PlotArea.XAxis.Items.Add(item);
}
{ //YAxis
MyChart.PlotArea.YAxis.MinValue = 0;
MyChart.PlotArea.YAxis.MaxValue = 100;
MyChart.PlotArea.YAxis.Step = 25;
MyChart.PlotArea.YAxis.AxisCrossingValue = 0;
MyChart.PlotArea.YAxis.Color = Color.Black;
MyChart.PlotArea.YAxis.MajorTickType = TickType.Outside;
MyChart.PlotArea.YAxis.MinorTickType = TickType.Outside;
MyChart.PlotArea.YAxis.Reversed = false;
MyChart.PlotArea.YAxis.LabelsAppearance.DataFormatString = "{0}%";
MyChart.PlotArea.YAxis.LabelsAppearance.RotationAngle = 0;
MyChart.PlotArea.YAxis.LabelsAppearance.Skip = 0;
MyChart.PlotArea.YAxis.LabelsAppearance.Step = 1;
MyChart.PlotArea.YAxis.MajorGridLines.Color = Color.Gray;
MyChart.PlotArea.YAxis.MinorGridLines.Color = Color.Gray;
MyChart.PlotArea.YAxis.TitleAppearance.Text = "CPU Load";
MyChart.PlotArea.YAxis.TitleAppearance.Position = AxisTitlePosition.Center;
MyChart.PlotArea.YAxis.TitleAppearance.RotationAngle = 0;
}
foreach (SeriesItem seriesItem in SeriesItems)
{
LineSeries lineSeries = new LineSeries();
lineSeries.Name = seriesItem.name;
lineSeries.Appearance.FillStyle.BackgroundColor = seriesItem.backgroundColor;
lineSeries.LabelsAppearance.DataFormatString = seriesItem.dataFormatString;
lineSeries.LabelsAppearance.Position = seriesItem.position;
lineSeries.LineAppearance.Width = seriesItem.lineWidth;
lineSeries.MarkersAppearance.BackgroundColor = seriesItem.markerBackgroundColor;
lineSeries.MarkersAppearance.MarkersType = seriesItem.markerType;
lineSeries.MarkersAppearance.Size = seriesItem.markerSize;
lineSeries.MarkersAppearance.BorderColor = seriesItem.markerBorderColor;
lineSeries.TooltipsAppearance.BackgroundColor = seriesItem.tooltipBackgroundColor;
lineSeries.TooltipsAppearance.DataFormatString = seriesItem.tooltipDataFormatString;
foreach (decimal value in seriesItem.Items)
lineSeries.Items.Add(value);
MyChart.PlotArea.Series.Add(lineSeries);
}
}
}
public class SeriesItem
{
public string name;
public Color backgroundColor;
public string dataFormatString;
public LineAndScatterLabelsPosition position;
public int lineWidth;
public Color markerBackgroundColor;
public MarkersType markerType;
public int markerSize;
public Color markerBorderColor;
public Color tooltipBackgroundColor;
public string tooltipDataFormatString;
public List<decimal> Items;
public SeriesItem(string Name, Color color)
{
name = Name;
backgroundColor = color;
dataFormatString = "{0}%";
position = LineAndScatterLabelsPosition.Above;
lineWidth = 1;
markerBackgroundColor = Color.Yellow;
markerType = MarkersType.Circle;
markerSize = 8;
markerBorderColor = Color.Green;
tooltipBackgroundColor = Color.White;
tooltipDataFormatString = "{0}%";
Items = new List<decimal>();
}
}
}
But when I want to use a method from the class, I have an error that says to me:
The call is ambiguous between the following methods or properties:
AdsignInt_V0._2.AdvertiserZone.ChartReports.SeriesItem.SeriesItem(string, System.Drawing.Color)
and
AdsignInt_V0._2.AdvertiserZone.ChartReports.SeriesItem.SeriesItem(string, System.Drawing.Color)
C:\Users\my media\Documents\Visual Studio 2013\Projects\AdsignInt_V0.2\AdsignInt_V0.2\AdvertiserZone\ChartReports\WebForm1.aspx.cs 27 34 AdsignInt_V0.2
Try cleaning the solution and the temporary ASP files, then rebuild. Most likely, the last build has assemblies that point to the same class name.
Also, the SeriesItem class is the old class that used to define RadHtmlChart series items, so you may want to change its name to avoid any conflicts. The current classes for series items are listed here: http://www.telerik.com/help/aspnet-ajax/htmlchart-server-side-api-configure-series-items.html.
On a side note - I do not think you need a new series for each series item, so you may want to put the foreach loop for the series items after the series creation.
I define de System.Drawing in top.
using Draw = System.Drawing;
After if I need use System.Drawing I use it with Draw.
Sample:
public SeriesItem(string Name, Draw.Color color)
{
name = Name;
backgroundColor = color;
dataFormatString = "{0}%";
position = LineAndScatterLabelsPosition.Above;
lineWidth = 1;
markerBackgroundColor = Draw.Color.Yellow;
markerType = MarkersType.Circle;
markerSize = 8;
markerBorderColor = Draw.Color.Green;
tooltipBackgroundColor = Draw.Color.White;
tooltipDataFormatString = "{0}%";
Items = new List<decimal>();
}

How do I display StringLabelValue?

I'm use Teechart version .Net & VS2005.
X-axis of the graph type of date and time, Y-axis was added to the Point Series.
I want to show the StringLabelValue.
My Code :
private void GridPoint()
{
datatable dt_point = new datatable();
Steema.TeeChart.Styles.Points Pinpoint = new Steema.TeeChart.Styles.Points();
TChart1.Series.Add(Pinpoint);
Pinpoint.Pointer.Visible = false;
Pinpoint.Pointer.InflateMargins = false;
Pinpoint.Pointer.Transparency = 100;
Pinpoint.Pointer.Pen.Visible = false;
Pinpoint.Marks.Color = Color.White;
Pinpoint.Marks.Pen.Color = Color.White;
Pinpoint.Marks.Shadow.Visible = false;
Pinpoint.Marks.Visible = true;
Steema.TeeChart.Axis axis = new Steema.TeeChart.Axis();
TChart1.Axes.Custom.Add(axis);
axis.StartPosition = 9;
axis.EndPosition = 9;
axis.Labels.Items.Add(0, " ");
axis.Labels.Items.Add(2000, " ");
axis.Labels.Items[0].Visible = false;
axis.Labels.Items[1].Visible = false;
axis.Title.Caption = "";
axis.Title.Font.Color = Color.Black;
TChart1.Series[0].CustomVertAxis = axis;
TChart1.Series[0].Clear();
if (dt_Point.Columns.Count == 0)
{
dt_Point.Columns.Add("SetTime", typeof(DateTime));
dt_Point.Columns.Add("Value", typeof(int));
dt_Point.Columns.Add("Label", typeof(string));
}
DataRow row;
row = dt_Point.NewRow();
row["SetTime"] = "2012-08-02 18:14:24";
row["Value"] = 100;
row["Label"] = "Point";
dt_Point.Rows.Add(row);
TChart1.Series[0].XValues.DataMember = "SetTime";
TChart1.Series[0].YValues.DataMember = "Value";
TChart1.Series[0].DataMember = "Label";
TChart1.Series[0].DataSource = dt_Point;
}
show the Graph :
I want to show graph:
I recommend that you set XValues.DateTime to true and change the DateTimeFormat and Style of the Bottom Axis labels to achieve the result that you want:
//XValues as DateTimeValues.
Pinpoint.XValues.DateTime = true;
//Labels axes style and format
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss";
tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Value;

Why Doesn't MSChart Fill Entire Chart Area?

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;

Categories

Resources