通过添加两个图表的Y值获取最小值和最大值 [英] Get Min and Max value From adding Y Values of Two Charts

查看:69
本文介绍了通过添加两个图表的Y值获取最小值和最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

在我的情况下,我有两个图表,两个图表的y值之和导致我的JOB< Component>的直径。从每个点的直径我想要最大值和最小值。我使用下面的代码但是每次我得到0时都是最小值。

In my case i have two charts and the sum of y values of both charts results into diameter of my JOB<Component>. From the diameter of each point i want the max and min value.I am using code below but in min value every time i am getting 0.

Dim val As Integer = Chart2.Series(0).Points.Count
        Dim a(val) As Decimal
        Dim i As Integer
        For Each Pt1 As DataPoint In Chart2.Series(0).Points
            For Each Pt2 As DataPoint In Chart3.Series(0).Points

                i = i + 1
                a(i) = Pt1.YValues(0) + Pt2.YValues(0)
            Next
            i = 0
        Next
        Dim i_min As Integer = LBound(a)
        Dim i_max As Integer = UBound(a)

        Dim Max As Integer = a(i_min)
        Dim Min As Integer = a(i_min)
        For i = i_min + 1 To i_max
            If a(i) > Max Then
                Max = a(i)
            ElseIf a(i) < Min Then
                Min = a(i)
            End If
        Next
        TextBox9.Text = Min.ToString
        TextBox8.Text = Max.ToString

推荐答案

Hello Tech,

Hello Tech,

     试试这个代码..我没有测试但是应该工作或者想一想你要做什么。如果要使用数组。您需要使用System.Math.Min和System.Math.Max。我做的是制作双打列表并获得它的
最小值和最大值..

      Try this code.. I have not tested but should work or give idea of what you have to do it. If you want to use an array. You need to use the System.Math.Min and System.Math.Max. What i did is make list of doubles and get the min and max value of it..

我有一件事有问题..如果你的图表没有来了y数据点的数量,它有问题。和你的每个循环。它将是chart2的第一个值和循环遍历chart3的所有数据点,然后结束然后转到chart2中的
下一个数据点并再次循环遍历所有chart3数据点。每次执行此操作时,它将添加数字来自chart2的第一个数字,然后是chart3中的所有数字。

I have problem with one thing.. If your charts do not have the came amount of y datapoints its going have problem. and your for each loop. It will go the first value of chart2 and the loop through all the datapoints of the chart3, then end then go to the next datapoint in chart2 and loop through all chart3 datapoints again.. each time you do this it add the numbers first number from chart2 and then all the numbers from chart3.

例子...... 1 + 1,1 + 2,1 + 3,1 + 4,1 + 5等(第一遍),2 + 1,2 + 2,2 + 3,2 + 4,2 + 5等等。(第二遍)等等。我会一直这样做,直到你得到chart2中的最后一个值。

example... 1+1, 1+2,1+3,1+4,1+5,etc (first pass), 2+1,2+2,2+3,2+4,2+5,etc..(second pass), etc. I will keep doing this until you get last value in chart2.

Shane

        Dim a As New List(Of Double)
        Dim i As Integer

        For Each Pt1 As DataPoint In Chart2.Series(0).Points
            For Each Pt2 As DataPoint In Chart3.Series(0).Points
                a.Add((Pt1.YValues.GetValue(i) + Pt2.YValues.GetValue(i)))
                i += 1
            Next
        Next
        TextBox1.Text = a.Min.ToString
        TextBox2.Text = a.Max.ToString


这篇关于通过添加两个图表的Y值获取最小值和最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆