Home Forums WinForms controls Xceed Chart for WinForms Real Time Line Series 3

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18864 |

    Hello,

    It is like that.
    I give u example.

    public partial class GSMChart : Window
    {
    ChartControl objChartControl;
    Chart objChart;
    ChartLabel objChartLabel;

    LineSeries[] objLineSeries;
    string SelectedChart = “”;
    Timer objTimer;

    public GSMChart()
    {
    InitializeComponent();
    objChartControl = new ChartControl();
    objChart = new Chart();

    }

    void btnStart_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
    LoadGraph();

    #region –> Adds Chart To WindowsFormsHost <–
    WindowsFormsHost objWindowsFormsHost = new WindowsFormsHost();
    objWindowsFormsHost.Child = objChartControl;
    objWindowsFormsHost.Margin = new Thickness(5);
    grdChart.Children.Add(objWindowsFormsHost);
    #endregion

    SetTimer();
    }

    void LoadGraph()
    {
    objChartControl.Settings.RenderDevice = RenderDevice.OpenGL;
    objChartControl.Background.FillEffect.SetSolidColor(Color.AliceBlue);

    ((Legend)objChartControl.Legends[0]).Mode = LegendMode.Automatic;

    objChart = objChartControl.Charts[0];

    objChart.View.SetPredefinedProjection(PredefinedProjection.Orthogonal);
    objChart.MarginMode = MarginMode.Stretch;
    objChart.Margins = new RectangleF(10, 10, 80, 80);
    objChart.Axis(StandardAxis.Depth).Visible = false;
    objChart.Axis(StandardAxis.PrimaryY).AxisStyle = AxisStyle.Line;
    objChart.Axis(StandardAxis.PrimaryY).MajorGridLine.Pattern = Xceed.Chart.GraphicsCore.LinePattern.Dot;

    objChart.Wall(ChartWallType.Left).Width = 0.0f;
    objChart.Wall(ChartWallType.Floor).Width = 0.0f;
    objChart.Wall(ChartWallType.Left).Visible = true;
    objChart.Axis(StandardAxis.PrimaryX).DimensionScale.AutoLabels = false;
    objChart.Axis(StandardAxis.PrimaryY).MajorGridLine.Color = Color.DarkSlateGray;
    objChart.Axis(StandardAxis.PrimaryX).DimensionScale.NumberOfDataPointsBetweenLabels = 5;
    objChart.Axis(StandardAxis.PrimaryX).DimensionScale.NumberOfDataPointsBetweenTicks = 5;

    objLineSeries = new LineSeries[InitialData.Rows.Count];

    for (int i = 0; i <= InitialData.Rows.Count-1; i++)
    {
    objLineSeries[i] = (LineSeries)objChart.Series.Add(SeriesType.Line);
    objLineSeries[i].Name = InitialData.Rows[i][“GroupName”].ToString();
    objLineSeries[i].MultiLineMode = MultiLineMode.Series;
    objLineSeries[i].DataLabels.Mode = DataLabelsMode.Every;
    objLineSeries[i].Values.ValueFormatting.Format = ValueFormat.CustomNumber;
    objLineSeries[i].Values.ValueFormatting.CustomFormat = “0.0”;

    ////objLineSeries[i].LineBorder.Color = Color.DarkOrange;
    //objLineSeries[i].Appearance.LineMode = AppearanceLineMode.DataPoints;
    //objLineSeries[i].Appearance.FillMode = AppearanceFillMode.DataPoints;
    //objLineSeries[i].Appearance.FillEffects.FillRandom(i);

    objLineSeries[i].Values.FillRandom(5);
    objLineSeries[i].LineBorder.Color = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255));

    objLineSeries[i].LineBorder.Width = 2;
    objLineSeries[i].LineFillEffect.SetSolidColor(Color.DarkBlue);
    objChartControl.Refresh();
    }
    }

    void SetTimer()
    {
    objTimer = new Timer();
    SetInterval(Convert.ToInt32(nmHour.GSMValue), Convert.ToInt32(nmMinute.GSMValue), Convert.ToInt32(nmSecond.GSMValue));
    objTimer.Tick += new EventHandler(objTimer_Tick);
    objTimer.Start();
    }

    void objTimer_Tick(object sender, EventArgs e)
    {
    for (int i = 0; i <= InitialData.Rows.Count-1; i++)
    {
    objLineSeries[i].Values.Add(Convert.ToDouble(InitialData.Rows[i][SelectedChart]));

    objChartControl.Refresh();
    }
    }

    private void SetInterval(int hour, int minute, int second)
    {
    if (second > 0)
    {
    int _TotalSeconds = 0;

    _TotalSeconds = ((hour * 3600) + (minute * 60) + second) * 1000;

    objTimer.Interval = _TotalSeconds;
    }
    }

    void btnVoltage_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
    objChart.Series.Clear();

    LoadGraph();

    SetChartLabel(“Voltage”);
    SelectedChart = “Voltage”;
    SetChartButtonFlag(false, true, false, false, false, false, false, false, false);
    }

    void SetChartLabel(string _ChartName)
    {
    if (objChartControl != null)
    {
    if (objChartLabel != null)
    {
    objChartControl.Labels.Remove(objChartLabel);
    }

    objChartLabel = objChartControl.Labels.AddHeader(_ChartName);
    objChartLabel.TextProps.Backplane.Visible = false;
    objChartLabel.TextProps.FillEffect.Color = Color.Navy;
    objChartLabel.TextProps.Shadow.Type = ShadowType.Solid;
    objChartLabel.TextProps.HorzAlign = HorzAlign.Left;
    objChartLabel.TextProps.VertAlign = VertAlign.Top;
    objChartLabel.HorizontalMargin = 4;
    objChartLabel.VerticalMargin = 4;
    }
    }
    }

    so the scene is like that.
    Line series shows Power,Voltage,Current,MaxCurrent,Temp,Sensor1,2,3,4 for each device according to values in database.
    It is according to user selectes device from form.
    Devices can be single or multiple.
    If for ex DS62 ,NYCE controller are there then 2 line series wll be shown in real time line series.
    if user selectes 3 Devices then 3 line series wll be there in chart.
    Like wise according to user selects devices in form that no. of lines wll be shown.
    I dont How many but it depends on user selection.
    so we cant fix line colors for lines.
    coz I dont know how many devices user selects each time,and how many lines wll be generated.
    so I want that random line colors for each line in chart.
    If u got this prob then plz help me soon.
    I m waiting for y r reply.

    And Thanx a lot for previous ans of 2 ques.
    Thanx in advance for this ques.

    Khushboo

    Imported from legacy forums. Posted by khushboo (had 2249 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi!!!!!

    I got my answer.

    Thanx & Regards,
    Khushboo

    Imported from legacy forums. Posted by khushboo (had 3627 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.