react-icecream-charts
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -36,3 +36,3 @@ /** | ||
/** | ||
* 初始化和重绘后触发的回调函数 | ||
* 初始化和配置变更后触发的回调函数 | ||
*/ | ||
@@ -39,0 +39,0 @@ afterRendered?: () => void; |
@@ -18,2 +18,8 @@ import Highcharts from 'highcharts'; | ||
labelFormatter?: (seriesData: LegendSeriesDataObject) => string; | ||
/** | ||
* The x offset of the legend | ||
* Negative x moves it to the left, positive x moves it | ||
* to the right. | ||
*/ | ||
x?: number; | ||
}; | ||
@@ -20,0 +26,0 @@ export declare type LegendOptions = false | LegendObjectOptions; |
@@ -9,2 +9,3 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
import mergeWith from 'lodash.mergewith'; | ||
// TODO 支持函数合并,配置里的 function 如果有合并需求会出问题 | ||
export default function merge() { | ||
@@ -11,0 +12,0 @@ var args = []; |
@@ -25,3 +25,3 @@ var __assign = (this && this.__assign) || function () { | ||
import { createPieOptions } from './options'; | ||
import { useHighOptions, createRightCenterLegendOptions } from '../_chart'; | ||
import { useHighOptions } from '../_chart'; | ||
import { cssObjectToLiterialString } from '../_chart/utils/style'; | ||
@@ -42,7 +42,3 @@ import { useConfig } from '../config-provider'; | ||
if (legend === false || (legend === null || legend === void 0 ? void 0 : legend.align) === undefined || (legend === null || legend === void 0 ? void 0 : legend.align) === 'right-center') { | ||
var updatedLegendOptions = createRightCenterLegendOptions(chart.plotTop / 2); | ||
// 防止更新 legend 时覆盖掉 layout | ||
if (legend && legend.columns != null && legend.columns !== 1) { | ||
updatedLegendOptions.layout = 'horizontal'; | ||
} | ||
var updatedLegendOptions = { y: chart.plotTop / 2 }; | ||
chart.legend.update(updatedLegendOptions); | ||
@@ -49,0 +45,0 @@ } |
@@ -62,3 +62,7 @@ import Highcharts, { CSSObject } from 'highcharts'; | ||
export declare type LegendPieObjectOptions = Omit<LegendObjectOptions, 'labelFormatter'> & { | ||
/** 图例的展示列数,值为 1 时会出现图例宽度不断变小的情况,所以不做处理 */ | ||
/** | ||
* 图例的展示列数,值为 1 时会出现图例宽度不断变小的情况,所以不做处理 | ||
* | ||
* 注:此特性依赖复杂的计算才能生效,所以当你传入 `width`、`maxHeight`等配置的时候会被无视 | ||
*/ | ||
columns?: number; | ||
@@ -65,0 +69,0 @@ /** |
@@ -28,3 +28,2 @@ var __assign = (this && this.__assign) || function () { | ||
export function createPieOptions(langData, options, chartOptions, series) { | ||
var legendColumns = (chartOptions === null || chartOptions === void 0 ? void 0 : chartOptions.legend) ? chartOptions.legend.columns : undefined; | ||
var pieOptions = { | ||
@@ -65,5 +64,6 @@ colors: [ | ||
chart: { | ||
// TODO 方法之间的合并会有问题,这里可能挪到 callback 里面去更好 | ||
events: { | ||
load: wrapRender(legendColumns), | ||
redraw: wrapRender(legendColumns) | ||
load: wrapRender(chartOptions === null || chartOptions === void 0 ? void 0 : chartOptions.legend), | ||
redraw: wrapRender(chartOptions === null || chartOptions === void 0 ? void 0 : chartOptions.legend) | ||
} | ||
@@ -81,3 +81,3 @@ } | ||
var _b = createHighLegendOptions(__assign({ align: align }, restOptions)), layout = _b.layout, labelFormatter = _b.labelFormatter, rest = __rest(_b, ["layout", "labelFormatter"]); | ||
var pieLegendOptions = __assign(__assign({}, rest), { layout: columns ? 'horizontal' : layout }); | ||
var pieLegendOptions = __assign(__assign({}, rest), { layout: columns != null && columns > 1 ? 'horizontal' : layout }); | ||
if (pieLabelFormatter) { | ||
@@ -122,3 +122,10 @@ pieLegendOptions.labelFormatter = function _labelFormatter() { | ||
// 如果 widthA 大于 widthB,单列展示,图例的总宽度等于图例的最大宽度 | ||
function wrapRender(column) { | ||
function wrapRender(legendOptions) { | ||
if (legendOptions == null) | ||
return; | ||
if (legendOptions === false) | ||
return; | ||
var columns = legendOptions.columns; | ||
if (columns != null && columns <= 1) | ||
return; | ||
function renderElements() { | ||
@@ -136,3 +143,3 @@ // highcharts 8.x 的 ts 声明存在大量类型缺失,升级 highcharts 到最新版本即可解决 | ||
// distance | ||
var nextLegendWidth = (maxItemWidth + itemDistance) * column - itemDistance; | ||
var nextLegendWidth = (maxItemWidth + itemDistance) * columns - itemDistance; | ||
// Compute how wide the legend is allowed to be | ||
@@ -151,3 +158,3 @@ var allowedWidth = legend.chart.spacingBox.width - 2 * legend.padding - legend.options.x; | ||
} | ||
return column == null || column === 1 ? undefined : renderElements; | ||
return renderElements; | ||
} |
@@ -36,3 +36,3 @@ /** | ||
/** | ||
* 初始化和重绘后触发的回调函数 | ||
* 初始化和配置变更后触发的回调函数 | ||
*/ | ||
@@ -39,0 +39,0 @@ afterRendered?: () => void; |
@@ -18,2 +18,8 @@ import Highcharts from 'highcharts'; | ||
labelFormatter?: (seriesData: LegendSeriesDataObject) => string; | ||
/** | ||
* The x offset of the legend | ||
* Negative x moves it to the left, positive x moves it | ||
* to the right. | ||
*/ | ||
x?: number; | ||
}; | ||
@@ -20,0 +26,0 @@ export declare type LegendOptions = false | LegendObjectOptions; |
@@ -14,2 +14,3 @@ "use strict"; | ||
var lodash_mergewith_1 = __importDefault(require("lodash.mergewith")); | ||
// TODO 支持函数合并,配置里的 function 如果有合并需求会出问题 | ||
function merge() { | ||
@@ -16,0 +17,0 @@ var args = []; |
@@ -66,7 +66,3 @@ "use strict"; | ||
if (legend === false || (legend === null || legend === void 0 ? void 0 : legend.align) === undefined || (legend === null || legend === void 0 ? void 0 : legend.align) === 'right-center') { | ||
var updatedLegendOptions = _chart_1.createRightCenterLegendOptions(chart.plotTop / 2); | ||
// 防止更新 legend 时覆盖掉 layout | ||
if (legend && legend.columns != null && legend.columns !== 1) { | ||
updatedLegendOptions.layout = 'horizontal'; | ||
} | ||
var updatedLegendOptions = { y: chart.plotTop / 2 }; | ||
chart.legend.update(updatedLegendOptions); | ||
@@ -73,0 +69,0 @@ } |
@@ -62,3 +62,7 @@ import Highcharts, { CSSObject } from 'highcharts'; | ||
export declare type LegendPieObjectOptions = Omit<LegendObjectOptions, 'labelFormatter'> & { | ||
/** 图例的展示列数,值为 1 时会出现图例宽度不断变小的情况,所以不做处理 */ | ||
/** | ||
* 图例的展示列数,值为 1 时会出现图例宽度不断变小的情况,所以不做处理 | ||
* | ||
* 注:此特性依赖复杂的计算才能生效,所以当你传入 `width`、`maxHeight`等配置的时候会被无视 | ||
*/ | ||
columns?: number; | ||
@@ -65,0 +69,0 @@ /** |
@@ -34,3 +34,2 @@ "use strict"; | ||
function createPieOptions(langData, options, chartOptions, series) { | ||
var legendColumns = (chartOptions === null || chartOptions === void 0 ? void 0 : chartOptions.legend) ? chartOptions.legend.columns : undefined; | ||
var pieOptions = { | ||
@@ -71,5 +70,6 @@ colors: [ | ||
chart: { | ||
// TODO 方法之间的合并会有问题,这里可能挪到 callback 里面去更好 | ||
events: { | ||
load: wrapRender(legendColumns), | ||
redraw: wrapRender(legendColumns) | ||
load: wrapRender(chartOptions === null || chartOptions === void 0 ? void 0 : chartOptions.legend), | ||
redraw: wrapRender(chartOptions === null || chartOptions === void 0 ? void 0 : chartOptions.legend) | ||
} | ||
@@ -88,3 +88,3 @@ } | ||
var _b = _chart_1.createHighLegendOptions(__assign({ align: align }, restOptions)), layout = _b.layout, labelFormatter = _b.labelFormatter, rest = __rest(_b, ["layout", "labelFormatter"]); | ||
var pieLegendOptions = __assign(__assign({}, rest), { layout: columns ? 'horizontal' : layout }); | ||
var pieLegendOptions = __assign(__assign({}, rest), { layout: columns != null && columns > 1 ? 'horizontal' : layout }); | ||
if (pieLabelFormatter) { | ||
@@ -129,3 +129,10 @@ pieLegendOptions.labelFormatter = function _labelFormatter() { | ||
// 如果 widthA 大于 widthB,单列展示,图例的总宽度等于图例的最大宽度 | ||
function wrapRender(column) { | ||
function wrapRender(legendOptions) { | ||
if (legendOptions == null) | ||
return; | ||
if (legendOptions === false) | ||
return; | ||
var columns = legendOptions.columns; | ||
if (columns != null && columns <= 1) | ||
return; | ||
function renderElements() { | ||
@@ -143,3 +150,3 @@ // highcharts 8.x 的 ts 声明存在大量类型缺失,升级 highcharts 到最新版本即可解决 | ||
// distance | ||
var nextLegendWidth = (maxItemWidth + itemDistance) * column - itemDistance; | ||
var nextLegendWidth = (maxItemWidth + itemDistance) * columns - itemDistance; | ||
// Compute how wide the legend is allowed to be | ||
@@ -158,3 +165,3 @@ var allowedWidth = legend.chart.spacingBox.width - 2 * legend.padding - legend.options.x; | ||
} | ||
return column == null || column === 1 ? undefined : renderElements; | ||
return renderElements; | ||
} |
{ | ||
"name": "react-icecream-charts", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "esm/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4806614
144867