func (gv *graphicalVisualizer) getProgressBars(bg *termui.MBarChart) error {

	var barIntList [2][]int
	var barStringList []string

	var barLabel string
	var cellIndex int
	maxTotal := -1

	cells, err := gv.appExaminer.ListCells()
	if err != nil {
		return err
	}

	for i, cell := range cells {

		if cell.Missing {
			barLabel = fmt.Sprintf("Missing")

		} else if cell.RunningInstances == 0 && cell.ClaimedInstances == 0 && !cell.Missing {
			barLabel = fmt.Sprintf("Empty")
			barIntList[0] = append(barIntList[0], 0)
			barIntList[1] = append(barIntList[1], 0)
		} else {

			cellNames := strings.Split(cell.CellID, "-")
			if len(cellNames) == 3 { //The cell name is usually of the form lattice-cell-[CellNumber]
				cellIndex, _ = strconv.Atoi(cellNames[2])
			} else { //Otherwise print the index of this cell
				cellIndex = i + 1
			}
			total := cell.RunningInstances + cell.ClaimedInstances
			barIntList[0] = append(barIntList[0], cell.RunningInstances)
			barIntList[1] = append(barIntList[1], cell.ClaimedInstances)
			barLabel = fmt.Sprintf("cell-%d", cellIndex)
			if total > maxTotal {
				maxTotal = total
			}
		}
		barStringList = append(barStringList, barLabel)
	}

	bg.Data[0] = barIntList[0]
	bg.Data[1] = barIntList[1]
	bg.DataLabels = barStringList
	if maxTotal < 10 {
		bg.SetMax(10)
	} else {
		bg.SetMax(maxTotal)
	}
	return nil
}
func (gv *graphicalVisualizer) getProgressBars(bg *termui.MBarChart) error {
	cells, err := gv.appExaminer.ListCells()
	if err != nil {
		return err
	}

	cellBars := []cellBar{}
	maxTotal := -1
	for _, cell := range cells {
		var bar cellBar
		if cell.Missing {
			bar = cellBar{label: "Missing"}
		} else {
			index := 0
			if strings.HasPrefix(cell.CellID, "cell-") {
				s := cell.CellID[5:len(cell.CellID)]
				if cellIndexInt, err := strconv.Atoi(s); err == nil {
					index = cellIndexInt
				}
			}

			bar = cellBar{
				label:   cell.CellID,
				index:   index,
				running: cell.RunningInstances,
				claimed: cell.ClaimedInstances,
			}

			total := cell.RunningInstances + cell.ClaimedInstances
			if total > maxTotal {
				maxTotal = total
			}
		}
		cellBars = append(cellBars, bar)
	}

	sort.Sort(cellBarSliceSortedByLabelNumber(cellBars))

	bg.Data[0] = getRunningFromBars(cellBars)
	bg.Data[1] = getClaimedFromBars(cellBars)
	bg.DataLabels = getLabelFromBars(cellBars)

	if maxTotal < 10 {
		bg.SetMax(10)
	} else {
		bg.SetMax(maxTotal)
	}

	return nil
}