Skip to content

Commit e2bd9c4

Browse files
committed
fix: chart style
1 parent 0525208 commit e2bd9c4

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

src/frontend/platform/src/pages/Dashboard/components/charts/BaseChart.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ const getCartesianChartOption = (
244244
// overflow: 'break'
245245
// ...axisLabelStyle,
246246
},
247-
name: styleConfig.xAxisTitle || ''
247+
name: styleConfig.xAxisTitle || '',
248+
nameLocation: 'center'
248249
};
249250

250251
// (Value Axis)
@@ -256,7 +257,9 @@ const getCartesianChartOption = (
256257
...axisLabelStyle,
257258
},
258259
splitLine: { show: styleConfig.showGrid ?? true },
259-
name: styleConfig.yAxisTitle || ''
260+
name: styleConfig.yAxisTitle || '',
261+
nameLocation: 'center',
262+
nameRotate: isHorizontal ? 0 : 90
260263
};
261264

262265
// Series
@@ -280,17 +283,20 @@ const getCartesianChartOption = (
280283
return item;
281284
});
282285

286+
const dimensionLength = styleConfig.xAxisTitle ? dataConfig.dimensions.length : 1
287+
const bottom = (styleConfig.legendPosition === 'bottom' ? 44 : 0) + dimensionLength * 13;
288+
283289
return {
284290
backgroundColor: styleConfig.bgColor,
285291
// title: buildTitleOption(styleConfig),
286292
legend: buildLegendOption(styleConfig, series.map(s => s.name)),
287293
tooltip: buildTooltipOption('axis', tooltipFormatter),
288294
grid: {
289-
left: styleConfig.legendPosition === 'left' ? 100 : '1%',
290-
right: styleConfig.legendPosition === 'right' ? 100 : '1%',
291-
top: styleConfig.legendPosition === 'top' ? 60 : 28,
292-
bottom: styleConfig.legendPosition === 'bottom' ? 40 : 0,
293-
containLabel: true
295+
left: styleConfig.legendPosition === 'left' ? 160 : 0,
296+
right: styleConfig.legendPosition === 'right' ? 100 : 0,
297+
top: styleConfig.legendPosition === 'top' ? 40 : 0,
298+
bottom,
299+
// containLabel: true,
294300
},
295301
xAxis: isHorizontal ? valueAxis : categoryAxis,
296302
yAxis: isHorizontal ? categoryAxis : valueAxis,
@@ -319,9 +325,9 @@ const buildLegendOption = (styleConfig: ComponentStyleConfig, seriesNames?: stri
319325
// computed
320326
const orient = pos === 'left' || pos === 'right' ? 'vertical' : 'horizontal';
321327
const top = pos === 'top' ? 0 : pos === 'bottom' ? 'auto' : 'center';
322-
const bottom = pos === 'bottom' ? 10 : 'auto';
323-
const left = pos === 'left' ? 10 : pos === 'center' ? 'center' : 'auto';
324-
const right = pos === 'right' ? 10 : 'auto';
328+
const bottom = pos === 'bottom' ? 0 : 'auto';
329+
const left = pos === 'left' ? 0 : pos === 'center' ? 'center' : 'auto';
330+
const right = pos === 'right' ? 0 : 'auto';
325331

326332
return {
327333
data: seriesNames, // Pie chart doesn't strictly need this, but Cartesian does

src/frontend/platform/src/pages/Dashboard/components/editor/ComponentWrapper.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export function ComponentWrapper({
244244

245245
<div className="w-full h-full p-2">
246246
{/* Component title with rename ability - hidden for query type */}
247-
{!['query', 'metric'].includes(component.type) && (
247+
{!['query', 'metric'].includes(componentData.type) && (
248248
<div className="group mb-2 relative">
249249
{isEditing ? (
250250
<Input
@@ -280,12 +280,12 @@ export function ComponentWrapper({
280280

281281
{/* Component content */}
282282
<div
283-
className={['query', 'metric'].includes(component.type) ? '' : ` no-drag cursor-default`}
283+
className={['query', 'metric'].includes(componentData.type) ? '' : ` no-drag cursor-default`}
284284
style={{
285-
height: ['query', 'metric'].includes(component.type) ? '100%' : `calc(100% - ${(componentData.style_config?.titleFontSize || 0) + 10}px)`
285+
height: ['query', 'metric'].includes(componentData.type) ? '100%' : `calc(100% - ${(componentData.style_config?.titleFontSize || 0) + 10}px)`
286286
}}
287287
>
288-
{component.type === 'query' ? (
288+
{componentData.type === 'query' ? (
289289
<QueryFilter isDark={isDark} component={componentData} isPreviewMode={isPreviewMode} />
290290
) : (
291291
<ChartContainer isDark={isDark} component={componentData} isPreviewMode={isPreviewMode} />

0 commit comments

Comments
 (0)