title: Powershell to create line chart from EXCEL
body: <p>My powershell script inputs data into EXCEL worksheet</p>
  
  <p><img src="https://i.stack.imgur.com/o3X4Z.png" alt="enter image description here"></p>
  
  <p>and I am trying to create a line chart that will resemble </p>
  
  <p><img src="https://i.stack.imgur.com/hShmm.png" alt="enter image description here"></p>
  
  <p>However, this is the code I have so far:</p>
  
  <pre><code>$xlConditionValues=[Microsoft.Office.Interop.Excel.XLConditionValueTypes]
  $xlTheme=[Microsoft.Office.Interop.Excel.XLThemeColor]
  $xlChart=[Microsoft.Office.Interop.Excel.XLChartType]
  $xlIconSet=[Microsoft.Office.Interop.Excel.XLIconSet]
  $xlDirection=[Microsoft.Office.Interop.Excel.XLDirection]
  
  ...
  
  $chart=$ws.Shapes.AddChart().Chart
  $chart.chartType=$xlChart::xlBarClustered
  
  $start=$ws.range("A1")
  
  $Y=$ws.Range($start,$start.End($xlDirection::xlDown))
  
  $start=$ws.range("B2")
  
  $X=$ws.Range($start,$start.End($xlDirection::xlDown))
  
  $chartdata=$ws.Range("A$($Y.item(1).Row):A$($Y.item($Y.count).Row),B$($X.item(1).Row):B$($X.item($X.count).Row)")
  $chart.SetSourceData($chartdata)
  
  #add labels
  $chart.seriesCollection(1).Select() | Out-Null
  $chart.SeriesCollection(1).ApplyDataLabels() | out-Null
  
  #modify the chart title
  $chart.ChartTitle.Text = "Number of Computer"
  
  
  $ws.shapes.item("Chart 1").top=40
  </code></pre>
  
  <p>And this is the graph it generates</p>
  
  <p><img src="https://i.stack.imgur.com/s5IqL.png" alt="enter image description here"></p>
  
  <p>How do I even begin to fix this? Any helpful tutorials?</p>