Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-icecream-charts

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-icecream-charts - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0

esm/_chart/langData/cn.d.ts

3

esm/_chart/chart.d.ts

@@ -9,2 +9,3 @@ /**

import { SeriesOptions } from './options/series';
import { LangData } from './langData';
export * from './options/chart';

@@ -40,2 +41,2 @@ export * from './options/plot';

}
export declare function createHighOptions(type: ChartType, chartOptions?: ChartOptions, plotOptions?: PlotOptions, specifiedChartHighOptions?: Highcharts.Options): Highcharts.Options;
export declare function createHighOptions(type: ChartType, chartOptions: ChartOptions | undefined, langData: LangData, plotOptions?: PlotOptions, specifiedChartHighOptions?: Highcharts.Options): Highcharts.Options;
import Highcharts from 'highcharts';
import NoDataToDisplay from 'highcharts/modules/no-data-to-display';
import { createHighLangOptions, createHighXAxisOptions } from './options/chart';
import { defaultColors } from './options/chart/colors';
import { createBottomCenterLegendOptions } from './options/chart/legend';
import { createHighPlotOptions } from './options/plot';
import { createHighLangOptions } from './options/chart/lang';
import { createHighOptionsFromChartOptions } from './utils/options';

@@ -16,12 +16,6 @@ import merge from './utils/merge';

// TODO: 换文档工具可以尝试去掉这个 if
// 放在这里的原因:
// The language object is global and it can't be set on each chart initialization.
// Instead, use `Highcharts.setOptions` to set it before any chart is initialized.
if (typeof Highcharts === 'object') {
NoDataToDisplay(Highcharts);
Highcharts.setOptions({
lang: createHighLangOptions()
});
}
export function createHighOptions(type, chartOptions, plotOptions,
export function createHighOptions(type, chartOptions, langData, plotOptions,
// 特定图表类型的内部配置

@@ -40,2 +34,4 @@ specifiedChartHighOptions) {

},
lang: createHighLangOptions(langData.langOptions),
xAxis: createHighXAxisOptions({ dateTimeLabelFormats: langData.xAxisDateTimeLabelFormats }),
// 默认颜色

@@ -42,0 +38,0 @@ colors: defaultColors,

import { Ref } from 'react';
import Highcharts from 'highcharts';
import { Chart } from './chart';
import { LangData } from './langData';
export declare type Options = {

@@ -9,3 +10,4 @@ chartRef?: Ref<Chart>;

loading?: boolean;
langData: LangData;
};
export declare function useHighOptions(chartOptions: Highcharts.Options, { chartRef, isMap, loading, callback }: Options): import("react").RefObject<HTMLDivElement>;
export declare function useHighOptions(chartOptions: Highcharts.Options, { chartRef: outerChartRef, isMap, loading, langData, callback }: Options): readonly [import("react").RefObject<HTMLDivElement>, import("react").MutableRefObject<() => void>];

@@ -1,10 +0,9 @@

import { useEffect, useImperativeHandle, useRef, useState } from 'react';
import { useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';
import Highcharts from 'highcharts';
import NoDataToDisplay from 'highcharts/modules/no-data-to-display';
import memoize from 'lodash.memoize';
import { createHighLangOptions } from './options/chart/lang';
var loadHighstock = memoize(function () { return import('highcharts/highstock').then(function (Highstock) {
var loadHighstock = memoize(function (langOptions) { return import('highcharts/highstock').then(function (Highstock) {
NoDataToDisplay(Highstock);
Highstock.setOptions({
lang: createHighLangOptions()
lang: langOptions
});

@@ -15,14 +14,15 @@ return Highstock;

export function useHighOptions(chartOptions, _a) {
var chartRef = _a.chartRef, isMap = _a.isMap, loading = _a.loading, callback = _a.callback;
var outerChartRef = _a.chartRef, isMap = _a.isMap, loading = _a.loading, langData = _a.langData, callback = _a.callback;
var renderToRef = useRef(null);
var _b = useState(), chart = _b[0], setChart = _b[1];
var chartInitializedRef = useRef(false);
useImperativeHandle(chartRef, function () { return ({
var chartRef = useRef();
var callbackRef = useAutoSyncRef(callback);
useImperativeHandle(outerChartRef, function () { return ({
resetZoom: function () {
var _a, _b;
(_a = chart === null || chart === void 0 ? void 0 : chart.xAxis) === null || _a === void 0 ? void 0 : _a.forEach(function (axis) { return axis.setExtremes(); });
(_b = chart === null || chart === void 0 ? void 0 : chart.yAxis) === null || _b === void 0 ? void 0 : _b.forEach(function (axis) { return axis.setExtremes(); });
var _a, _b, _c, _d;
(_b = (_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.xAxis) === null || _b === void 0 ? void 0 : _b.forEach(function (axis) { return axis.setExtremes(); });
(_d = (_c = chartRef.current) === null || _c === void 0 ? void 0 : _c.yAxis) === null || _d === void 0 ? void 0 : _d.forEach(function (axis) { return axis.setExtremes(); });
}
}); }, [chart]);
}); }, []);
useEffect(function () {
var chart = chartRef.current;
if (chart) {

@@ -36,33 +36,56 @@ if (loading) {

}
}, [loading, chart]);
useEffect(function () {
}, [loading]);
var createChartRef = useAutoSyncRef(function () {
var renderTo = renderToRef.current;
if (renderTo) {
if (chart) {
chart.update(chartOptions, true, true);
callback === null || callback === void 0 ? void 0 : callback(chart);
return;
}
// 由于 highmaps 及 highstock 是异步加载的,这里设置一个中间变量防止 setChart 多次
// 设置多次会导致 chart 的实例获取异常,怀疑是 highcharts 内部的问题
if (!chartInitializedRef.current) {
chartInitializedRef.current = true;
if (isMap) {
loadHighmaps().then(function (Highmaps) {
setChart(Highmaps.mapChart(renderTo, chartOptions, callback));
});
}
else if (chartOptions.navigator) {
loadHighstock().then(function (Highstock) {
setChart(Highstock.stockChart(renderTo, chartOptions, callback));
});
}
else {
setChart(Highcharts.chart(renderTo, chartOptions, callback));
}
}
if (!renderTo)
return;
var chartCallback = function (chart) {
var _a;
(_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, chart);
chartRef.current = chart;
};
chartRef.current = undefined;
if (isMap) {
loadHighmaps().then(function (Highmaps) {
Highmaps.setOptions({ lang: chartOptions.lang });
Highmaps.mapChart(renderTo, chartOptions, chartCallback);
});
}
}, [chartOptions, callback, isMap, loading, chart]);
useEffect(function () { return function () { return chart === null || chart === void 0 ? void 0 : chart.destroy(); }; }, [chart]);
return renderToRef;
else if (chartOptions.navigator) {
loadHighstock(chartOptions.lang).then(function (Highstock) {
Highstock.stockChart(renderTo, chartOptions, chartCallback);
});
}
else {
Highcharts.setOptions({ lang: chartOptions.lang });
Highcharts.chart(renderTo, chartOptions, chartCallback);
}
});
/**
* highcharts 的 chart.update 不能响应 lang 数据的变化,每次 lang 变化都需要:
* 1、Highcharts.setOptions 设置语言
* 2、创建新 chart
*/
useEffect(function () {
createChartRef.current();
}, [langData, createChartRef]);
useEffect(function () {
var _a;
var chart = chartRef.current;
if (!chart)
return;
chart.update(chartOptions, true, true);
(_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, chart);
}, [chartOptions, callbackRef]);
// highcharts 往同一个容器二次添加 chart 的时候会把之前的 chart 销毁;
// 所以这里只需要关注组件 unmount 的时候销毁 chart 实例即可
useEffect(function () { return function () { var _a; return (_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.destroy(); }; }, []);
return [renderToRef, createChartRef];
}
function useAutoSyncRef(parameter) {
var ref = useRef(parameter);
useLayoutEffect(function () {
ref.current = parameter;
});
return ref;
}
export * from './hooks';
export * from './chart';
export * from './langData';
export * from './hooks';
export * from './chart';
export * from './langData';

@@ -97,1 +97,2 @@ import { TooltipOptions } from './tooltip';

export * from './zoom-type';
export * from './lang';

@@ -11,1 +11,2 @@ export * from './tooltip';

export * from './zoom-type';
export * from './lang';

@@ -12,13 +12,5 @@ var __assign = (this && this.__assign) || function () {

};
var defaultLangOptions = {
noData: '暂无数据',
months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
shortMonths: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
weekdays: ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
loading: '加载中...',
resetZoom: '重置'
};
export function createHighLangOptions(options) {
if (options === void 0) { options = {}; }
return __assign(__assign({}, defaultLangOptions), options);
return __assign({}, options);
}

@@ -38,16 +38,2 @@ import { AxisLabelsOptions } from './common';

* for example the day unit can be used on midnight and hour unit be used for intermediate values on the same axis.
* Defaults to:
* ```json
{
"millisecond": "%H:%M:%S.%L",
"second": "%H:%M:%S",
"minute": "%H:%M:%S",
"hour": "%H:%M",
"day": "%b%d日",
"week": "%b%d日",
"month": "%Y %b",
"year": "%Y"
}
* ```
*/

@@ -54,0 +40,0 @@ dateTimeLabelFormats?: XAxisOptionsDateTimeLabelFormats;

@@ -16,13 +16,3 @@ var __assign = (this && this.__assign) || function () {

lineWidth: 1,
tickColor: Grey.grey5,
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M:%S',
hour: '%H:%M',
day: '%b%d日',
week: '%b%d日',
month: '%Y %b',
year: '%Y'
}
tickColor: Grey.grey5
};

@@ -29,0 +19,0 @@ export function createHighXAxisOptions(options) {

@@ -26,8 +26,15 @@ var __assign = (this && this.__assign) || function () {

import { useHighOptions } from '../_chart';
import { useConfig } from '../config-provider';
export * from './options';
export function AreaChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var areaOptions = useMemo(function () { return createAreaOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = useHighOptions(areaOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = useConfig().langData;
var areaOptions = useMemo(function () { return createAreaOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = useHighOptions(areaOptions, {
loading: loading,
chartRef: chartRef,
langData: langData,
callback: afterRendered
})[0];
return React.createElement("div", __assign({ ref: ref }, restProps));
}
import { createAreaOptions } from './options';
import { cnData } from '../_chart';
describe('Area Chart', function () {

@@ -18,5 +19,5 @@ test('basic', function () {

];
var highOptions = createAreaOptions(options, {}, series);
var highOptions = createAreaOptions(cnData, options, {}, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotAreaOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createAreaOptions(options?: PlotAreaOptions, chartOptions?: ChartOptions, series?: SeriesAreaOptions[]): Highcharts.Options;
export declare function createAreaOptions(langData: LangData, options?: PlotAreaOptions, chartOptions?: ChartOptions, series?: SeriesAreaOptions[]): Highcharts.Options;
import { Blue } from 'icecream-base/lib/colors';
import { createHighOptions, createHighSeriesOptions } from '../_chart';
export function createAreaOptions(options, chartOptions, series) {
export function createAreaOptions(langData, options, chartOptions, series) {
var areaOptions = {

@@ -27,3 +27,3 @@ legend: {

};
return createHighOptions('area', chartOptions, options, areaOptions);
return createHighOptions('area', chartOptions, langData, options, areaOptions);
}

@@ -26,8 +26,15 @@ var __assign = (this && this.__assign) || function () {

import { useHighOptions } from '../_chart';
import { useConfig } from '../config-provider';
export * from './options';
export function AreasplineChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var areasplineOptions = useMemo(function () { return createAreasplineOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = useHighOptions(areasplineOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = useConfig().langData;
var areasplineOptions = useMemo(function () { return createAreasplineOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = useHighOptions(areasplineOptions, {
chartRef: chartRef,
loading: loading,
langData: langData,
callback: afterRendered
})[0];
return React.createElement("div", __assign({ ref: ref }, restProps));
}
import { createAreasplineOptions } from './options';
import { cnData } from '../_chart';
describe('Areaspline Chart', function () {

@@ -17,5 +18,5 @@ test('basic', function () {

];
var highOptions = createAreasplineOptions(options, {}, series);
var highOptions = createAreasplineOptions(cnData, options, {}, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotAreasplineOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createAreasplineOptions(options?: PlotAreasplineOptions, chartOptions?: ChartOptions, series?: SeriesAreasplineOptions[]): Highcharts.Options;
export declare function createAreasplineOptions(langData: LangData, options?: PlotAreasplineOptions, chartOptions?: ChartOptions, series?: SeriesAreasplineOptions[]): Highcharts.Options;
import { createHighOptions, createHighSeriesOptions } from '../_chart';
export function createAreasplineOptions(options, chartOptions, series) {
export function createAreasplineOptions(langData, options, chartOptions, series) {
var areasplineOptions = {

@@ -19,3 +19,3 @@ legend: {

};
return createHighOptions('areaspline', chartOptions, options, areasplineOptions);
return createHighOptions('areaspline', chartOptions, langData, options, areasplineOptions);
}

@@ -26,8 +26,10 @@ var __assign = (this && this.__assign) || function () {

import { useHighOptions } from '../_chart';
import { useConfig } from '../config-provider';
export * from './options';
export function BarChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var barOptions = useMemo(function () { return createBarOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = useHighOptions(barOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = useConfig().langData;
var barOptions = useMemo(function () { return createBarOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = useHighOptions(barOptions, { chartRef: chartRef, callback: afterRendered, loading: loading, langData: langData })[0];
return React.createElement("div", __assign({ ref: ref }, restProps));
}
import { createBarOptions } from './options';
import { cnData } from '../_chart';
describe('Bar Chart', function () {

@@ -24,5 +25,5 @@ test('basic', function () {

];
var highOptions = createBarOptions({}, chartOptions, series);
var highOptions = createBarOptions(cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotBarOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createBarOptions(options?: PlotBarOptions, chartOptions?: ChartOptions, series?: SeriesBarOptions[]): Highcharts.Options;
export declare function createBarOptions(langData: LangData, options?: PlotBarOptions, chartOptions?: ChartOptions, series?: SeriesBarOptions[]): Highcharts.Options;

@@ -21,3 +21,3 @@ import { Blue, Yellow, Cyan, Olivine, Magenta, Purple, Cobalt, OrangeRed } from 'icecream-base/lib/colors';

];
export function createBarOptions(options, chartOptions, series) {
export function createBarOptions(langData, options, chartOptions, series) {
var barOptions = {

@@ -39,3 +39,3 @@ legend: createRightTopLegendOptions(),

};
return createHighOptions('bar', chartOptions, options, barOptions);
return createHighOptions('bar', chartOptions, langData, options, barOptions);
}

@@ -26,8 +26,10 @@ var __assign = (this && this.__assign) || function () {

import { useHighOptions } from '../_chart';
import { useConfig } from '../config-provider';
export * from './options';
export function ColumnChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var columnOptions = useMemo(function () { return createColumnOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = useHighOptions(columnOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = useConfig().langData;
var columnOptions = useMemo(function () { return createColumnOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = useHighOptions(columnOptions, { chartRef: chartRef, callback: afterRendered, loading: loading, langData: langData })[0];
return React.createElement("div", __assign({ ref: ref }, restProps));
}
import { createColumnOptions } from './options';
import { cnData } from '../_chart';
describe('Column Chart', function () {

@@ -19,5 +20,5 @@ test('basic', function () {

];
var highOptions = createColumnOptions({}, chartOptions, series);
var highOptions = createColumnOptions(cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotColumnOptions extends PlotOptions {

@@ -16,2 +16,2 @@ /**

}
export declare function createColumnOptions(options?: PlotColumnOptions, chartOptions?: ChartOptions, series?: SeriesColumnOptions[]): Highcharts.Options;
export declare function createColumnOptions(langData: LangData, options?: PlotColumnOptions, chartOptions?: ChartOptions, series?: SeriesColumnOptions[]): Highcharts.Options;
import { Blue, Yellow, Cyan, Olivine, Magenta, Purple, Cobalt, OrangeRed } from 'icecream-base/lib/colors';
import { createHighOptions, createSeriesWithStateHoverColors } from '../_chart';
import { defaultColors } from '../_chart/options/chart/colors';
export function createColumnOptions(options, chartOptions, series) {
export function createColumnOptions(langData, options, chartOptions, series) {
var columnOptions = {

@@ -37,3 +37,3 @@ colors: [

};
return createHighOptions('column', chartOptions, options, columnOptions);
return createHighOptions('column', chartOptions, langData, options, columnOptions);
}

@@ -12,1 +12,2 @@ export * from './_chart';

export * from './map';
export * from './config-provider';

@@ -12,1 +12,2 @@ export * from './_chart';

export * from './map';
export * from './config-provider';

@@ -26,8 +26,15 @@ var __assign = (this && this.__assign) || function () {

import { useHighOptions } from '../_chart';
import { useConfig } from '../config-provider';
export * from './options';
export function LineChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var lineOptions = useMemo(function () { return createLineOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = useHighOptions(lineOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = useConfig().langData;
var lineOptions = useMemo(function () { return createLineOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = useHighOptions(lineOptions, {
loading: loading,
chartRef: chartRef,
langData: langData,
callback: afterRendered
})[0];
return React.createElement("div", __assign({ ref: ref }, restProps));
}
import { createLineOptions } from './options';
import { cnData } from '../_chart';
describe('Line Chart', function () {

@@ -32,5 +33,5 @@ test('basic', function () {

];
var highOptions = createLineOptions(options, chartOptions, series);
var highOptions = createLineOptions(cnData, options, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotLineOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createLineOptions(options?: PlotLineOptions, chartOptions?: ChartOptions, series?: SeriesLineOptions[]): Highcharts.Options;
export declare function createLineOptions(langData: LangData, options?: PlotLineOptions, chartOptions?: ChartOptions, series?: SeriesLineOptions[]): Highcharts.Options;
import { Blue } from 'icecream-base/lib/colors';
import { createHighOptions, createHighSeriesOptions } from '../_chart';
export function createLineOptions(options, chartOptions, series) {
export function createLineOptions(langData, options, chartOptions, series) {
var lineOptions = {

@@ -21,3 +21,3 @@ xAxis: {

};
return createHighOptions('line', chartOptions, options, lineOptions);
return createHighOptions('line', chartOptions, langData, options, lineOptions);
}

@@ -23,5 +23,13 @@ var __assign = (this && this.__assign) || function () {

};
import React, { useMemo } from 'react';
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
import React, { useMemo, useEffect } from 'react';
import { createMapOptions } from './options';
import { useHighOptions } from '../_chart';
import { useConfig } from '../config-provider';
export * from './options';

@@ -31,5 +39,20 @@ export * from './map-data';

var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var mapOptions = useMemo(function () { return createMapOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = useHighOptions(mapOptions, { chartRef: chartRef, callback: afterRendered, isMap: true, loading: loading });
var langData = useConfig().langData;
var mapOptions = useMemo(function () { return createMapOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var _a = useHighOptions(mapOptions, {
chartRef: chartRef,
isMap: true,
loading: loading,
langData: langData,
callback: afterRendered
}), ref = _a[0], reloadChartRef = _a[1];
var mapDataList = (series !== null && series !== void 0 ? series : []).map(function (d) { return d.mapData; });
/**
* Mapcharts 下 mapchart.update 不能响应 mapData 数据的变化,外部 mapData 可能会延迟加载,每次 mapData 变化都需要重新创建 mapchart
*/
useEffect(function () {
reloadChartRef.current();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, __spreadArrays([reloadChartRef], mapDataList));
return React.createElement("div", __assign({ ref: ref }, restProps));
}
import { createMapOptions } from './options';
import { cnData } from '../_chart';
describe('Map Chart', function () {

@@ -24,5 +25,5 @@ test('basic', function () {

];
var highOptions = createMapOptions({}, chartOptions, series);
var highOptions = createMapOptions(cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotMapOptions extends PlotOptions {

@@ -20,2 +20,2 @@ }

}
export declare function createMapOptions(options?: PlotMapOptions, chartOptions?: ChartOptions, series?: SeriesMapOptions[]): Highcharts.Options;
export declare function createMapOptions(langData: LangData, options?: PlotMapOptions, chartOptions?: ChartOptions, series?: SeriesMapOptions[]): Highcharts.Options;
import { Blue } from 'icecream-base/lib/colors';
import { createHighOptions, createMapLegendOptions, createHighSeriesOptions } from '../_chart';
export function createMapOptions(options, chartOptions, series) {
export function createMapOptions(langData, options, chartOptions, series) {
var _a;

@@ -37,3 +37,3 @@ var mapOptions = {

};
return createHighOptions('map', chartOptions, options, mapOptions);
return createHighOptions('map', chartOptions, langData, options, mapOptions);
}

@@ -27,2 +27,3 @@ var __assign = (this && this.__assign) || function () {

import { cssObjectToLiterialString } from '../_chart/utils/style';
import { useConfig } from '../config-provider';
export * from './options';

@@ -34,3 +35,4 @@ export function PieChart(props) {

var innerSubtitleRef = useRef();
var pieOptions = useMemo(function () { return createPieOptions(plotOptions, chartOptions, series); }, [plotOptions, chartOptions, series]);
var langData = useConfig().langData;
var pieOptions = useMemo(function () { return createPieOptions(langData, plotOptions, chartOptions, series); }, [langData, plotOptions, chartOptions, series]);
var callback = useCallback(function (chart) {

@@ -54,3 +56,8 @@ var _a, _b;

}, [chartOptions === null || chartOptions === void 0 ? void 0 : chartOptions.legend, innerTitle, innerSubtitle, afterRendered]);
var ref = useHighOptions(pieOptions, { chartRef: chartRef, callback: callback, loading: loading });
var ref = useHighOptions(pieOptions, {
chartRef: chartRef,
callback: callback,
loading: loading,
langData: langData
})[0];
return React.createElement("div", __assign({ ref: ref }, restProps));

@@ -57,0 +64,0 @@ }

@@ -0,1 +1,2 @@

import { cnData } from '../_chart';
import { createPieOptions } from './options';

@@ -34,5 +35,5 @@ describe('Pie Chart', function () {

}];
var highOptions = createPieOptions(options, chartOptions, series);
var highOptions = createPieOptions(cnData, options, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});
import { CSSObject } from 'highcharts';
import { PlotOptions, ChartOptions, SeriesOptions, PointOptionsObject } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions, PointOptionsObject } from '../_chart';
export declare type InnerTitleObjectOptions = {

@@ -58,2 +58,2 @@ /**

}
export declare function createPieOptions(options?: PlotPieOptions, chartOptions?: ChartOptions, series?: SeriesPieOptions[]): Highcharts.Options;
export declare function createPieOptions(langData: LangData, options?: PlotPieOptions, chartOptions?: ChartOptions, series?: SeriesPieOptions[]): Highcharts.Options;

@@ -25,3 +25,3 @@ var __assign = (this && this.__assign) || function () {

import { createHighOptions, createRightCenterLegendOptions, createHighSeriesOptions, isPointOptionsObject, createHighPointOptions } from '../_chart';
export function createPieOptions(options, chartOptions, series) {
export function createPieOptions(langData, options, chartOptions, series) {
var pieOptions = {

@@ -62,3 +62,3 @@ colors: [

};
return createHighOptions('pie', chartOptions, options, pieOptions);
return createHighOptions('pie', chartOptions, langData, options, pieOptions);
}

@@ -65,0 +65,0 @@ function createSeriesPieOptions(series) {

@@ -26,8 +26,15 @@ var __assign = (this && this.__assign) || function () {

import { useHighOptions } from '../_chart';
import { useConfig } from '../config-provider';
export * from './options';
export function ScatterChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var scatterOptions = useMemo(function () { return createScatterOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = useHighOptions(scatterOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = useConfig().langData;
var scatterOptions = useMemo(function () { return createScatterOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = useHighOptions(scatterOptions, {
loading: loading,
chartRef: chartRef,
langData: langData,
callback: afterRendered
})[0];
return React.createElement("div", __assign({ ref: ref }, restProps));
}

@@ -0,1 +1,2 @@

import { cnData } from '../_chart';
import { createScatterOptions } from './options';

@@ -21,5 +22,5 @@ describe('Scatter Chart', function () {

];
var highOptions = createScatterOptions({}, chartOptions, series);
var highOptions = createScatterOptions(cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotScatterOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createScatterOptions(options?: PlotScatterOptions, chartOptions?: ChartOptions, series?: SeriesScatterOptions[]): Highcharts.Options;
export declare function createScatterOptions(langData: LangData, options?: PlotScatterOptions, chartOptions?: ChartOptions, series?: SeriesScatterOptions[]): Highcharts.Options;
import { Cobalt, Blue, Green, Olivine, Yellow, OrangeRed, Magenta, Purple } from 'icecream-base/lib/colors';
import { createHighOptions } from '../_chart';
export function createScatterOptions(options, chartOptions, series) {
export function createScatterOptions(langData, options, chartOptions, series) {
var scatterOptions = {

@@ -39,3 +39,3 @@ colors: [

};
return createHighOptions('scatter', chartOptions, options, scatterOptions);
return createHighOptions('scatter', chartOptions, langData, options, scatterOptions);
}

@@ -26,8 +26,15 @@ var __assign = (this && this.__assign) || function () {

import { useHighOptions } from '../_chart';
import { useConfig } from '../config-provider';
export * from './options';
export function SplineChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var splineOptions = useMemo(function () { return createSplineOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = useHighOptions(splineOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = useConfig().langData;
var splineOptions = useMemo(function () { return createSplineOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = useHighOptions(splineOptions, {
loading: loading,
chartRef: chartRef,
langData: langData,
callback: afterRendered
})[0];
return React.createElement("div", __assign({ ref: ref }, restProps));
}

@@ -0,1 +1,2 @@

import { cnData } from '../_chart';
import { createSplineOptions } from './options';

@@ -63,5 +64,5 @@ describe('Spline Chart', function () {

];
var highOptions = createSplineOptions({}, chartOptions, series);
var highOptions = createSplineOptions(cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotSplineOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createSplineOptions(options?: PlotSplineOptions, chartOptions?: ChartOptions, series?: SeriesSplineOptions[]): Highcharts.Options;
export declare function createSplineOptions(langData: LangData, options?: PlotSplineOptions, chartOptions?: ChartOptions, series?: SeriesSplineOptions[]): Highcharts.Options;
import { createHighOptions } from '../_chart';
export function createSplineOptions(options, chartOptions, series) {
export function createSplineOptions(langData, options, chartOptions, series) {
var splineOptions = {

@@ -13,3 +13,3 @@ plotOptions: {

};
return createHighOptions('spline', chartOptions, options, splineOptions);
return createHighOptions('spline', chartOptions, langData, options, splineOptions);
}

@@ -9,2 +9,3 @@ /**

import { SeriesOptions } from './options/series';
import { LangData } from './langData';
export * from './options/chart';

@@ -40,2 +41,2 @@ export * from './options/plot';

}
export declare function createHighOptions(type: ChartType, chartOptions?: ChartOptions, plotOptions?: PlotOptions, specifiedChartHighOptions?: Highcharts.Options): Highcharts.Options;
export declare function createHighOptions(type: ChartType, chartOptions: ChartOptions | undefined, langData: LangData, plotOptions?: PlotOptions, specifiedChartHighOptions?: Highcharts.Options): Highcharts.Options;

@@ -19,6 +19,6 @@ "use strict";

var no_data_to_display_1 = __importDefault(require("highcharts/modules/no-data-to-display"));
var chart_1 = require("./options/chart");
var colors_1 = require("./options/chart/colors");
var legend_1 = require("./options/chart/legend");
var plot_1 = require("./options/plot");
var lang_1 = require("./options/chart/lang");
var options_1 = require("./utils/options");

@@ -33,12 +33,6 @@ var merge_1 = __importDefault(require("./utils/merge"));

// TODO: 换文档工具可以尝试去掉这个 if
// 放在这里的原因:
// The language object is global and it can't be set on each chart initialization.
// Instead, use `Highcharts.setOptions` to set it before any chart is initialized.
if (typeof highcharts_1.default === 'object') {
no_data_to_display_1.default(highcharts_1.default);
highcharts_1.default.setOptions({
lang: lang_1.createHighLangOptions()
});
}
function createHighOptions(type, chartOptions, plotOptions,
function createHighOptions(type, chartOptions, langData, plotOptions,
// 特定图表类型的内部配置

@@ -57,2 +51,4 @@ specifiedChartHighOptions) {

},
lang: chart_1.createHighLangOptions(langData.langOptions),
xAxis: chart_1.createHighXAxisOptions({ dateTimeLabelFormats: langData.xAxisDateTimeLabelFormats }),
// 默认颜色

@@ -59,0 +55,0 @@ colors: colors_1.defaultColors,

import { Ref } from 'react';
import Highcharts from 'highcharts';
import { Chart } from './chart';
import { LangData } from './langData';
export declare type Options = {

@@ -9,3 +10,4 @@ chartRef?: Ref<Chart>;

loading?: boolean;
langData: LangData;
};
export declare function useHighOptions(chartOptions: Highcharts.Options, { chartRef, isMap, loading, callback }: Options): import("react").RefObject<HTMLDivElement>;
export declare function useHighOptions(chartOptions: Highcharts.Options, { chartRef: outerChartRef, isMap, loading, langData, callback }: Options): readonly [import("react").RefObject<HTMLDivElement>, import("react").MutableRefObject<() => void>];

@@ -30,7 +30,6 @@ "use strict";

var lodash_memoize_1 = __importDefault(require("lodash.memoize"));
var lang_1 = require("./options/chart/lang");
var loadHighstock = lodash_memoize_1.default(function () { return Promise.resolve().then(function () { return __importStar(require('highcharts/highstock')); }).then(function (Highstock) {
var loadHighstock = lodash_memoize_1.default(function (langOptions) { return Promise.resolve().then(function () { return __importStar(require('highcharts/highstock')); }).then(function (Highstock) {
no_data_to_display_1.default(Highstock);
Highstock.setOptions({
lang: lang_1.createHighLangOptions()
lang: langOptions
});

@@ -41,14 +40,15 @@ return Highstock;

function useHighOptions(chartOptions, _a) {
var chartRef = _a.chartRef, isMap = _a.isMap, loading = _a.loading, callback = _a.callback;
var outerChartRef = _a.chartRef, isMap = _a.isMap, loading = _a.loading, langData = _a.langData, callback = _a.callback;
var renderToRef = react_1.useRef(null);
var _b = react_1.useState(), chart = _b[0], setChart = _b[1];
var chartInitializedRef = react_1.useRef(false);
react_1.useImperativeHandle(chartRef, function () { return ({
var chartRef = react_1.useRef();
var callbackRef = useAutoSyncRef(callback);
react_1.useImperativeHandle(outerChartRef, function () { return ({
resetZoom: function () {
var _a, _b;
(_a = chart === null || chart === void 0 ? void 0 : chart.xAxis) === null || _a === void 0 ? void 0 : _a.forEach(function (axis) { return axis.setExtremes(); });
(_b = chart === null || chart === void 0 ? void 0 : chart.yAxis) === null || _b === void 0 ? void 0 : _b.forEach(function (axis) { return axis.setExtremes(); });
var _a, _b, _c, _d;
(_b = (_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.xAxis) === null || _b === void 0 ? void 0 : _b.forEach(function (axis) { return axis.setExtremes(); });
(_d = (_c = chartRef.current) === null || _c === void 0 ? void 0 : _c.yAxis) === null || _d === void 0 ? void 0 : _d.forEach(function (axis) { return axis.setExtremes(); });
}
}); }, [chart]);
}); }, []);
react_1.useEffect(function () {
var chart = chartRef.current;
if (chart) {

@@ -62,34 +62,57 @@ if (loading) {

}
}, [loading, chart]);
react_1.useEffect(function () {
}, [loading]);
var createChartRef = useAutoSyncRef(function () {
var renderTo = renderToRef.current;
if (renderTo) {
if (chart) {
chart.update(chartOptions, true, true);
callback === null || callback === void 0 ? void 0 : callback(chart);
return;
}
// 由于 highmaps 及 highstock 是异步加载的,这里设置一个中间变量防止 setChart 多次
// 设置多次会导致 chart 的实例获取异常,怀疑是 highcharts 内部的问题
if (!chartInitializedRef.current) {
chartInitializedRef.current = true;
if (isMap) {
loadHighmaps().then(function (Highmaps) {
setChart(Highmaps.mapChart(renderTo, chartOptions, callback));
});
}
else if (chartOptions.navigator) {
loadHighstock().then(function (Highstock) {
setChart(Highstock.stockChart(renderTo, chartOptions, callback));
});
}
else {
setChart(highcharts_1.default.chart(renderTo, chartOptions, callback));
}
}
if (!renderTo)
return;
var chartCallback = function (chart) {
var _a;
(_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, chart);
chartRef.current = chart;
};
chartRef.current = undefined;
if (isMap) {
loadHighmaps().then(function (Highmaps) {
Highmaps.setOptions({ lang: chartOptions.lang });
Highmaps.mapChart(renderTo, chartOptions, chartCallback);
});
}
}, [chartOptions, callback, isMap, loading, chart]);
react_1.useEffect(function () { return function () { return chart === null || chart === void 0 ? void 0 : chart.destroy(); }; }, [chart]);
return renderToRef;
else if (chartOptions.navigator) {
loadHighstock(chartOptions.lang).then(function (Highstock) {
Highstock.stockChart(renderTo, chartOptions, chartCallback);
});
}
else {
highcharts_1.default.setOptions({ lang: chartOptions.lang });
highcharts_1.default.chart(renderTo, chartOptions, chartCallback);
}
});
/**
* highcharts 的 chart.update 不能响应 lang 数据的变化,每次 lang 变化都需要:
* 1、Highcharts.setOptions 设置语言
* 2、创建新 chart
*/
react_1.useEffect(function () {
createChartRef.current();
}, [langData, createChartRef]);
react_1.useEffect(function () {
var _a;
var chart = chartRef.current;
if (!chart)
return;
chart.update(chartOptions, true, true);
(_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, chart);
}, [chartOptions, callbackRef]);
// highcharts 往同一个容器二次添加 chart 的时候会把之前的 chart 销毁;
// 所以这里只需要关注组件 unmount 的时候销毁 chart 实例即可
react_1.useEffect(function () { return function () { var _a; return (_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.destroy(); }; }, []);
return [renderToRef, createChartRef];
}
exports.useHighOptions = useHighOptions;
function useAutoSyncRef(parameter) {
var ref = react_1.useRef(parameter);
react_1.useLayoutEffect(function () {
ref.current = parameter;
});
return ref;
}
export * from './hooks';
export * from './chart';
export * from './langData';

@@ -15,1 +15,2 @@ "use strict";

__exportStar(require("./chart"), exports);
__exportStar(require("./langData"), exports);

@@ -97,1 +97,2 @@ import { TooltipOptions } from './tooltip';

export * from './zoom-type';
export * from './lang';

@@ -23,1 +23,2 @@ "use strict";

__exportStar(require("./zoom-type"), exports);
__exportStar(require("./lang"), exports);

@@ -15,14 +15,6 @@ "use strict";

exports.createHighLangOptions = void 0;
var defaultLangOptions = {
noData: '暂无数据',
months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
shortMonths: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
weekdays: ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
loading: '加载中...',
resetZoom: '重置'
};
function createHighLangOptions(options) {
if (options === void 0) { options = {}; }
return __assign(__assign({}, defaultLangOptions), options);
return __assign({}, options);
}
exports.createHighLangOptions = createHighLangOptions;

@@ -38,16 +38,2 @@ import { AxisLabelsOptions } from './common';

* for example the day unit can be used on midnight and hour unit be used for intermediate values on the same axis.
* Defaults to:
* ```json
{
"millisecond": "%H:%M:%S.%L",
"second": "%H:%M:%S",
"minute": "%H:%M:%S",
"hour": "%H:%M",
"day": "%b%d日",
"week": "%b%d日",
"month": "%Y %b",
"year": "%Y"
}
* ```
*/

@@ -54,0 +40,0 @@ dateTimeLabelFormats?: XAxisOptionsDateTimeLabelFormats;

@@ -19,13 +19,3 @@ "use strict";

lineWidth: 1,
tickColor: colors_1.Grey.grey5,
dateTimeLabelFormats: {
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M:%S',
hour: '%H:%M',
day: '%b%d日',
week: '%b%d日',
month: '%Y %b',
year: '%Y'
}
tickColor: colors_1.Grey.grey5
};

@@ -32,0 +22,0 @@ function createHighXAxisOptions(options) {

@@ -51,9 +51,16 @@ "use strict";

var _chart_1 = require("../_chart");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);
function AreaChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var areaOptions = react_1.useMemo(function () { return options_1.createAreaOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = _chart_1.useHighOptions(areaOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = config_provider_1.useConfig().langData;
var areaOptions = react_1.useMemo(function () { return options_1.createAreaOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = _chart_1.useHighOptions(areaOptions, {
loading: loading,
chartRef: chartRef,
langData: langData,
callback: afterRendered
})[0];
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));
}
exports.AreaChart = AreaChart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var options_1 = require("./options");
var _chart_1 = require("../_chart");
describe('Area Chart', function () {

@@ -20,5 +21,5 @@ test('basic', function () {

];
var highOptions = options_1.createAreaOptions(options, {}, series);
var highOptions = options_1.createAreaOptions(_chart_1.cnData, options, {}, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotAreaOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createAreaOptions(options?: PlotAreaOptions, chartOptions?: ChartOptions, series?: SeriesAreaOptions[]): Highcharts.Options;
export declare function createAreaOptions(langData: LangData, options?: PlotAreaOptions, chartOptions?: ChartOptions, series?: SeriesAreaOptions[]): Highcharts.Options;

@@ -6,3 +6,3 @@ "use strict";

var _chart_1 = require("../_chart");
function createAreaOptions(options, chartOptions, series) {
function createAreaOptions(langData, options, chartOptions, series) {
var areaOptions = {

@@ -31,4 +31,4 @@ legend: {

};
return _chart_1.createHighOptions('area', chartOptions, options, areaOptions);
return _chart_1.createHighOptions('area', chartOptions, langData, options, areaOptions);
}
exports.createAreaOptions = createAreaOptions;

@@ -51,9 +51,16 @@ "use strict";

var _chart_1 = require("../_chart");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);
function AreasplineChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var areasplineOptions = react_1.useMemo(function () { return options_1.createAreasplineOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = _chart_1.useHighOptions(areasplineOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = config_provider_1.useConfig().langData;
var areasplineOptions = react_1.useMemo(function () { return options_1.createAreasplineOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = _chart_1.useHighOptions(areasplineOptions, {
chartRef: chartRef,
loading: loading,
langData: langData,
callback: afterRendered
})[0];
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));
}
exports.AreasplineChart = AreasplineChart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var options_1 = require("./options");
var _chart_1 = require("../_chart");
describe('Areaspline Chart', function () {

@@ -19,5 +20,5 @@ test('basic', function () {

];
var highOptions = options_1.createAreasplineOptions(options, {}, series);
var highOptions = options_1.createAreasplineOptions(_chart_1.cnData, options, {}, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotAreasplineOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createAreasplineOptions(options?: PlotAreasplineOptions, chartOptions?: ChartOptions, series?: SeriesAreasplineOptions[]): Highcharts.Options;
export declare function createAreasplineOptions(langData: LangData, options?: PlotAreasplineOptions, chartOptions?: ChartOptions, series?: SeriesAreasplineOptions[]): Highcharts.Options;

@@ -5,3 +5,3 @@ "use strict";

var _chart_1 = require("../_chart");
function createAreasplineOptions(options, chartOptions, series) {
function createAreasplineOptions(langData, options, chartOptions, series) {
var areasplineOptions = {

@@ -23,4 +23,4 @@ legend: {

};
return _chart_1.createHighOptions('areaspline', chartOptions, options, areasplineOptions);
return _chart_1.createHighOptions('areaspline', chartOptions, langData, options, areasplineOptions);
}
exports.createAreasplineOptions = createAreasplineOptions;

@@ -51,9 +51,11 @@ "use strict";

var _chart_1 = require("../_chart");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);
function BarChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var barOptions = react_1.useMemo(function () { return options_1.createBarOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = _chart_1.useHighOptions(barOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = config_provider_1.useConfig().langData;
var barOptions = react_1.useMemo(function () { return options_1.createBarOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = _chart_1.useHighOptions(barOptions, { chartRef: chartRef, callback: afterRendered, loading: loading, langData: langData })[0];
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));
}
exports.BarChart = BarChart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var options_1 = require("./options");
var _chart_1 = require("../_chart");
describe('Bar Chart', function () {

@@ -26,5 +27,5 @@ test('basic', function () {

];
var highOptions = options_1.createBarOptions({}, chartOptions, series);
var highOptions = options_1.createBarOptions(_chart_1.cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotBarOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createBarOptions(options?: PlotBarOptions, chartOptions?: ChartOptions, series?: SeriesBarOptions[]): Highcharts.Options;
export declare function createBarOptions(langData: LangData, options?: PlotBarOptions, chartOptions?: ChartOptions, series?: SeriesBarOptions[]): Highcharts.Options;

@@ -24,3 +24,3 @@ "use strict";

];
function createBarOptions(options, chartOptions, series) {
function createBarOptions(langData, options, chartOptions, series) {
var barOptions = {

@@ -42,4 +42,4 @@ legend: _chart_1.createRightTopLegendOptions(),

};
return _chart_1.createHighOptions('bar', chartOptions, options, barOptions);
return _chart_1.createHighOptions('bar', chartOptions, langData, options, barOptions);
}
exports.createBarOptions = createBarOptions;

@@ -51,9 +51,11 @@ "use strict";

var _chart_1 = require("../_chart");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);
function ColumnChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var columnOptions = react_1.useMemo(function () { return options_1.createColumnOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = _chart_1.useHighOptions(columnOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = config_provider_1.useConfig().langData;
var columnOptions = react_1.useMemo(function () { return options_1.createColumnOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = _chart_1.useHighOptions(columnOptions, { chartRef: chartRef, callback: afterRendered, loading: loading, langData: langData })[0];
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));
}
exports.ColumnChart = ColumnChart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var options_1 = require("./options");
var _chart_1 = require("../_chart");
describe('Column Chart', function () {

@@ -21,5 +22,5 @@ test('basic', function () {

];
var highOptions = options_1.createColumnOptions({}, chartOptions, series);
var highOptions = options_1.createColumnOptions(_chart_1.cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotColumnOptions extends PlotOptions {

@@ -16,2 +16,2 @@ /**

}
export declare function createColumnOptions(options?: PlotColumnOptions, chartOptions?: ChartOptions, series?: SeriesColumnOptions[]): Highcharts.Options;
export declare function createColumnOptions(langData: LangData, options?: PlotColumnOptions, chartOptions?: ChartOptions, series?: SeriesColumnOptions[]): Highcharts.Options;

@@ -7,3 +7,3 @@ "use strict";

var colors_2 = require("../_chart/options/chart/colors");
function createColumnOptions(options, chartOptions, series) {
function createColumnOptions(langData, options, chartOptions, series) {
var columnOptions = {

@@ -41,4 +41,4 @@ colors: [

};
return _chart_1.createHighOptions('column', chartOptions, options, columnOptions);
return _chart_1.createHighOptions('column', chartOptions, langData, options, columnOptions);
}
exports.createColumnOptions = createColumnOptions;

@@ -12,1 +12,2 @@ export * from './_chart';

export * from './map';
export * from './config-provider';

@@ -24,1 +24,2 @@ "use strict";

__exportStar(require("./map"), exports);
__exportStar(require("./config-provider"), exports);

@@ -51,9 +51,16 @@ "use strict";

var _chart_1 = require("../_chart");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);
function LineChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var lineOptions = react_1.useMemo(function () { return options_1.createLineOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = _chart_1.useHighOptions(lineOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = config_provider_1.useConfig().langData;
var lineOptions = react_1.useMemo(function () { return options_1.createLineOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = _chart_1.useHighOptions(lineOptions, {
loading: loading,
chartRef: chartRef,
langData: langData,
callback: afterRendered
})[0];
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));
}
exports.LineChart = LineChart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var options_1 = require("./options");
var _chart_1 = require("../_chart");
describe('Line Chart', function () {

@@ -34,5 +35,5 @@ test('basic', function () {

];
var highOptions = options_1.createLineOptions(options, chartOptions, series);
var highOptions = options_1.createLineOptions(_chart_1.cnData, options, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotLineOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createLineOptions(options?: PlotLineOptions, chartOptions?: ChartOptions, series?: SeriesLineOptions[]): Highcharts.Options;
export declare function createLineOptions(langData: LangData, options?: PlotLineOptions, chartOptions?: ChartOptions, series?: SeriesLineOptions[]): Highcharts.Options;

@@ -6,3 +6,3 @@ "use strict";

var _chart_1 = require("../_chart");
function createLineOptions(options, chartOptions, series) {
function createLineOptions(langData, options, chartOptions, series) {
var lineOptions = {

@@ -25,4 +25,4 @@ xAxis: {

};
return _chart_1.createHighOptions('line', chartOptions, options, lineOptions);
return _chart_1.createHighOptions('line', chartOptions, langData, options, lineOptions);
}
exports.createLineOptions = createLineOptions;

@@ -46,2 +46,9 @@ "use strict";

};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -52,2 +59,3 @@ exports.MapChart = void 0;

var _chart_1 = require("../_chart");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);

@@ -57,6 +65,21 @@ __exportStar(require("./map-data"), exports);

var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var mapOptions = react_1.useMemo(function () { return options_1.createMapOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = _chart_1.useHighOptions(mapOptions, { chartRef: chartRef, callback: afterRendered, isMap: true, loading: loading });
var langData = config_provider_1.useConfig().langData;
var mapOptions = react_1.useMemo(function () { return options_1.createMapOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var _a = _chart_1.useHighOptions(mapOptions, {
chartRef: chartRef,
isMap: true,
loading: loading,
langData: langData,
callback: afterRendered
}), ref = _a[0], reloadChartRef = _a[1];
var mapDataList = (series !== null && series !== void 0 ? series : []).map(function (d) { return d.mapData; });
/**
* Mapcharts 下 mapchart.update 不能响应 mapData 数据的变化,外部 mapData 可能会延迟加载,每次 mapData 变化都需要重新创建 mapchart
*/
react_1.useEffect(function () {
reloadChartRef.current();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, __spreadArrays([reloadChartRef], mapDataList));
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));
}
exports.MapChart = MapChart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var options_1 = require("./options");
var _chart_1 = require("../_chart");
describe('Map Chart', function () {

@@ -26,5 +27,5 @@ test('basic', function () {

];
var highOptions = options_1.createMapOptions({}, chartOptions, series);
var highOptions = options_1.createMapOptions(_chart_1.cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotMapOptions extends PlotOptions {

@@ -20,2 +20,2 @@ }

}
export declare function createMapOptions(options?: PlotMapOptions, chartOptions?: ChartOptions, series?: SeriesMapOptions[]): Highcharts.Options;
export declare function createMapOptions(langData: LangData, options?: PlotMapOptions, chartOptions?: ChartOptions, series?: SeriesMapOptions[]): Highcharts.Options;

@@ -6,3 +6,3 @@ "use strict";

var _chart_1 = require("../_chart");
function createMapOptions(options, chartOptions, series) {
function createMapOptions(langData, options, chartOptions, series) {
var _a;

@@ -41,4 +41,4 @@ var mapOptions = {

};
return _chart_1.createHighOptions('map', chartOptions, options, mapOptions);
return _chart_1.createHighOptions('map', chartOptions, langData, options, mapOptions);
}
exports.createMapOptions = createMapOptions;

@@ -52,2 +52,3 @@ "use strict";

var style_1 = require("../_chart/utils/style");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);

@@ -59,3 +60,4 @@ function PieChart(props) {

var innerSubtitleRef = react_1.useRef();
var pieOptions = react_1.useMemo(function () { return options_1.createPieOptions(plotOptions, chartOptions, series); }, [plotOptions, chartOptions, series]);
var langData = config_provider_1.useConfig().langData;
var pieOptions = react_1.useMemo(function () { return options_1.createPieOptions(langData, plotOptions, chartOptions, series); }, [langData, plotOptions, chartOptions, series]);
var callback = react_1.useCallback(function (chart) {

@@ -79,3 +81,8 @@ var _a, _b;

}, [chartOptions === null || chartOptions === void 0 ? void 0 : chartOptions.legend, innerTitle, innerSubtitle, afterRendered]);
var ref = _chart_1.useHighOptions(pieOptions, { chartRef: chartRef, callback: callback, loading: loading });
var ref = _chart_1.useHighOptions(pieOptions, {
chartRef: chartRef,
callback: callback,
loading: loading,
langData: langData
})[0];
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));

@@ -82,0 +89,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _chart_1 = require("../_chart");
var options_1 = require("./options");

@@ -36,5 +37,5 @@ describe('Pie Chart', function () {

}];
var highOptions = options_1.createPieOptions(options, chartOptions, series);
var highOptions = options_1.createPieOptions(_chart_1.cnData, options, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});
import { CSSObject } from 'highcharts';
import { PlotOptions, ChartOptions, SeriesOptions, PointOptionsObject } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions, PointOptionsObject } from '../_chart';
export declare type InnerTitleObjectOptions = {

@@ -58,2 +58,2 @@ /**

}
export declare function createPieOptions(options?: PlotPieOptions, chartOptions?: ChartOptions, series?: SeriesPieOptions[]): Highcharts.Options;
export declare function createPieOptions(langData: LangData, options?: PlotPieOptions, chartOptions?: ChartOptions, series?: SeriesPieOptions[]): Highcharts.Options;

@@ -28,3 +28,3 @@ "use strict";

var _chart_1 = require("../_chart");
function createPieOptions(options, chartOptions, series) {
function createPieOptions(langData, options, chartOptions, series) {
var pieOptions = {

@@ -65,3 +65,3 @@ colors: [

};
return _chart_1.createHighOptions('pie', chartOptions, options, pieOptions);
return _chart_1.createHighOptions('pie', chartOptions, langData, options, pieOptions);
}

@@ -68,0 +68,0 @@ exports.createPieOptions = createPieOptions;

@@ -51,9 +51,16 @@ "use strict";

var _chart_1 = require("../_chart");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);
function ScatterChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var scatterOptions = react_1.useMemo(function () { return options_1.createScatterOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = _chart_1.useHighOptions(scatterOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = config_provider_1.useConfig().langData;
var scatterOptions = react_1.useMemo(function () { return options_1.createScatterOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = _chart_1.useHighOptions(scatterOptions, {
loading: loading,
chartRef: chartRef,
langData: langData,
callback: afterRendered
})[0];
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));
}
exports.ScatterChart = ScatterChart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _chart_1 = require("../_chart");
var options_1 = require("./options");

@@ -23,5 +24,5 @@ describe('Scatter Chart', function () {

];
var highOptions = options_1.createScatterOptions({}, chartOptions, series);
var highOptions = options_1.createScatterOptions(_chart_1.cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotScatterOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createScatterOptions(options?: PlotScatterOptions, chartOptions?: ChartOptions, series?: SeriesScatterOptions[]): Highcharts.Options;
export declare function createScatterOptions(langData: LangData, options?: PlotScatterOptions, chartOptions?: ChartOptions, series?: SeriesScatterOptions[]): Highcharts.Options;

@@ -6,3 +6,3 @@ "use strict";

var _chart_1 = require("../_chart");
function createScatterOptions(options, chartOptions, series) {
function createScatterOptions(langData, options, chartOptions, series) {
var scatterOptions = {

@@ -43,4 +43,4 @@ colors: [

};
return _chart_1.createHighOptions('scatter', chartOptions, options, scatterOptions);
return _chart_1.createHighOptions('scatter', chartOptions, langData, options, scatterOptions);
}
exports.createScatterOptions = createScatterOptions;

@@ -51,9 +51,16 @@ "use strict";

var _chart_1 = require("../_chart");
var config_provider_1 = require("../config-provider");
__exportStar(require("./options"), exports);
function SplineChart(props) {
var options = props.options, afterRendered = props.afterRendered, chartOptions = props.chartOptions, loading = props.loading, series = props.series, chartRef = props.chartRef, restProps = __rest(props, ["options", "afterRendered", "chartOptions", "loading", "series", "chartRef"]);
var splineOptions = react_1.useMemo(function () { return options_1.createSplineOptions(options, chartOptions, series); }, [options, chartOptions, series]);
var ref = _chart_1.useHighOptions(splineOptions, { chartRef: chartRef, callback: afterRendered, loading: loading });
var langData = config_provider_1.useConfig().langData;
var splineOptions = react_1.useMemo(function () { return options_1.createSplineOptions(langData, options, chartOptions, series); }, [langData, options, chartOptions, series]);
var ref = _chart_1.useHighOptions(splineOptions, {
loading: loading,
chartRef: chartRef,
langData: langData,
callback: afterRendered
})[0];
return react_1.default.createElement("div", __assign({ ref: ref }, restProps));
}
exports.SplineChart = SplineChart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _chart_1 = require("../_chart");
var options_1 = require("./options");

@@ -65,5 +66,5 @@ describe('Spline Chart', function () {

];
var highOptions = options_1.createSplineOptions({}, chartOptions, series);
var highOptions = options_1.createSplineOptions(_chart_1.cnData, {}, chartOptions, series);
expect(highOptions).toMatchSnapshot();
});
});

@@ -1,2 +0,2 @@

import { PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
import { LangData, PlotOptions, ChartOptions, SeriesOptions } from '../_chart';
export interface PlotSplineOptions extends PlotOptions {

@@ -7,2 +7,2 @@ }

}
export declare function createSplineOptions(options?: PlotSplineOptions, chartOptions?: ChartOptions, series?: SeriesSplineOptions[]): Highcharts.Options;
export declare function createSplineOptions(langData: LangData, options?: PlotSplineOptions, chartOptions?: ChartOptions, series?: SeriesSplineOptions[]): Highcharts.Options;

@@ -5,3 +5,3 @@ "use strict";

var _chart_1 = require("../_chart");
function createSplineOptions(options, chartOptions, series) {
function createSplineOptions(langData, options, chartOptions, series) {
var splineOptions = {

@@ -17,4 +17,4 @@ plotOptions: {

};
return _chart_1.createHighOptions('spline', chartOptions, options, splineOptions);
return _chart_1.createHighOptions('spline', chartOptions, langData, options, splineOptions);
}
exports.createSplineOptions = createSplineOptions;
{
"name": "react-icecream-charts",
"version": "0.6.2",
"version": "0.7.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "esm/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc