protected void Page_Load(object sender, System.EventArgs e) { // Set Marker shape to image if (Shape.SelectedItem.Value == "Image") { if (!ApplyToPoint.Checked) { Chart1.Series["Default"].MarkerImage = "Face.bmp"; Chart1.Series["Default"].MarkerImageTransparentColor = Color.White; } else { Chart1.Series["Default"].Points[2].MarkerImage = "Face.bmp"; Chart1.Series["Default"].Points[2].MarkerImageTransparentColor = Color.White; } // Disable color and size controls MarkerSize.Enabled = false; MarkerColor.Enabled = false; MarkerBorderColor.Enabled = false; Dropdownlist1.Enabled = false; } // Set "bubble" series shape else { if (!ApplyToPoint.Checked) { Chart1.Series["Default"].MarkerStyle = (MarkerStyle)MarkerStyle.Parse(typeof(MarkerStyle), Shape.SelectedItem.Value); } else { Chart1.Series["Default"].Points[2].MarkerStyle = (MarkerStyle)MarkerStyle.Parse(typeof(MarkerStyle), Shape.SelectedItem.Value); } // Enable color and size controls MarkerSize.Enabled = true; MarkerColor.Enabled = true; MarkerBorderColor.Enabled = true; Dropdownlist1.Enabled = true; } if (!ApplyToPoint.Checked) { Chart1.Series["Default"].MarkerSize = Int32.Parse(MarkerSize.SelectedItem.Text); Chart1.Series["Default"].MarkerColor = Color.FromName(MarkerColor.SelectedItem.Value); Chart1.Series["Default"].MarkerBorderColor = Color.FromName(MarkerBorderColor.SelectedItem.Value); Chart1.Series["Default"].MarkerBorderWidth = Int32.Parse(Dropdownlist1.SelectedItem.ToString()); } else { Chart1.Series["Default"].Points[2].MarkerSize = Int32.Parse(MarkerSize.SelectedItem.Text); Chart1.Series["Default"].Points[2].MarkerColor = Color.FromName(MarkerColor.SelectedItem.Value); Chart1.Series["Default"].Points[2].MarkerBorderColor = Color.FromName(MarkerBorderColor.SelectedItem.Value); Chart1.Series["Default"].Points[2].MarkerBorderWidth = Int32.Parse(Dropdownlist1.SelectedItem.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { startDate.Value = DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd"); endDate.Value = DateTime.Now.ToString("yyyy-MM-dd"); BindCustomerDDL(); var customerId = Request.QueryString["CustomerId"]; if (!string.IsNullOrEmpty(customerId)) { ddlCustomer.SelectedValue = customerId; } } DataTable dt = GetExpenseTrendData(); int poinsCount = dt.Rows.Count; decimal[] percentValues = new decimal[poinsCount]; string[] xValues = new string[poinsCount]; int[] yValues = new int[poinsCount]; int sumY = 0; for (int i = 0; i < poinsCount; i++) { yValues[i] = Convert.ToInt32(dt.Rows[i]["YVALUE"]); xValues[i] = "" + dt.Rows[i]["XVALUE"]; sumY += yValues[i]; } sumY = sumY == 0 ? 1 : sumY; for (int i = 0; i < poinsCount; i++) { percentValues[i] = 100 * yValues[i] / sumY; } Chart1.Series["Series1"].Points.DataBindXY(xValues, yValues); for (int i = 0; i < poinsCount; i++) { Chart1.Series["Series1"].Points[i].ToolTip = string.Format("{0}消费金额{1}元,占{2}%", xValues[i], yValues[i], percentValues[i]); } // Set "bubble" series shape Chart1.Series["Series1"].MarkerStyle = (MarkerStyle)MarkerStyle.Parse(typeof(MarkerStyle), Shape.SelectedItem.Value); // Set max bubble size Chart1.Series["Series1"]["BubbleMaxSize"] = MaxSize.SelectedItem.Text; // Show as 2D or 3D if (Show3D.Checked) { Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; } else { Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false; } }
protected void Page_Load(object sender, System.EventArgs e) { // Set bubble series shape to image if (Shape.SelectedItem.Value == "Image") { Chart1.Series["Series1"].MarkerImage = "Face.bmp"; Chart1.Series["Series1"].MarkerImageTransparentColor = Color.White; } // Set "bubble" series shape else { Chart1.Series["Series1"].MarkerStyle = (MarkerStyle)MarkerStyle.Parse(typeof(MarkerStyle), Shape.SelectedItem.Value); } // Set max bubble size Chart1.Series["Series1"]["BubbleMaxSize"] = MaxSize.SelectedItem.Text; Chart1.Series["Series2"]["BubbleMaxSize"] = MaxSize.SelectedItem.Text; // Show Y value or bubble sise as point labels Chart1.Series["Series1"].IsValueShownAsLabel = true; Chart1.Series["Series2"].IsValueShownAsLabel = true; if (BubbleSizeSizeForLabel.Checked) { Chart1.Series["Series1"]["BubbleUseSizeForLabel"] = "true"; Chart1.Series["Series2"]["BubbleUseSizeForLabel"] = "true"; } // Set scale for the bubble size if (ScaleMin.SelectedItem.Text != "Auto") { Chart1.Series["Series1"]["BubbleScaleMin"] = ScaleMin.SelectedItem.Text; Chart1.Series["Series2"]["BubbleScaleMin"] = ScaleMin.SelectedItem.Text; } if (ScaleMax.SelectedItem.Text != "Auto") { Chart1.Series["Series1"]["BubbleScaleMax"] = ScaleMax.SelectedItem.Text; Chart1.Series["Series2"]["BubbleScaleMax"] = ScaleMax.SelectedItem.Text; } // Show as 2D or 3D if (Show3D.Checked) { Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; } else { Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false; } }
private void UpdateChartSettings() { // Set bubble series shape to image if (comboBoxShape.Text == "Image") { // Get image path System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm mainForm = (System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm) this.ParentForm; string imageFileName = mainForm.CurrentSamplePath; imageFileName += "\\Face.bmp"; chart1.Series["Default"].MarkerImage = imageFileName; chart1.Series["Default"].MarkerImageTransparentColor = Color.White; chart1.Series["Default"].MarkerStyle = MarkerStyle.None; } // Set "bubble" series shape else { chart1.Series["Default"].MarkerImage = ""; chart1.Series["Default"].MarkerStyle = (MarkerStyle)MarkerStyle.Parse(typeof(MarkerStyle), comboBoxShape.Text); } // Set max bubble size chart1.Series["Default"]["BubbleMaxSize"] = comboBoxMaxSize.Text; // Show Y value or bubble sise as point labels chart1.Series["Default"].IsValueShownAsLabel = true; if (checkBoxShowSizeInLabel.Checked) { chart1.Series["Default"]["BubbleUseSizeForLabel"] = "true"; } else { chart1.Series["Default"]["BubbleUseSizeForLabel"] = "false"; } // Set scale for the bubble size if (comboBoxMinScale.Text != "Auto") { chart1.Series["Default"]["BubbleScaleMin"] = comboBoxMinScale.Text; } else { chart1.Series["Default"].DeleteCustomProperty("BubbleScaleMin"); } if (comboBoxMaxScale.Text != "Auto") { chart1.Series["Default"]["BubbleScaleMax"] = comboBoxMaxScale.Text; } else { chart1.Series["Default"].DeleteCustomProperty("BubbleScaleMax"); } if (checkBoxShow3D.Checked) { chart1.ChartAreas["Default"].Area3DStyle.Enable3D = true; } else { chart1.ChartAreas["Default"].Area3DStyle.Enable3D = false; } }