本文整理汇总了TypeScript中@grafana/ui.getColorFromHexRgbOrName函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getColorFromHexRgbOrName函数的具体用法?TypeScript getColorFromHexRgbOrName怎么用?TypeScript getColorFromHexRgbOrName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getColorFromHexRgbOrName函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getColorForValue
getColorForValue(value, style: ColumnStyle) {
if (!style.thresholds) {
return null;
}
for (let i = style.thresholds.length; i > 0; i--) {
if (value >= style.thresholds[i - 1]) {
return getColorFromHexRgbOrName(style.colors[i], this.theme);
}
}
return getColorFromHexRgbOrName(_.first(style.colors), this.theme);
}
开发者ID:grafana,项目名称:grafana,代码行数:11,代码来源:renderer.ts
示例2: timeSeriesHandler
timeSeriesHandler(seriesData: LegacyResponseData, index: number, options: Options) {
const datapoints = seriesData.datapoints || [];
const alias = seriesData.target;
const colorIndex = index % colors.length;
const color = this.panel.aliasColors[alias] || colors[colorIndex];
const series = new TimeSeries({
datapoints: datapoints,
alias: alias,
color: getColorFromHexRgbOrName(color, config.theme.type),
unit: seriesData.unit,
});
if (datapoints && datapoints.length > 0) {
const last = datapoints[datapoints.length - 1][1];
const from = options.range.from;
if (last - from.valueOf() < -10000) {
series.isOutsideRange = true;
}
}
return series;
}
开发者ID:johntdyer,项目名称:grafana,代码行数:26,代码来源:data_processor.ts
示例3: timeSeriesHandler
timeSeriesHandler(seriesData, index, options) {
const datapoints = seriesData.datapoints || [];
const alias = seriesData.target;
const colorIndex = index % colors.length;
const color = this.panel.aliasColors[alias] || colors[colorIndex];
const series = new TimeSeries({
datapoints: datapoints,
alias: alias,
color: getColorFromHexRgbOrName(color, config.bootData.user.lightTheme ? GrafanaTheme.Light : GrafanaTheme.Dark),
unit: seriesData.unit,
});
if (datapoints && datapoints.length > 0) {
const last = datapoints[datapoints.length - 1][1];
const from = options.range.from;
if (last - from < -10000) {
series.isOutsideRange = true;
}
}
return series;
}
开发者ID:gnydick,项目名称:grafana,代码行数:25,代码来源:data_processor.ts
示例4: getCardColor
getCardColor(d) {
if (this.panel.color.mode === 'opacity') {
return getColorFromHexRgbOrName(
this.panel.color.cardColor,
contextSrv.user.lightTheme ? GrafanaThemeType.Light : GrafanaThemeType.Dark
);
} else {
return this.colorScale(d.count);
}
}
开发者ID:CorpGlory,项目名称:grafana,代码行数:10,代码来源:rendering.ts
示例5: drawSimpleOpacityLegend
function drawSimpleOpacityLegend(elem, options) {
const legendElem = $(elem).find('svg');
clearLegend(elem);
const legend = d3.select(legendElem.get(0));
const legendWidth = Math.floor(legendElem.outerWidth());
const legendHeight = legendElem.attr('height');
if (legendWidth) {
let legendOpacityScale;
if (options.colorScale === 'linear') {
legendOpacityScale = d3
.scaleLinear()
.domain([0, legendWidth])
.range([0, 1]);
} else if (options.colorScale === 'sqrt') {
legendOpacityScale = d3
.scalePow()
.exponent(options.exponent)
.domain([0, legendWidth])
.range([0, 1]);
}
const rangeStep = 10;
const valuesRange = d3.range(0, legendWidth, rangeStep);
const legendRects = legend.selectAll('.heatmap-opacity-legend-rect').data(valuesRange);
legendRects
.enter()
.append('rect')
.attr('x', d => d)
.attr('y', 0)
.attr('width', rangeStep)
.attr('height', legendHeight)
.attr('stroke-width', 0)
.attr(
'fill',
getColorFromHexRgbOrName(
options.cardColor,
contextSrv.user.lightTheme ? GrafanaThemeType.Light : GrafanaThemeType.Dark
)
)
.style('opacity', d => legendOpacityScale(d));
}
}
开发者ID:CorpGlory,项目名称:grafana,代码行数:45,代码来源:color_legend.ts
示例6: toTimeSeries
private toTimeSeries(field: Field, alias: string, datapoints: any[][], index: number, range?: TimeRange) {
const colorIndex = index % colors.length;
const color = this.panel.aliasColors[alias] || colors[colorIndex];
const series = new TimeSeries({
datapoints: datapoints || [],
alias: alias,
color: getColorFromHexRgbOrName(color, config.theme.type),
unit: field.unit,
});
if (datapoints && datapoints.length > 0 && range) {
const last = datapoints[datapoints.length - 1][1];
const from = range.from;
if (last - from.valueOf() < -10000) {
series.isOutsideRange = true;
}
}
return series;
}
开发者ID:grafana,项目名称:grafana,代码行数:21,代码来源:data_processor.ts
示例7: getDisplayProcessor
export const getGraphSeriesModel = (
data: PanelData,
seriesOptions: SeriesOptions,
graphOptions: GraphOptions,
legendOptions: GraphLegendEditorLegendOptions
) => {
const graphs: GraphSeriesXY[] = [];
const displayProcessor = getDisplayProcessor({
field: {
decimals: legendOptions.decimals,
},
});
for (const series of data.series) {
const fieldCache = new FieldCache(series.fields);
const timeColumn = fieldCache.getFirstFieldOfType(FieldType.time);
if (!timeColumn) {
continue;
}
const numberFields = fieldCache.getFields(FieldType.number);
for (let i = 0; i < numberFields.length; i++) {
const field = numberFields[i];
// Use external calculator just to make sure it works :)
const points = getFlotPairs({
series,
xIndex: timeColumn.index,
yIndex: field.index,
nullValueMode: NullValueMode.Null,
});
if (points.length > 0) {
const seriesStats = reduceField({
series,
reducers: legendOptions.stats,
fieldIndex: field.index,
});
let statsDisplayValues: DisplayValue[];
if (legendOptions.stats) {
statsDisplayValues = legendOptions.stats.map<DisplayValue>(stat => {
const statDisplayValue = displayProcessor(seriesStats[stat]);
return {
...statDisplayValue,
text: statDisplayValue.text,
title: stat,
};
});
}
const seriesColor =
seriesOptions[field.name] && seriesOptions[field.name].color
? getColorFromHexRgbOrName(seriesOptions[field.name].color)
: colors[graphs.length % colors.length];
graphs.push({
label: field.name,
data: points,
color: seriesColor,
info: statsDisplayValues,
isVisible: true,
yAxis: (seriesOptions[field.name] && seriesOptions[field.name].yAxis) || 1,
});
}
}
}
return graphs;
};
开发者ID:grafana,项目名称:grafana,代码行数:71,代码来源:getGraphSeriesModel.ts
示例8: addFlotOptions
addFlotOptions(options, panel) {
if (!panel.thresholds || panel.thresholds.length === 0) {
return;
}
let gtLimit = Infinity;
let ltLimit = -Infinity;
let i, threshold, other;
for (i = 0; i < panel.thresholds.length; i++) {
threshold = panel.thresholds[i];
if (!_.isNumber(threshold.value)) {
continue;
}
let limit;
switch (threshold.op) {
case 'gt': {
limit = gtLimit;
// if next threshold is less then op and greater value, then use that as limit
if (panel.thresholds.length > i + 1) {
other = panel.thresholds[i + 1];
if (other.value > threshold.value) {
limit = other.value;
ltLimit = limit;
}
}
break;
}
case 'lt': {
limit = ltLimit;
// if next threshold is less then op and greater value, then use that as limit
if (panel.thresholds.length > i + 1) {
other = panel.thresholds[i + 1];
if (other.value < threshold.value) {
limit = other.value;
gtLimit = limit;
}
}
break;
}
}
let fillColor, lineColor;
switch (threshold.colorMode) {
case 'critical': {
fillColor = 'rgba(234, 112, 112, 0.12)';
lineColor = 'rgba(237, 46, 24, 0.60)';
break;
}
case 'warning': {
fillColor = 'rgba(235, 138, 14, 0.12)';
lineColor = 'rgba(247, 149, 32, 0.60)';
break;
}
case 'ok': {
fillColor = 'rgba(11, 237, 50, 0.090)';
lineColor = 'rgba(6,163,69, 0.60)';
break;
}
case 'custom': {
if (!threshold.fillColor) {
threshold.fillColor = 'rgba(255, 255, 255, 1)';
}
if (!threshold.lineColor) {
threshold.lineColor = 'rgba(255, 255, 255, 0)';
}
fillColor = threshold.fillColor;
lineColor = threshold.lineColor;
break;
}
}
// fill
if (threshold.fill) {
if (threshold.yaxis === 'right' && this.hasSecondYAxis) {
options.grid.markings.push({
y2axis: { from: threshold.value, to: limit },
color: getColorFromHexRgbOrName(fillColor),
});
} else {
options.grid.markings.push({
yaxis: { from: threshold.value, to: limit },
color: getColorFromHexRgbOrName(fillColor),
});
}
}
if (threshold.line) {
if (threshold.yaxis === 'right' && this.hasSecondYAxis) {
options.grid.markings.push({
y2axis: { from: threshold.value, to: threshold.value },
color: getColorFromHexRgbOrName(lineColor),
});
} else {
options.grid.markings.push({
yaxis: { from: threshold.value, to: threshold.value },
color: getColorFromHexRgbOrName(lineColor),
});
}
//.........这里部分代码省略.........
开发者ID:CorpGlory,项目名称:grafana,代码行数:101,代码来源:threshold_manager.ts
注:本文中的@grafana/ui.getColorFromHexRgbOrName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论