/// <summary> /// Creates a 1D histogram. /// </summary> /// <param name="rawData">An array of 1D data that contains the data to be binned.</param> /// <param name="lowBound">The data that represents the low bound of the histogram.</param> /// <param name="highBound">The data that represents the high bound of the histogram.</param> /// <param name="nBins">The number of bins that the data will pe placed in, between lo-bound and hi-bound.</param> /// <param name="name">The name of the histogram.</param> /// <param name="guid">The guid of the histogram.</param> // ReSharper disable once PublicConstructorInAbstractClass public Histogram1D_Base(Array rawData, object lowBound, object highBound, int nBins, string name, Guid guid) { m_rawData = rawData; m_lowBound = lowBound; m_highBound = highBound; m_name = name; Guid = guid; NumBins = nBins; m_labelProvider = DefaultLabelProvider; }
public string TrimLabelIfNeeded(LabelProvider provider) { string label = provider.Current; if (Text.CalcSize(label).x <= width) { return(label); } if (cache.TryGetValue(label, out string shorter)) { return(shorter); } return(TrimLabel(provider)); }
private static void PrintLabels() { ConsoleWriter.WriteInGreen("Fetching labels.."); var labelProvider = new LabelProvider(_service); List <Label> labels = labelProvider.GetLabels(); if (!labels.Any()) { ConsoleWriter.WriteInGreen("No labels found"); return; } foreach (var label in labels) { ConsoleWriter.WriteInGreen($"{label.LabelId}\t{label.LabelName}"); } }
public string TrimLabel(LabelProvider provider) { string original = provider.Current; string shorter = original; while (!shorter.NullOrEmpty()) { int length = shorter.Length; shorter = provider.Trim(); // The trimmer should always return a shorter length. If it doesn't we bail--it's a bad implementation. if (shorter.Length >= length) { break; } string withSuffix = provider.CurrentWithSuffix(suffix); Vector2 size = Text.CalcSize(withSuffix); if (size.x <= width) { cache.Add(original, withSuffix); return(shorter); } } return(original); }