1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-05-01 22:17:51 +08:00

65 lines
2.3 KiB
Go
Raw Normal View History

2020-11-13 15:20:34 +08:00
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package axes
// label.go contains code that calculates the positions of labels on the axes.
import (
2020-11-18 16:01:09 +08:00
"errors"
2020-11-13 15:20:34 +08:00
"image"
)
// Label is one text label on an axis.
type Label struct {
// Label content.
Text string
// Position of the label within the canvas.
Pos image.Point
}
2020-11-18 16:01:09 +08:00
// yLabels returns labels that should be placed next to the cells.
2020-11-13 15:20:34 +08:00
// The labelWidth is the width of the area from the left-most side of the
// canvas until the Y axis (not including the Y axis). This is the area where
// the labels will be placed and aligned.
// Labels are returned with Y coordinates in ascending order.
// Y coordinates grow down.
func yLabels(graphHeight, labelWidth int, stringLabels []string) ([]*Label, error) {
2020-11-18 16:01:09 +08:00
return nil, errors.New("not implemented")
2020-11-13 15:20:34 +08:00
}
// rowLabel returns one label for the specified row.
// The row is the Y coordinate of the row, Y coordinates grow down.
func rowLabel(row int, label string, labelWidth int) (*Label, error) {
2020-11-18 16:01:09 +08:00
return nil, errors.New("not implemented")
2020-11-13 15:20:34 +08:00
}
2020-11-18 16:01:09 +08:00
// xLabels returns labels that should be placed under the cells.
2020-11-13 15:20:34 +08:00
// Labels are returned with X coordinates in ascending order.
// X coordinates grow right.
func xLabels(yEnd image.Point, graphWidth int, stringLabels []string, cellWidth int) ([]*Label, error) {
2020-11-18 16:01:09 +08:00
return nil, errors.New("not implemented")
2020-11-13 15:20:34 +08:00
}
// paddedLabelLength calculates the length of the padded label and
// the column index corresponding to the label.
// For example, the longest label's length is 5, like '12:34', and the cell's width is 3.
// So in order to better display, every three cells will display a label,
// the label belongs to the middle column of the three columns,
// and the padded length is 3*3, which is 9.
func paddedLabelLength(graphWidth, longest, cellWidth int) (l, index int) {
return
}