Browse Source

비행 시간 y축 value 수정

pull/2/head
hhjk00 10 months ago
parent
commit
02faa12590
  1. 13
      src/components/statistics/StatisticsSearch.js
  2. 13
      src/containers/statistics/FlightContainer.js

13
src/components/statistics/StatisticsSearch.js

@ -41,8 +41,7 @@ export default function StatisticsSearch({
const chartInit = () => {
const { topData, graphData } = searchData;
const filteredData = data =>
data.filter(i => i && !['nodata', 'NoData'].includes(i));
const filteredData = data => data.filter(i => i && i !== 'NoData');
const graph = filteredData(graphData.map(i => i.value));
const top = filteredData(topData.map(i => i.value));
@ -133,8 +132,8 @@ export default function StatisticsSearch({
ticks: {
callback: function (value, index, values) {
if (searchType.category === 'TIME') {
const dateValue = formatSeconds(value);
return dateValue;
const isLastIndex = index === values.length - 1;
return formatSeconds(value, isLastIndex);
} else if (searchType.category === 'DISTANCE') {
return value + 'm';
}
@ -231,7 +230,7 @@ export default function StatisticsSearch({
]
};
const handlerPlugins = chartData => {
const plugins = chartData => {
return [
{
afterDraw: function (chart) {
@ -418,7 +417,7 @@ export default function StatisticsSearch({
data={totalData}
options={barOptions}
height={400}
plugins={handlerPlugins(totalData)}
plugins={plugins(totalData)}
/>
</div>
</CardBody>
@ -437,7 +436,7 @@ export default function StatisticsSearch({
data={topData}
options={doughnutOptions}
height={275}
plugins={handlerPlugins(topData)}
plugins={plugins(topData)}
/>
</div>
{/* <div className='d-flex justify-content-between mt-3 mb-1'>

13
src/containers/statistics/FlightContainer.js

@ -109,6 +109,7 @@ export default function FlightContainer() {
return stepSize;
};
// 1234.2345 -> 1,234.2
const formatDistance = number => {
if (number === 'noData' || number === 0.0) return '0';
@ -127,6 +128,10 @@ export default function FlightContainer() {
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
};
const formatPart = (value, unit, isLastIndex) => {
return value > 0 || isLastIndex ? `${value}${unit}` : '';
};
// '24:35:12' -> '1일 35분 12초'
const formatTimeString = time => {
if (time === 'noData' || time === '00:00:00') return '0초';
@ -143,17 +148,15 @@ export default function FlightContainer() {
return parts.join(' ');
};
const formatPart = (value, unit) => (value > 0 ? `${value}${unit}` : '');
// 975 -> '16분 15초'
const formatSeconds = time => {
const formatSeconds = (time, isLastIndex) => {
const { days, hours, minutes, seconds } = secondsToDHMS(time);
let parts = [
const parts = [
formatPart(days, '일'),
formatPart(hours, '시간'),
formatPart(minutes, '분'),
formatPart(seconds, '초')
formatPart(seconds, '초', isLastIndex)
];
return parts.join(' ');

Loading…
Cancel
Save