本文整理汇总了TypeScript中d3.scaleOrdinal函数的典型用法代码示例。如果您正苦于以下问题:TypeScript scaleOrdinal函数的具体用法?TypeScript scaleOrdinal怎么用?TypeScript scaleOrdinal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scaleOrdinal函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: colorCategory
export function colorCategory(parameters: { [name: string]: string }, domain: string[]): d3.ScaleOrdinal<string, string> {
const cacheKey = "_cachedColorOrdinal_";
var category = parameters["ColorCategory"];
var categorySteps = parseInt(parameters["ColorCategorySteps"]);
if (parameters[cacheKey]) {
const cached = parameters[cacheKey] as any as CachedColorOrdinal;
if (cached.category == category && cached.categorySteps == categorySteps) {
domain.forEach(a => cached.scale(a));
return cached.scale;
}
}
var scheme = getColorScheme(category, categorySteps);
const newCached: CachedColorOrdinal = {
category: category,
categorySteps: categorySteps,
scale: d3.scaleOrdinal(scheme).domain(domain),
};
parameters[cacheKey] = newCached as any;
return newCached.scale;
}
开发者ID:MehdyKarimpour,项目名称:extensions,代码行数:27,代码来源:ChartUtils.ts
示例2: axes
export function* axes(xtitle, ytitle, changeLimits) {
let margin = { top: 20, right: 25, bottom: 30, left: 50 },
width = 480 - margin.left - margin.right,
height = 180 - margin.top - margin.bottom;
let svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
let colors = d3.scaleOrdinal(d3.schemeCategory10);
let x = d3.scaleLinear().range([0, width]);
let y = d3.scaleLinear().range([height, 0]);
let x_axis = d3.axisBottom(x);
let y_axis = d3.axisLeft(y);
let x_node = svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")");
let y_node = svg.append("g")
.attr("class", "y axis");
x_node.append("text")
.attr("transform", "translate(" + width + ", 0)")
.text(xtitle);
y_node.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text(ytitle);
let l = d3.line()
.x(function (d, n) { return x(n) })
.y(function (d) { return y(d) });
let p = svg.append("path")
.attr("class", "line")
.attr("stroke", colors("1"));
let first = true;
while (true) {
let data = yield svg;
let ymin = Math.min(...data);
let ymax = Math.max(...data);
if (changeLimits || first) {
first = false;
x.domain([0, data.length]);
y.domain([ymin, ymax]);
}
// update axes
x_node.call(x_axis);
y_node.call(y_axis);
p.datum(data)
.attr("d", l);
}
}
开发者ID:hessammehr,项目名称:coalescence,代码行数:58,代码来源:plot-utils.ts
示例3: register
* stand-alone pages for plotting. Note currently there is only one global
* handler. It gets replaced it register is called twice.
*/
export function register(handler: OutputHandler): void {
if (h == null) {
console.warn("Warning replacing existing OutputHandler.");
}
h = handler;
}
export function outputEl(): null | Element {
return h ? h() : null;
}
// TODO colors should match those used by the syntax highlighting.
const color = d3.scaleOrdinal(d3.schemeCategory10);
function makeAxis(svg, margin, xScale, yScale, width, height) {
const axisBottom = d3.axisBottom(xScale);
axisBottom.tickSizeOuter(0);
svg.append("g")
.attr("transform", `translate(${margin.left},${height + margin.top})`)
.call(axisBottom);
const axisLeft = d3.axisLeft(yScale);
axisLeft.tickSizeOuter(0);
svg.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`)
.call(axisLeft);
const axisRight = d3.axisRight(yScale);
开发者ID:Befirst-Solutions,项目名称:propel,代码行数:31,代码来源:matplotlib.ts
示例4: category8
export function category8() {
return scaleOrdinal().range(paletteCategory8);
}
开发者ID:proteus-h2020,项目名称:proteus-charts,代码行数:3,代码来源:colors.ts
注:本文中的d3.scaleOrdinal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论