Commit af874e68 authored by 崔佳豪's avatar 崔佳豪

fix(EC_HistoryView): 优化多图表图例显示

parent 7cd47831
...@@ -57,6 +57,7 @@ const GridChart = memo((props) => { ...@@ -57,6 +57,7 @@ const GridChart = memo((props) => {
}; };
const option = optionGenerator(list, cusOption, contrast, contrastOption, smooth, { const option = optionGenerator(list, cusOption, contrast, contrastOption, smooth, {
curveCenter, curveCenter,
nameWithSensor: false,
}); });
return { return {
key, key,
......
...@@ -12,9 +12,9 @@ const axisWidth = 40; ...@@ -12,9 +12,9 @@ const axisWidth = 40;
* @param {any} contrastOption 同期对比周期配置, day|month * @param {any} contrastOption 同期对比周期配置, day|month
* @returns * @returns
*/ */
const nameFormatter = (data, contrast, contrastOption) => { const nameFormatter = (data, contrast, contrastOption, nameWithSensor) => {
const { equipmentName, sensorName, unit, dataModel, dateFrom, dateTo } = data; const { equipmentName, sensorName, unit, dataModel, dateFrom, dateTo } = data;
let name = `${equipmentName}-${sensorName}`; let name = nameWithSensor ? `${equipmentName}-${sensorName}` : equipmentName;
if (contrast) { if (contrast) {
const time = dateFrom.slice(0, contrastOption === 'day' ? 10 : 7).replace(/-/g, ''); const time = dateFrom.slice(0, contrastOption === 'day' ? 10 : 7).replace(/-/g, '');
name = `${name}-${time}`; name = `${name}-${time}`;
...@@ -80,6 +80,7 @@ const minMax = (data) => { ...@@ -80,6 +80,7 @@ const minMax = (data) => {
const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth, config) => { const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth, config) => {
const needUnit = _.get(config, 'needUnit', false); const needUnit = _.get(config, 'needUnit', false);
const curveCenter = _.get(config, 'curveCenter', false); const curveCenter = _.get(config, 'curveCenter', false);
const nameWithSensor = _.get(config, 'nameWithSensor', true);
// 自定义属性 // 自定义属性
const restOption = _.pick(cusOption, ['title', 'legend']); const restOption = _.pick(cusOption, ['title', 'legend']);
...@@ -138,7 +139,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth ...@@ -138,7 +139,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
const series = dataSource.map((item) => { const series = dataSource.map((item) => {
const { sensorName, unit } = item; const { sensorName, unit } = item;
const name = nameFormatter(item, contrast, contrastOption); const name = nameFormatter(item, contrast, contrastOption, nameWithSensor);
const data = dataAccessor(item, contrast, contrastOption); const data = dataAccessor(item, contrast, contrastOption);
const type = 'line'; const type = 'line';
const areaStyle = areaStyleFormatter(item); const areaStyle = areaStyleFormatter(item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment