mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 07:35:45 -06:00
BarChart: inside-align strokes, upgrade uPlot to 1.6.4. (#30806)
This commit is contained in:
parent
0c639b2221
commit
b5400922e2
@ -72,7 +72,7 @@
|
||||
"react-transition-group": "4.4.1",
|
||||
"slate": "0.47.8",
|
||||
"tinycolor2": "1.4.1",
|
||||
"uplot": "1.6.3"
|
||||
"uplot": "1.6.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "16.0.0",
|
||||
|
@ -165,8 +165,10 @@ export const BarChart: React.FunctionComponent<Props> = ({
|
||||
|
||||
builder.addSeries({
|
||||
scaleKey,
|
||||
pxAlign: false,
|
||||
lineWidth: customConfig.lineWidth,
|
||||
lineColor: seriesColor,
|
||||
//lineStyle: customConfig.lineStyle,
|
||||
fillOpacity: customConfig.fillOpacity,
|
||||
theme,
|
||||
colorMode,
|
||||
@ -176,12 +178,6 @@ export const BarChart: React.FunctionComponent<Props> = ({
|
||||
gradientMode: customConfig.gradientMode,
|
||||
thresholds: field.config.thresholds,
|
||||
|
||||
/*
|
||||
lineColor: customConfig.lineColor ?? seriesColor,
|
||||
lineWidth: customConfig.lineWidth,
|
||||
lineStyle: customConfig.lineStyle,
|
||||
*/
|
||||
|
||||
// The following properties are not used in the uPlot config, but are utilized as transport for legend config
|
||||
dataFrameFieldIndex: {
|
||||
fieldIndex: i,
|
||||
|
@ -64,6 +64,7 @@ export function getConfig(opts: BarsOptions) {
|
||||
sidx,
|
||||
(series, dataX, dataY, scaleX, scaleY, valToPosX, valToPosY, xOff, yOff, xDim, yDim, moveTo, lineTo, rect) => {
|
||||
const fill = new Path2D();
|
||||
const stroke = new Path2D();
|
||||
|
||||
let numGroups = dataX.length;
|
||||
let barsPerGroup = u.series.length - 1;
|
||||
@ -83,6 +84,12 @@ export function getConfig(opts: BarsOptions) {
|
||||
let top = Math.round(Math.min(yPos, y0Pos));
|
||||
let barHgt = btm - top;
|
||||
|
||||
let strokeWidth = series.width || 0;
|
||||
|
||||
if (strokeWidth) {
|
||||
rect(stroke, lft + strokeWidth / 2, top + strokeWidth / 2, barWid - strokeWidth, barHgt - strokeWidth);
|
||||
}
|
||||
|
||||
rect(fill, lft, top, barWid, barHgt);
|
||||
|
||||
let x = ori === 0 ? Math.round(lft - xOff) : Math.round(top - yOff);
|
||||
@ -95,7 +102,7 @@ export function getConfig(opts: BarsOptions) {
|
||||
});
|
||||
|
||||
return {
|
||||
stroke: fill,
|
||||
stroke,
|
||||
fill,
|
||||
};
|
||||
}
|
||||
|
@ -469,6 +469,7 @@ describe('UPlotConfigBuilder', () => {
|
||||
"size": 5,
|
||||
"stroke": "#00ff00",
|
||||
},
|
||||
"pxAlign": undefined,
|
||||
"scale": "scale-x",
|
||||
"show": true,
|
||||
"spanGaps": false,
|
||||
|
@ -17,6 +17,7 @@ import { getHueGradientFn, getOpacityGradientFn, getScaleGradientFn } from './gr
|
||||
|
||||
export interface SeriesProps extends LineConfig, BarConfig, FillConfig, PointsConfig {
|
||||
scaleKey: string;
|
||||
pxAlign?: boolean;
|
||||
gradientMode?: GraphGradientMode;
|
||||
/** Used when gradientMode is set to Scheme */
|
||||
thresholds?: ThresholdsConfig;
|
||||
@ -46,6 +47,7 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder<SeriesProps, Series> {
|
||||
pointColor,
|
||||
pointSize,
|
||||
scaleKey,
|
||||
pxAlign,
|
||||
spanNulls,
|
||||
show = true,
|
||||
} = this.props;
|
||||
@ -103,6 +105,7 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder<SeriesProps, Series> {
|
||||
return {
|
||||
scale: scaleKey,
|
||||
spanGaps: spanNulls,
|
||||
pxAlign,
|
||||
show,
|
||||
fill: this.getFill(),
|
||||
...lineConfig,
|
||||
|
@ -26041,10 +26041,10 @@ update-notifier@^2.5.0:
|
||||
semver-diff "^2.0.0"
|
||||
xdg-basedir "^3.0.0"
|
||||
|
||||
uplot@1.6.3:
|
||||
version "1.6.3"
|
||||
resolved "https://registry.yarnpkg.com/uplot/-/uplot-1.6.3.tgz#85b21f59b2e9db24976aa688cb267d950dfa45b5"
|
||||
integrity sha512-aSqtBqJRqO7KkuZxRxVGumDi7+293HsBCdzg9HbOYkRZ8lxf2utLpkAu4oljejlwYy1zrn7DXBSvcZ5wnWig9w==
|
||||
uplot@1.6.4:
|
||||
version "1.6.4"
|
||||
resolved "https://registry.yarnpkg.com/uplot/-/uplot-1.6.4.tgz#016e9f66796d78c187957e710743f7ca405dfb4d"
|
||||
integrity sha512-4d6JixG54HQKFDLAegzwgwf87GtEbp6pt3YlHygyLt+mJ9RHneCXYlZxr1QOhLetoSSHeeDuWP5RFMv8mdltpg==
|
||||
|
||||
upper-case@^1.1.1:
|
||||
version "1.1.3"
|
||||
|
Loading…
Reference in New Issue
Block a user