title: VB.Net Dynamic chart creation. Layout help needed
body: <p>First off all, English is not! my first/native language.</p>
  
  <p>For my internship @ this company I'm trying to collect some data. There are like 200 PC's in the network. All HP SFF PCs. All the pcs will be overwritten with a company disk image containing software and policies. They also get an bios update. But as the months go by these versions get outdated. Not that it is required to update the bios, we want to now which version in on which pc on which model.</p>
  
  <p>There are several PC models. 
  E.g. HP DC7600, HP 7700.</p>
  
  <p>There are several bios versions.
  E.g. 786G1 v01.10, 786G1 v01.16</p>
  
  <p>I'm collecting this data with the following method. Every one has a network share to a certain disk.(Company documents).</p>
  
  <p>For the <strong>client</strong> side I'm using WMI(Windows Management Instrumentation) to gather the information needed.</p>
  
  <pre><code>Sub RetrieveInfo()
      Dim _PCName As String = My.Computer.Name
      Dim _Info As String = vbNullString
      Dim _FileName As String = "G:\BiosVersion\" &amp; _PCName &amp; ".txt"
      Dim _ManagmentC As New ManagementClass("Win32_ComputerSystem")
      Dim _Moc As ManagementObjectCollection = _ManagmentC.GetInstances
  
      For Each _Mo As ManagementObject In _Moc
          Dim Model() As String = Split(_Mo.Properties("Model").Value.ToString, " ")
          For i = 0 To Model.Length - 1
              If Model(i).ToLower.Contains("dc") Then _Info &amp;= Model(i)
          Next
      Next
  
      _ManagmentC = New ManagementClass("win32_bios")
      _Moc = _ManagmentC.GetInstances
      For Each _Mo As ManagementObject In _Moc
          _Info &amp;= "|" &amp; _Mo.Properties("SMBIOSBIOSVersion").Value.ToString
      Next
  
      Try
          If IO.File.Exists(_FileName) Then
              IO.File.Delete(_FileName)
          End If
      Catch ex As IO.IOException
          _FileName = _FileName.Replace(_PCName, _PCName &amp; "-" &amp; New Random().Next(10, 10000))
      End Try
  
      IO.File.WriteAllText(_FileName, _Info)
  
  End Sub
  </code></pre>
  
  <p>As you can see, this creates as text file in the share with the String PCName (e.g. PC1001).
  It writes both the PC Model number &amp; Bios version to the text file. (e.g. dc7900|786G1 v01.16)</p>
  
  <hr>
  
  <p>For the <strong>server</strong> side, the chart building part, I'm doing the following.</p>
  
  <pre><code>Dim Path As String = "G:\BiosVersion\"
  Sub UpdateChart()
      Dim PCModels As New List(Of String)
      Dim BiosVersions As New List(Of String)
      Dim Files As IO.FileInfo() = New IO.DirectoryInfo(Path).GetFiles
  
      For Each File As IO.FileInfo In Files
          If File.Extension = ".txt" Then
              PCModels.Add(IO.File.ReadAllText(File.FullName).Split("|")(0))
              BiosVersions.Add(IO.File.ReadAllText(File.FullName).Split("|")(1))
          End If
      Next
      PCModels = RemoveDuplicates(PCModels)
      BiosVersions = RemoveDuplicates(BiosVersions)
  
      For i = 0 To chartBios.Series.Count - 1
          chartBios.Series.Remove(chartBios.Series.Item(i))
      Next
  
      Dim Dictionary As New Dictionary(Of String, Integer)
      For Each Version As String In BiosVersions
          chartBios.Series.Add(Version)
          Dim Count As Integer = 0
          For Each File As IO.FileInfo In Files
              If IO.File.ReadAllText(File.FullName).Split("|")(1).ToLower.Trim = Version.ToLower.Trim Then
                  Count += 1
              End If
          Next
          Dictionary.Add(Version, Count)
      Next
  
      For Each Entry As KeyValuePair(Of String, Integer) In Dictionary
          chartBios.Series(Entry.Key).Points.AddY(Entry.Value)
      Next
  End Sub
  
  Function RemoveDuplicates(ByVal inputList As List(Of String)) As List(Of String)
      Dim uniqueStore As New Dictionary(Of String, Integer)()
      Dim finalList As New List(Of String)()
      For Each currValue As String In inputList
          If Not uniqueStore.ContainsKey(currValue) Then
              uniqueStore.Add(currValue, 0)
              finalList.Add(currValue)
          End If
      Next
      Return finalList
  End Function
  </code></pre>
  
  <p>chartBios = the chart control.</p>
  
  <p><em><strong>Which results in the following:</em></strong>
  I can't post any images yet(Spam Prevention)
  <a href="http://i.imgur.com/bGpyH.jpg" rel="nofollow">http://i.imgur.com/bGpyH.jpg</a></p>
  
  <p>What I'm trying to do is the following.
  I have 3 Vars, Bios version, How many times each version is installed &amp; model name.</p>
  
  <h1><em><strong>This is an example of the Chart layout that I want. Anyone has any idea on how to create this layout ? At runtime or static I don't care as long at it can be filled at Runtime.</em></strong></h1>
  
  <p>For each Bios version number there must be a bar for each PC Model with a label which represents the amount of times the bios version is installed.</p>
  
  <p>Example:
  I can't post any images yet(Spam Prevention)
  <a href="http://i.imgur.com/tP0Sf.jpg" rel="nofollow">http://i.imgur.com/tP0Sf.jpg</a></p>