mirror of https://github.com/apache/superset.git
fix(plugin-chart-echarts): make to allow the custome of x & y axis title margin i… (#18947)
* fix(chartviz): make to allow the custome of x & y axis title margin in chart * fix(chartviz): add eslint radix error in chart.js * fix(chartviz): change the transformProps in chart plugin & creat helper. * fix(chartviz): lint fix & chart.js back * fix(plugin-chart-echarts): make to allow the custom margin of X & y axis in BoxPlot & Mixedtimeseries charts * fix(plugin-chart-echarts): make to change changeNumber to changeInteger * fix(plugin-chart-echarts): make to add license & change file name
This commit is contained in:
parent
999c2c6826
commit
c79ee56884
|
@ -36,6 +36,7 @@ import {
|
|||
getColtypesMapping,
|
||||
sanitizeHtml,
|
||||
} from '../utils/series';
|
||||
import { convertInteger } from '../utils/convertInteger';
|
||||
import { defaultGrid, defaultTooltip, defaultYAxis } from '../defaults';
|
||||
import { getPadding } from '../Timeseries/transformers';
|
||||
import { OpacityEnum } from '../constants';
|
||||
|
@ -240,8 +241,8 @@ export default function transformProps(
|
|||
null,
|
||||
addXAxisTitleOffset,
|
||||
yAxisTitlePosition,
|
||||
yAxisTitleMargin,
|
||||
xAxisTitleMargin,
|
||||
convertInteger(yAxisTitleMargin),
|
||||
convertInteger(xAxisTitleMargin),
|
||||
);
|
||||
const echartOptions: EChartsCoreOption = {
|
||||
grid: {
|
||||
|
@ -253,7 +254,7 @@ export default function transformProps(
|
|||
data: transformedData.map(row => row.name),
|
||||
axisLabel,
|
||||
name: xAxisTitle,
|
||||
nameGap: xAxisTitleMargin,
|
||||
nameGap: convertInteger(xAxisTitleMargin),
|
||||
nameLocation: 'middle',
|
||||
},
|
||||
yAxis: {
|
||||
|
@ -261,7 +262,7 @@ export default function transformProps(
|
|||
type: 'value',
|
||||
axisLabel: { formatter: numberFormatter },
|
||||
name: yAxisTitle,
|
||||
nameGap: yAxisTitleMargin,
|
||||
nameGap: convertInteger(yAxisTitleMargin),
|
||||
nameLocation: yAxisTitlePosition === 'Left' ? 'middle' : 'end',
|
||||
},
|
||||
tooltip: {
|
||||
|
|
|
@ -50,6 +50,7 @@ import {
|
|||
formatForecastTooltipSeries,
|
||||
rebaseForecastDatum,
|
||||
} from '../utils/forecast';
|
||||
import { convertInteger } from '../utils/convertInteger';
|
||||
import { defaultGrid, defaultTooltip, defaultYAxis } from '../defaults';
|
||||
import {
|
||||
getPadding,
|
||||
|
@ -251,8 +252,8 @@ export default function transformProps(
|
|||
null,
|
||||
addXAxisTitleOffset,
|
||||
yAxisTitlePosition,
|
||||
yAxisTitleMargin,
|
||||
xAxisTitleMargin,
|
||||
convertInteger(yAxisTitleMargin),
|
||||
convertInteger(xAxisTitleMargin),
|
||||
);
|
||||
const labelMap = rawSeriesA.reduce((acc, datum) => {
|
||||
const label = datum.name as string;
|
||||
|
@ -282,7 +283,7 @@ export default function transformProps(
|
|||
xAxis: {
|
||||
type: 'time',
|
||||
name: xAxisTitle,
|
||||
nameGap: xAxisTitleMargin,
|
||||
nameGap: convertInteger(xAxisTitleMargin),
|
||||
nameLocation: 'middle',
|
||||
axisLabel: {
|
||||
formatter: xAxisFormatter,
|
||||
|
@ -300,7 +301,7 @@ export default function transformProps(
|
|||
axisLabel: { formatter },
|
||||
scale: truncateYAxis,
|
||||
name: yAxisTitle,
|
||||
nameGap: yAxisTitleMargin,
|
||||
nameGap: convertInteger(yAxisTitleMargin),
|
||||
nameLocation: yAxisTitlePosition === 'Left' ? 'middle' : 'end',
|
||||
alignTicks,
|
||||
},
|
||||
|
|
|
@ -55,6 +55,7 @@ import {
|
|||
formatForecastTooltipSeries,
|
||||
rebaseForecastDatum,
|
||||
} from '../utils/forecast';
|
||||
import { convertInteger } from '../utils/convertInteger';
|
||||
import { defaultGrid, defaultTooltip, defaultYAxis } from '../defaults';
|
||||
import {
|
||||
getPadding,
|
||||
|
@ -125,6 +126,7 @@ export default function transformProps(
|
|||
yAxisTitleMargin,
|
||||
yAxisTitlePosition,
|
||||
}: EchartsTimeseriesFormData = { ...DEFAULT_FORM_DATA, ...formData };
|
||||
|
||||
const colorScale = CategoricalColorNamespace.getScale(colorScheme as string);
|
||||
const rebasedData = rebaseForecastDatum(data, verboseMap);
|
||||
const xAxisCol = verboseMap[xAxisOrig] || xAxisOrig || DTTM_ALIAS;
|
||||
|
@ -282,8 +284,8 @@ export default function transformProps(
|
|||
legendMargin,
|
||||
addXAxisLabelOffset,
|
||||
yAxisTitlePosition,
|
||||
yAxisTitleMargin,
|
||||
xAxisTitleMargin,
|
||||
convertInteger(yAxisTitleMargin),
|
||||
convertInteger(xAxisTitleMargin),
|
||||
);
|
||||
|
||||
const legendData = rawSeries
|
||||
|
@ -304,7 +306,7 @@ export default function transformProps(
|
|||
xAxis: {
|
||||
type: xAxisType,
|
||||
name: xAxisTitle,
|
||||
nameGap: xAxisTitleMargin,
|
||||
nameGap: convertInteger(xAxisTitleMargin),
|
||||
nameLocation: 'middle',
|
||||
axisLabel: {
|
||||
hideOverlap: true,
|
||||
|
@ -322,7 +324,7 @@ export default function transformProps(
|
|||
axisLabel: { formatter },
|
||||
scale: truncateYAxis,
|
||||
name: yAxisTitle,
|
||||
nameGap: yAxisTitleMargin,
|
||||
nameGap: convertInteger(yAxisTitleMargin),
|
||||
nameLocation: yAxisTitlePosition === 'Left' ? 'middle' : 'end',
|
||||
},
|
||||
tooltip: {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
export const convertInteger = (value: string | number) => {
|
||||
if (typeof value !== 'number') return parseInt(value, 10) || 0;
|
||||
return value;
|
||||
};
|
Loading…
Reference in New Issue