本文整理匯總了TypeScript中d3-scale.scalePow函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript scalePow函數的具體用法?TypeScript scalePow怎麽用?TypeScript scalePow使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了scalePow函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createConnectionStrokeWidthRangeScale
export function createConnectionStrokeWidthRangeScale(width: number) {
const rangeMax = CONNECTION_STROKE_WIDTH_RANGE_MAX_SCALE(width);
return scalePow<[number, number]>()
.exponent(2)
.range([[0.5, rangeMax[0]], [1, rangeMax[1]]]);
}
示例2: createPlaceStrokeWidthRangeScale
export function createPlaceStrokeWidthRangeScale(width: number) {
const rangeMin = PLACE_STROKE_WIDTH_RANGE_MIN_SCALE(width);
const rangeMax = PLACE_STROKE_WIDTH_RANGE_MAX_SCALE(width);
return scalePow<[number, number]>()
.exponent(2)
.range([[rangeMin[0], rangeMax[0]], [rangeMin[1], rangeMax[1]]]);
}
示例3: createPlaceRadiusRangeScale
export function createPlaceRadiusRangeScale(width: number) {
const rangeMin = PLACE_RADIUS_RANGE_MIN_SCALE(width);
const rangeMax = PLACE_RADIUS_RANGE_MAX_SCALE(width);
return scalePow<[number, number]>()
.exponent(2)
.range([[rangeMin[0], rangeMax[0]], [rangeMin[1], rangeMax[1]]]);
}
示例4: valueOf
// --------------------------------------------------------------------------
// Test Axis Generators
// --------------------------------------------------------------------------
let topAxis: d3Axis.Axis<number | { valueOf(): number }> = d3Axis.axisTop(scaleLinear());
let rightAxis: d3Axis.Axis<Date> = d3Axis.axisRight<Date>(scaleTime());
let bottomAxis: d3Axis.Axis<string> = d3Axis.axisBottom(scaleOrdinal<number>());
let leftAxis: d3Axis.Axis<number | { valueOf(): number }> = d3Axis.axisLeft(scaleLinear<number>());
// --------------------------------------------------------------------------
// Test Configure Axis
// --------------------------------------------------------------------------
// scale(...) ----------------------------------------------------------------
leftAxis = leftAxis.scale(scalePow());
const powerScale: ScalePower<number, number> = leftAxis.scale<ScalePower<number, number>>();
// powerScale = leftAxis.scale(); // fails, without casting as AxisScale is purposely generic
bottomAxis = bottomAxis.scale(scaleOrdinal<number>());
// bottomAxis = bottomAxis.scale(scalePow()) // fails, domain of scale incompatible with domain of axis
const axisScale: d3Axis.AxisScale<string> = bottomAxis.scale();
const ordinalScale: ScaleOrdinal<string, number> = bottomAxis.scale<ScaleOrdinal<string, number>>();
// ordinalScale = bottomAxis.scale(); // fails, without casting as AxisScale is purposely generic
// ticks(...) ----------------------------------------------------------------
topAxis = topAxis.ticks(20, ',f');
示例5:
// copy(...) -----------------------------------------------------------------
const copiedLinearScale: d3Scale.ScaleLinear<number, string> = linearScaleNumString.copy();
// -------------------------------------------------------------------------------
// Power Scale Factories
// -------------------------------------------------------------------------------
// scalePow() and scaleSqrt() ----------------------------------------------------
let powerScaleNumber: d3Scale.ScalePower<number, number>;
let powerScaleString: d3Scale.ScalePower<string, string>;
let powerScaleNumString: d3Scale.ScalePower<number, string>;
powerScaleNumber = d3Scale.scalePow();
powerScaleString = d3Scale.scalePow<string>();
powerScaleNumString = d3Scale.scalePow<number, string>();
let squarerootScaleNumber: d3Scale.ScalePower<number, number>;
let squarerootScaleString: d3Scale.ScalePower<string, string>;
let squarerootScaleNumString: d3Scale.ScalePower<number, string>;
squarerootScaleNumber = d3Scale.scaleSqrt();
squarerootScaleString = d3Scale.scaleSqrt<string>();
squarerootScaleNumString = d3Scale.scaleSqrt<number, string>();
// ScalePower Interface ========================================================
// exponent --------------------------------------------------------------------
示例6: valueOf
// --------------------------------------------------------------------------
// Test Axis Generators
// --------------------------------------------------------------------------
let topAxis: d3Axis.Axis<number | { valueOf(): number }> = d3Axis.axisTop(scaleLinear());
let rightAxis: d3Axis.Axis<Date> = d3Axis.axisRight<Date>(scaleTime());
let bottomAxis: d3Axis.Axis<string> = d3Axis.axisBottom(scaleOrdinal<number>());
let leftAxis: d3Axis.Axis<number | { valueOf(): number }> = d3Axis.axisLeft(scaleLinear<number>());
// --------------------------------------------------------------------------
// Test Configure Axis
// --------------------------------------------------------------------------
// scale(...) ----------------------------------------------------------------
leftAxis = leftAxis.scale(scalePow());
const powerScale: ScalePower<number, number> = leftAxis.scale<ScalePower<number, number>>();
bottomAxis = bottomAxis.scale(scaleOrdinal<number>());
// $ExpectError
bottomAxis = bottomAxis.scale(scalePow()); // fails, domain of scale incompatible with domain of axis
const axisScale: d3Axis.AxisScale<string> = bottomAxis.scale();
const ordinalScale: ScaleOrdinal<string, number> = bottomAxis.scale<ScaleOrdinal<string, number>>();
// ticks(...) ----------------------------------------------------------------
topAxis = topAxis.ticks(20, ',f');
rightAxis = rightAxis.ticks(timeMinute.every(5));