func termdashValueFormatter(cfg model.Widget) (linechart.ValueFormatter, error) {
	axisUnit := cfg.Graph.Visualization.YAxis.Unit
	axisDecimals := cfg.Graph.Visualization.YAxis.Decimals
	f, err := unit.NewUnitFormatter(axisUnit)
	if err != nil {
		return nil, err
	}
	if axisUnit == "" && axisDecimals == 0 {
		axisDecimals = 2
	}
	return func(value float64) string {
		return f(value, axisDecimals)
	}, nil
}
termdashValueFormatter will get a termdashValueFormatter based
on the widget configuration.
package termdash
import (
	"fmt"
	"math"
	"github.com/mum4k/termdash/cell"
	"github.com/mum4k/termdash/container"
	"github.com/mum4k/termdash/container/grid"
	"github.com/mum4k/termdash/linestyle"
	"github.com/mum4k/termdash/widgets/linechart"
	"github.com/mum4k/termdash/widgets/text"
	"github.com/slok/grafterm/internal/model"
	"github.com/slok/grafterm/internal/service/unit"
	"github.com/slok/grafterm/internal/view/render"
)
const (
	fullPerc              = 99
	graphHorizontalPerc   = 80
	legendHorizontalPerc  = 19
	paddingHorizontalPerc = 10
	graphVerticalPerc     = 90
	legendVerticalPerc    = 4
	paddingVerticalPerc   = 50
	legendCharacter       = `⠤⠤`
	axesColor             = 8
	yAxisLabelsColor      = 15
	xAxisLabelsColor      = 248
)
type graph struct {
	cfg model.Widget
	widgetGraph  *linechart.LineChart
	widgetLegend *text.Text
	element      grid.Element
}
func newGraph(cfg model.Widget) (*graph, error) {
	vf, err := termdashValueFormatter(cfg)
	if err != nil {
		return nil, err
	}
	lc, err := linechart.New(
		linechart.AxesCellOpts(cell.FgColor(cell.ColorNumber(axesColor))),
		linechart.YLabelCellOpts(cell.FgColor(cell.ColorNumber(yAxisLabelsColor))),
		linechart.XLabelCellOpts(cell.FgColor(cell.ColorNumber(xAxisLabelsColor))),
		linechart.YAxisAdaptive(),
		linechart.YAxisFormattedValues(vf),
	)
	if err != nil {
		return nil, err
	}
	var element grid.Element
	var txt *text.Text
	if !cfg.Graph.Visualization.Legend.Disable {
		txt, err = text.New(text.WrapAtRunes())
		if err != nil {
			return nil, err
		}
	}
	element = elementFromGraphAndLegend(cfg, lc, txt)
	return &graph{
		widgetGraph:  lc,
		widgetLegend: txt,
		cfg:          cfg,
		element:      element,
	}, nil
}