@easyv/charts
Advanced tools
Comparing version 1.0.25 to 1.0.26
@@ -27,4 +27,3 @@ "use strict"; | ||
var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) { | ||
var id = _ref.id, | ||
_ref$config = _ref.config, | ||
var _ref$config = _ref.config, | ||
axesConfig = _ref$config.axes, | ||
@@ -37,5 +36,3 @@ background = _ref$config.background, | ||
_ref$config$chart$mar = _ref$config$chart.margin, | ||
marginRight = _ref$config$chart$mar.marginRight, | ||
marginLeft = _ref$config$chart$mar.marginLeft, | ||
marginBottom = _ref$config$chart$mar.marginBottom, | ||
marginTop = _ref$config$chart$mar.marginTop, | ||
@@ -60,2 +57,9 @@ animation = _ref$config$chart.animation, | ||
var context = (0, _react.useContext)(_context.chartContext); | ||
var _useContext = (0, _react.useContext)(_context.chartContext), | ||
chartWidth = _useContext.width, | ||
chartHeight = _useContext.height, | ||
triggerOnRelative = _useContext.triggerOnRelative, | ||
onClickSvg = _useContext.onClickSvg; | ||
var svg = /*#__PURE__*/(0, _react.createRef)(); | ||
@@ -98,12 +102,11 @@ var axes = (0, _hooks.useAxes)({ | ||
x: position | ||
}; // const onItemClick = useCallback( | ||
// (e) => { | ||
// e.stopPropagation(); | ||
// const { data } = e.currentTarget.dataset; | ||
// const _data = JSON.parse(data); | ||
// triggerOnRelative(_data); | ||
// }, | ||
// [triggerOnRelative] | ||
// ); | ||
}; | ||
var onItemClick = (0, _react.useCallback)(function (e) { | ||
e.stopPropagation(); | ||
var data = e.currentTarget.dataset.data; | ||
var _data = JSON.parse(data); | ||
triggerOnRelative(_data); | ||
}, [triggerOnRelative]); | ||
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer, { | ||
@@ -117,3 +120,3 @@ width: width, | ||
ref: svg, | ||
onClick: context.onClickSvg | ||
onClick: onClickSvg | ||
}, background && /*#__PURE__*/_react["default"].createElement(_.Background, { | ||
@@ -137,3 +140,4 @@ length: isVertical ? chartWidth : chartHeight, | ||
xAxis: axisX, | ||
yAxis: yAxis | ||
yAxis: yAxis, | ||
onRelativeOfClick: onItemClick | ||
})); | ||
@@ -149,3 +153,4 @@ }), series.map(function (_ref3, index) { | ||
xAxis: axisX, | ||
yAxis: yAxis | ||
yAxis: yAxis, | ||
onRelativeOfClick: onItemClick | ||
})); | ||
@@ -152,0 +157,0 @@ })), /*#__PURE__*/_react["default"].createElement(_.Legend, { |
@@ -85,3 +85,4 @@ "use strict"; | ||
var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) { | ||
var _ref3$config = _ref3.config, | ||
var onRelativeOfClick = _ref3.onRelativeOfClick, | ||
_ref3$config = _ref3.config, | ||
_ref3$config$pattern = _ref3$config.pattern, | ||
@@ -108,6 +109,2 @@ pattern = _ref3$config$pattern === void 0 ? {} : _ref3$config$pattern, | ||
if (!data.length) return null; | ||
var _useContext = (0, _react.useContext)(_context.chartContext), | ||
onRelative = _useContext.onRelative; | ||
var bandwidth = (0, _utils.getBandwidth)(step, paddingOuter); | ||
@@ -156,3 +153,3 @@ | ||
}, attr, { | ||
onClick: onRelative, | ||
onClick: onRelativeOfClick, | ||
"data-data": JSON.stringify(data) | ||
@@ -159,0 +156,0 @@ }), /*#__PURE__*/_react["default"].createElement("div", { |
@@ -100,3 +100,3 @@ "use strict"; | ||
data: data | ||
}, props)) : /*#__PURE__*/_react["default"].createElement(_.AxisChart, (0, _extends2["default"])({ | ||
}, props)) : /*#__PURE__*/_react["default"].createElement(_.CartesianChart, (0, _extends2["default"])({ | ||
id: id, | ||
@@ -103,0 +103,0 @@ config: config, |
@@ -122,6 +122,6 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "AxisChart", { | ||
Object.defineProperty(exports, "CartesianChart", { | ||
enumerable: true, | ||
get: function get() { | ||
return _AxisChart["default"]; | ||
return _CartesianChart["default"]; | ||
} | ||
@@ -181,3 +181,3 @@ }); | ||
var _AxisChart = _interopRequireDefault(require("./AxisChart")); | ||
var _CartesianChart = _interopRequireDefault(require("./CartesianChart")); | ||
@@ -184,0 +184,0 @@ var _PieChart = _interopRequireDefault(require("./PieChart")); |
@@ -41,3 +41,4 @@ "use strict"; | ||
direction = _ref$xAxis.direction, | ||
yScaler = _ref.yAxis.scaler; | ||
yScaler = _ref.yAxis.scaler, | ||
onRelativeOfClick = _ref.onRelativeOfClick; | ||
var showIcon = icon && icon.show; | ||
@@ -49,4 +50,3 @@ var showLabel = label && label.show; | ||
width = _useContext.width, | ||
height = _useContext.height, | ||
onRelative = _useContext.onRelative; | ||
height = _useContext.height; | ||
@@ -106,3 +106,3 @@ var bandwidth = (0, _utils.getBandwidth)(step, paddingOuter); | ||
key: i, | ||
onClick: onRelative, | ||
onClick: onRelativeOfClick, | ||
"data-data": JSON.stringify(data) | ||
@@ -109,0 +109,0 @@ }, showIcon && /*#__PURE__*/React.createElement(Icon, { |
{ | ||
"name": "@easyv/charts", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -50,2 +50,3 @@ import React, { memo, useContext } from 'react'; | ||
({ | ||
onRelativeOfClick, | ||
config: { | ||
@@ -65,3 +66,2 @@ pattern = {}, | ||
if (!data.length) return null; | ||
const { onRelative } = useContext(chartContext); | ||
const bandwidth = getBandwidth(step, paddingOuter); | ||
@@ -105,3 +105,3 @@ const { seriesStep, seriesWidth } = getBandSeriesStepAndWidth({ | ||
{...attr} | ||
onClick={onRelative} | ||
onClick={onRelativeOfClick} | ||
data-data={JSON.stringify(data)} | ||
@@ -108,0 +108,0 @@ > |
import React, { memo, useMemo, createRef, useCallback } from 'react'; | ||
import { chartContext } from '../context'; | ||
import { PieChart, AxisChart } from '.'; | ||
import { PieChart, CartesianChart } from '.'; | ||
@@ -90,3 +90,3 @@ const getCallbackData = (callbacks, data) => { | ||
) : ( | ||
<AxisChart id={id} config={config} data={data} {...props} /> | ||
<CartesianChart id={id} config={config} data={data} {...props} /> | ||
)} | ||
@@ -93,0 +93,0 @@ </chartContext.Provider> |
@@ -20,3 +20,3 @@ import AnimateData from './AnimateData'; | ||
import Carousel from './Carousel'; | ||
import AxisChart from './AxisChart'; | ||
import CartesianChart from './CartesianChart'; | ||
import PieChart from './PieChart'; | ||
@@ -47,5 +47,5 @@ import Chart from './Chart'; | ||
Carousel, | ||
AxisChart, | ||
CartesianChart, | ||
PieChart, | ||
Chart, | ||
}; |
@@ -22,2 +22,3 @@ import { Fragment, memo, useContext } from 'react'; | ||
yAxis: { scaler: yScaler }, | ||
onRelativeOfClick | ||
}) => { | ||
@@ -28,3 +29,3 @@ const showIcon = icon && icon.show; | ||
if (!(data.length && (showIcon || showLabel))) return null; | ||
const { width, height, onRelative } = useContext(chartContext); | ||
const { width, height } = useContext(chartContext); | ||
const bandwidth = getBandwidth(step, paddingOuter); | ||
@@ -81,3 +82,3 @@ const { seriesStep, seriesWidth } = getBandSeriesStepAndWidth({ | ||
return ( | ||
<g key={i} onClick={onRelative} data-data={JSON.stringify(data)}> | ||
<g key={i} onClick={onRelativeOfClick} data-data={JSON.stringify(data)}> | ||
{showIcon && <Icon cx={attr.x} cy={attr.y} config={icon} />} | ||
@@ -84,0 +85,0 @@ {showLabel && <Label value={y} config={label} {...attr} />} |
294452
77
8770