Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Windows.Forms.DataVisualization.Charting;
- namespace WindowsFormsApp4
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- chart1.ChartAreas[0].AxisY.Maximum = 10;
- chart1.ChartAreas[0].AxisY.Interval = (10 / 10) * 2;
- chart1.ChartAreas[0].AxisY2.Maximum = 10;
- chart1.ChartAreas[0].AxisY2.Interval = (10 / 10) * 2;
- chart1.ChartAreas[0].AxisY2.LabelStyle.Enabled = false;
- chart1.ChartAreas[0].AxisY2.MajorGrid.Enabled = false;
- }
- private void Add_Click(object sender, EventArgs e)
- {
- chart1.Series[0].Points.AddXY(DateTime.Now.ToString("HH:mm:ss"), PointBox.Text.Replace(',','.'));
- if (Convert.ToDouble(PointBox.Text) > chart1.ChartAreas[0].AxisY.Maximum)
- {
- double tal = Math.Ceiling(Convert.ToDouble(PointBox.Text));
- chart1.ChartAreas[0].AxisY.Maximum = tal;
- chart1.ChartAreas[0].AxisY.Interval = (tal / 10) * 2;
- chart1.ChartAreas[0].AxisY2.Maximum = tal;
- chart1.ChartAreas[0].AxisY2.Interval = (tal / 10) * 2;
- }
- }
- private void LeakButton_Click(object sender, EventArgs e)
- {
- chart1.ChartAreas[0].AxisY2.LabelStyle.Enabled = true;
- chart1.ChartAreas[0].AxisY2.MajorGrid.Enabled = true;
- chart1.ChartAreas[0].AxisY2.CustomLabels.Clear();
- Double CustomOne = -1;
- Double CustomTwo = -1;
- try
- {
- CustomOne = Convert.ToDouble(LeakOne.Text);
- }
- catch (System.FormatException)
- {
- }
- try
- {
- CustomTwo = Convert.ToDouble(LeakTwo.Text);
- }
- catch (System.FormatException)
- {
- }
- CustomLabel Leak1 = new CustomLabel
- {
- FromPosition = CustomOne+0.5,
- ToPosition = CustomOne-0.5,
- ForeColor = Color.Green,
- Text = "Leak A",
- GridTicks = System.Windows.Forms.DataVisualization.Charting.GridTickTypes.Gridline
- };
- chart1.ChartAreas[0].AxisY2.CustomLabels.Add(Leak1);
- CustomLabel Leak2 = new CustomLabel
- {
- FromPosition = CustomTwo+0.5,
- ToPosition = CustomTwo-0.5,
- ForeColor = Color.Red,
- Text = "Leak B",
- GridTicks = System.Windows.Forms.DataVisualization.Charting.GridTickTypes.Gridline
- };
- chart1.ChartAreas[0].AxisY2.CustomLabels.Add(Leak2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement