Merge remote-tracking branch 'origin/iipbs/common/main' into iipbs/sn/ii
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
} from "./lib/chart";
|
} from "./lib/chart";
|
||||||
import type { ContentType } from "recharts/types/component/DefaultLegendContent";
|
import type { ContentType } from "recharts/types/component/DefaultLegendContent";
|
||||||
import type { set } from "date-fns";
|
import type { set } from "date-fns";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
// 툴크 커스텀 css
|
// 툴크 커스텀 css
|
||||||
/** 차트 기본 스타일 */
|
/** 차트 기본 스타일 */
|
||||||
@@ -126,6 +127,37 @@ export default function LineBarchart({
|
|||||||
monthTicks = getTicks(chartData);
|
monthTicks = getTicks(chartData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CustomAxisText : React.FC<{ viewBox: any, fieldText: string, position:string }> = ({ viewBox, fieldText, position }) => {
|
||||||
|
const { x, y, width, height } = viewBox; // 축 영역
|
||||||
|
const padding = 5; // 차트 바깥으로 띄우기
|
||||||
|
|
||||||
|
if('left' == position) {
|
||||||
|
return (
|
||||||
|
<text
|
||||||
|
x={x - padding} // 맨 좌측 바깥
|
||||||
|
y={y + height / 2} // 수직 중앙
|
||||||
|
textAnchor="middle"
|
||||||
|
transform={`rotate(-90, ${x - padding}, ${y + height / 2})`}
|
||||||
|
className="text-[12px] font-bold"
|
||||||
|
>
|
||||||
|
{fieldText}
|
||||||
|
</text>
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
return (
|
||||||
|
<text
|
||||||
|
x={x + height / 2 } // 맨 좌측 바깥
|
||||||
|
y={y - width + padding } // 수직 중앙
|
||||||
|
textAnchor="middle"
|
||||||
|
transform={`rotate(90, ${x}, ${y})`}
|
||||||
|
className="text-[12px] font-bold"
|
||||||
|
>
|
||||||
|
{fieldText}
|
||||||
|
</text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={chartClassName}>
|
<div className={chartClassName}>
|
||||||
{chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? (
|
{chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? (
|
||||||
@@ -151,9 +183,11 @@ export default function LineBarchart({
|
|||||||
yAxisId="left"
|
yAxisId="left"
|
||||||
className="text-[12px] font-bold"
|
className="text-[12px] font-bold"
|
||||||
tickCount={6}
|
tickCount={6}
|
||||||
|
tickFormatter={(value) =>
|
||||||
|
typeof value === "number" ? value.toLocaleString() : value
|
||||||
|
}
|
||||||
orientation="left"
|
orientation="left"
|
||||||
domain={[0, Math.ceil(lineMaxValue * 1)]}
|
label={(props) => <CustomAxisText {...props} fieldText={yFieldText} position="left" />}
|
||||||
label={{ value: yFieldText, angle: -90, position: 'insideLeft', offset: -8 }}
|
|
||||||
/>}
|
/>}
|
||||||
{/* 오른쪽 Y축: barVal */}
|
{/* 오른쪽 Y축: barVal */}
|
||||||
{yFieldText2 && <YAxis
|
{yFieldText2 && <YAxis
|
||||||
@@ -161,8 +195,10 @@ export default function LineBarchart({
|
|||||||
className="text-[12px] font-bold"
|
className="text-[12px] font-bold"
|
||||||
tickCount={6}
|
tickCount={6}
|
||||||
orientation="right"
|
orientation="right"
|
||||||
domain={[0, Math.ceil(barMaxValue * 1)]}
|
tickFormatter={(value) =>
|
||||||
label={{ value: yFieldText2, angle: -90, position: 'insideRight' }}
|
typeof value === "number" ? value.toLocaleString() : value
|
||||||
|
}
|
||||||
|
label={(props) => <CustomAxisText {...props} fieldText={yFieldText} position="right" />}
|
||||||
reversed={true}
|
reversed={true}
|
||||||
/>}
|
/>}
|
||||||
<Tooltip content={<CustomTooltip active={undefined} payload={undefined} label={undefined} />} />
|
<Tooltip content={<CustomTooltip active={undefined} payload={undefined} label={undefined} />} />
|
||||||
|
|||||||
@@ -129,6 +129,37 @@ const CustomLegend = (props: LegendProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CustomAxisText : React.FC<{ viewBox: any, fieldText: string, position:string }> = ({ viewBox, fieldText, position }) => {
|
||||||
|
const { x, y, width, height } = viewBox; // 축 영역
|
||||||
|
const padding = 5; // 차트 바깥으로 띄우기
|
||||||
|
|
||||||
|
if('left' == position) {
|
||||||
|
return (
|
||||||
|
<text
|
||||||
|
x={x - padding} // 맨 좌측 바깥
|
||||||
|
y={y + height / 2} // 수직 중앙
|
||||||
|
textAnchor="middle"
|
||||||
|
transform={`rotate(-90, ${x - padding}, ${y + height / 2})`}
|
||||||
|
className="text-[12px] font-bold"
|
||||||
|
>
|
||||||
|
{fieldText}
|
||||||
|
</text>
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
return (
|
||||||
|
<text
|
||||||
|
x={x + height / 2 } // 맨 좌측 바깥
|
||||||
|
y={y - width + padding } // 수직 중앙
|
||||||
|
textAnchor="middle"
|
||||||
|
transform={`rotate(90, ${x}, ${y})`}
|
||||||
|
className="text-[12px] font-bold"
|
||||||
|
>
|
||||||
|
{fieldText}
|
||||||
|
</text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type DataType = {label: string; val: string};
|
type DataType = {label: string; val: string};
|
||||||
|
|
||||||
type ChartDataType = {
|
type ChartDataType = {
|
||||||
@@ -220,7 +251,10 @@ export default function Linechart({
|
|||||||
yAxisId="left"
|
yAxisId="left"
|
||||||
className="text-[12px] font-bold"
|
className="text-[12px] font-bold"
|
||||||
orientation="left"
|
orientation="left"
|
||||||
label={{ value: yFieldText, className:"text-[12px] font-bold", angle: -90, position: 'insideLeft' }} />
|
tickFormatter={(value) =>
|
||||||
|
typeof value === "number" ? value.toLocaleString() : value
|
||||||
|
}
|
||||||
|
label={(props) => <CustomAxisText {...props} fieldText={yFieldText} position="left" />}/>
|
||||||
<Tooltip content={<CustomTooltip />} />
|
<Tooltip content={<CustomTooltip />} />
|
||||||
{showLegend && <Legend content={CustomLegend as ContentType}/>}
|
{showLegend && <Legend content={CustomLegend as ContentType}/>}
|
||||||
{Object.keys(chartData).map((key) => {
|
{Object.keys(chartData).map((key) => {
|
||||||
|
|||||||
@@ -597,40 +597,63 @@ GisOlLayer.prototype = {
|
|||||||
const tileSize = 256; // 기본 타일 크기
|
const tileSize = 256; // 기본 타일 크기
|
||||||
return Math.ceil(Math.log2(maxResolution / (cameraHeight / tileSize)));
|
return Math.ceil(Math.log2(maxResolution / (cameraHeight / tileSize)));
|
||||||
},
|
},
|
||||||
ensureSearchLayer: function () {
|
ensureSearchLayer: function (option) {
|
||||||
let layer = this.searchLayer;
|
let layer = this.searchLayer;
|
||||||
|
|
||||||
if (!layer) {
|
if (!layer) {
|
||||||
layer = new VectorLayer({
|
let source;
|
||||||
source: new VectorSource(),
|
|
||||||
|
try {
|
||||||
|
if (option.cmncNm == 'bbox') {
|
||||||
|
source = this.getVectorSourceBbox(option);
|
||||||
|
} else {
|
||||||
|
source = this.getVectorSourceAll(option);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(option);
|
||||||
|
}
|
||||||
|
|
||||||
|
layer = new VectorImageLayer({
|
||||||
|
...option,
|
||||||
|
id: 'search-layer',
|
||||||
|
source: source,
|
||||||
zIndex: 9999
|
zIndex: 9999
|
||||||
});
|
});
|
||||||
|
layer.setStyle(this.gisStyle.getLayerStyleFunction(layer, option));
|
||||||
|
|
||||||
let map = GisApp.Module.core.map;
|
let map = GisApp.Module.core.map;
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
this.searchLayer = layer;
|
||||||
}
|
}
|
||||||
return layer;
|
return layer;
|
||||||
},
|
},
|
||||||
clearSearchLayer: function () {
|
clearSearchLayer: function (option) {
|
||||||
const layer = this.ensureSearchLayer();
|
const layer = this.ensureSearchLayer(option);
|
||||||
layer.getSource().clear(true);
|
layer.getSource().clear(true);
|
||||||
|
|
||||||
|
if (this.searchLayer) {
|
||||||
|
GisApp.Module.core.map.removeLayer(this.searchLayer);
|
||||||
|
this.searchLayer = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
showSearchResultsFromGeoJSON: function (lyrTyNm, featureId) {
|
showSearchResultsFromGeoJSON: function (lyrTyNm, featureId) {
|
||||||
const layer = this.ensureSearchLayer();
|
|
||||||
|
|
||||||
// 이전 검색결과는 깨끗이
|
|
||||||
const prev = layer.getSource();
|
|
||||||
if (prev) prev.clear(true);
|
|
||||||
|
|
||||||
//레이어 타입 설정(point, line 등. 이걸 style에서 사용)
|
//레이어 타입 설정(point, line 등. 이걸 style에서 사용)
|
||||||
const layerCode = GisApp.layerCode;
|
const layerCode = GisApp.layerCode;
|
||||||
const matched = Object.values(layerCode).find(obj => obj.lyrTyNm === lyrTyNm);
|
const matched = Object.values(layerCode).find(obj => obj.lyrTyNm === lyrTyNm);
|
||||||
|
// 이전 검색 레이어 완전히 제거
|
||||||
|
this.clearSearchLayer(matched);
|
||||||
|
// 새로운 검색 레이어 생성
|
||||||
|
const layer = this.ensureSearchLayer(matched);
|
||||||
layer.set("gobjTy", matched.gobjTy);
|
layer.set("gobjTy", matched.gobjTy);
|
||||||
|
|
||||||
// 새 소스 만들기
|
// 새 소스 만들기
|
||||||
const source = this.getFeatureSourceFromGeoserver(lyrTyNm, featureId);
|
const source = this.getFeatureSourceFromGeoserver(lyrTyNm, featureId, matched);
|
||||||
|
|
||||||
// 1) 로드 완료시 extent 맞추기
|
// 1) 로드 완료시 extent 맞추기
|
||||||
const onLoadEnd = () => {
|
const onLoadEnd = () => {
|
||||||
|
if (Object.keys(source.nullGeometryFeatures_).length > 0) alert('해당 시설의 위치 정보가 없습니다.');
|
||||||
|
|
||||||
const feats = source.getFeatures();
|
const feats = source.getFeatures();
|
||||||
if (feats && feats.length > 0) {
|
if (feats && feats.length > 0) {
|
||||||
const select = GisApp.Module.select;
|
const select = GisApp.Module.select;
|
||||||
@@ -665,12 +688,13 @@ GisOlLayer.prototype = {
|
|||||||
* @param {*} featureId
|
* @param {*} featureId
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getFeatureSourceFromGeoserver: function (lyrTyNm, featureId) {
|
getFeatureSourceFromGeoserver: function (lyrTyNm, featureId, option) {
|
||||||
|
|
||||||
const typeName = this.storageNm + lyrTyNm;
|
const typeName = this.storageNm + lyrTyNm;
|
||||||
const srsName = GisApp.TO_PROJ;
|
const srsName = GisApp.TO_PROJ;
|
||||||
const baseUrl = GisApp.GEOSERVER_URL;
|
const baseUrl = GisApp.GEOSERVER_URL;
|
||||||
const source = new VectorSource({
|
const source = new VectorSource({
|
||||||
|
...option,
|
||||||
format: new GeoJSON(),
|
format: new GeoJSON(),
|
||||||
url: () => {
|
url: () => {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
@@ -695,13 +719,14 @@ GisOlLayer.prototype = {
|
|||||||
* @param {Array|string} featureIds 피처 ID 배열 또는 단일 ID
|
* @param {Array|string} featureIds 피처 ID 배열 또는 단일 ID
|
||||||
*/
|
*/
|
||||||
showMultipleSearchResultsFromGeoJSON: function (lyrTyNm, featureIds) {
|
showMultipleSearchResultsFromGeoJSON: function (lyrTyNm, featureIds) {
|
||||||
const layer = this.ensureSearchLayer();
|
|
||||||
|
|
||||||
const prev = layer.getSource();
|
|
||||||
if (prev) prev.clear(true);
|
|
||||||
|
|
||||||
const layerCode = GisApp.layerCode;
|
const layerCode = GisApp.layerCode;
|
||||||
const matched = Object.values(layerCode).find(obj => obj.lyrTyNm === lyrTyNm);
|
const matched = Object.values(layerCode).find(obj => obj.lyrTyNm === lyrTyNm);
|
||||||
|
|
||||||
|
// 이전 검색 레이어 완전히 제거
|
||||||
|
this.clearSearchLayer(matched);
|
||||||
|
// 새로운 검색 레이어 생성
|
||||||
|
const layer = this.ensureSearchLayer(matched);
|
||||||
layer.set("gobjTy", matched.gobjTy);
|
layer.set("gobjTy", matched.gobjTy);
|
||||||
|
|
||||||
const source = this.getMultiFeatureSourceFromGeoserver(lyrTyNm, featureIds);
|
const source = this.getMultiFeatureSourceFromGeoserver(lyrTyNm, featureIds);
|
||||||
|
|||||||
@@ -284,6 +284,7 @@ GisOlSelect.prototype = {
|
|||||||
selectedFeatures.forEach(feature => {
|
selectedFeatures.forEach(feature => {
|
||||||
selectedFeatures.remove(feature);
|
selectedFeatures.remove(feature);
|
||||||
});
|
});
|
||||||
|
selectedFeatures.clear();
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* SELECT 이벤트 활성화
|
* SELECT 이벤트 활성화
|
||||||
|
|||||||
Reference in New Issue
Block a user