diff --git a/tensorboard/components/vz_line_chart2/linear-scale.ts b/tensorboard/components/vz_line_chart2/linear-scale.ts index b4174e481a9..2ec68030f9b 100644 --- a/tensorboard/components/vz_line_chart2/linear-scale.ts +++ b/tensorboard/components/vz_line_chart2/linear-scale.ts @@ -30,10 +30,12 @@ export class LinearScale extends Plottable.Scales.Linear implements ITfScale { /** * Adds some padding to a given domain. Specifically, it: - * - returns about [-0.1a, 2.1a] when a = b and a >= 0. - * - returns about [-2.1a, 0.1a] when a = b and a < 0. + * - returns about [-0.1a - c, 2.1a + c] when a = b and a >= 0. + * - returns about [-2.1|a| - c, -0.1|a| + c] when a = b and a < 0. * - returns [-0.1b, b + padProportion * (b-a)] if b > 2a and a > 0 * - else, pads by `padProportion` + * Note that `c` is a constant offset which specifically is 1.1. Please refer + * to [1] for its rationale. * @override */ protected _niceDomain(domain: number[], count?: number): number[] { @@ -51,10 +53,10 @@ export class LinearScale extends Plottable.Scales.Linear implements ITfScale { let lower: number; if (a >= 0 && a < span) { - // We include the intercept (y = 0) if doing so less than doubles the span - // of the y-axis. (We actually select a lower bound that's slightly less - // than 0 so that 0.00 will clearly be written on the lower edge of the - // chart. The label on the lowest tick is often filtered out.) + // [1]: We include the intercept (y = 0) if doing so less than doubles the + // span of the y-axis. (We actually select a lower bound that's slightly + // less than 0 so that 0.00 will clearly be written on the lower edge of + // the chart. The label on the lowest tick is often filtered out.) lower = -0.1 * b; } else { lower = a - padding; diff --git a/tensorboard/components/vz_line_chart2/log-scale.ts b/tensorboard/components/vz_line_chart2/log-scale.ts index 0b07301aee5..035ee2ffcc2 100644 --- a/tensorboard/components/vz_line_chart2/log-scale.ts +++ b/tensorboard/components/vz_line_chart2/log-scale.ts @@ -17,7 +17,7 @@ namespace vz_line_chart2 { const MIN_VALUE = 1e-15; function log(x: number): number { - return Math.log(x) / Math.log(10); + return Math.log10(x); } function pow(x: number): number { diff --git a/tensorboard/components/vz_line_chart2/tf-scale.ts b/tensorboard/components/vz_line_chart2/tf-scale.ts index ad819f37a6e..c34f221e211 100644 --- a/tensorboard/components/vz_line_chart2/tf-scale.ts +++ b/tensorboard/components/vz_line_chart2/tf-scale.ts @@ -18,10 +18,7 @@ export type ValueProviderForDomain = () => number[]; /** * Plottable.Scale is a class that wraps the d3.scale that adds many utility - * methods that work with the Plottable's `dataset` concept. Here, we will - * attempt to explain few basic concepts in plain English. - * - domain: [f(min(x)), f(max(x))] - * - range: pixel values of the chart + * methods that work with the Plottable's `dataset` concept. * * Plottable.Scale provides some cool feature where a scale is bound to set of * plots (i.e., line, scatter, smooth line chart, etc...) and, when a dataset @@ -72,7 +69,8 @@ export abstract class TfScale extends Plottable.QuantitativeScale implem /** * Returns possible `extent`s for a dataset. Note that a dataset can contain * multiple series. - * Unlike the method name suggests, it uses `values` to return `extent`s. + * Unlike the method name suggests, it uses values from each series to + * return `extent`s. * @override */ protected _getAllIncludedValues(ignoreAttachState = false): number[] {