32#include <com/sun/star/chart2/Symbol.hpp>
33#include <com/sun/star/chart/DataLabelPlacement.hpp>
34#include <com/sun/star/chart/MissingValueTreatment.hpp>
37#include <osl/diagnose.h>
39#include <officecfg/Office/Compatibility.hxx>
49 , sal_Int32 nDimensionCount
51 , std::unique_ptr<PlottingPositionHelper> pPlottingPositionHelper
53 : VSeriesPlotter( xChartTypeModel, nDimensionCount, true )
54 , m_pMainPosHelper(
std::move(pPlottingPositionHelper))
59 assert(nDimensionCount == 2);
61 m_pMainPosHelper->AllowShiftXAxisPos(
true);
62 m_pMainPosHelper->AllowShiftZAxisPos(
true);
64 PlotterBase::m_pPosHelper = m_pMainPosHelper.get();
65 VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get();
72double NetChart::getMaximumX()
74 double fMax = VSeriesPlotter::getMaximumX() + 1.0;
78bool NetChart::isExpandIfValuesCloseToBorder( sal_Int32 )
83bool NetChart::isSeparateStackingForDifferentSigns( sal_Int32 )
92 return LegendSymbolStyle::Box;
93 return LegendSymbolStyle::Line;
101 if( pSymbolProperties )
103 aRet <<= *pSymbolProperties;
109drawing::Direction3D NetChart::getPreferredDiagramAspectRatio()
const
111 return drawing::Direction3D(1,1,1);
115 ,
const std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly
121 std::vector<std::vector<css::drawing::Position3D>> aPoly;
123 bool bIsClipped =
false;
124 if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
127 double fFirstY = pSeries->
getYValue( 0 );
128 double fLastY = pSeries->
getYValue( VSeriesPlotter::getPointCount() - 1 );
130 || (std::isfinite( fFirstY ) && std::isfinite( fLastY )) )
134 std::vector<std::vector<css::drawing::Position3D>> aTmpPoly(*pSeriesPoly);
135 drawing::Position3D aLast(aScaledLogicClipDoubleRect.
getMaxX(),aTmpPoly[0][0].PositionY,aTmpPoly[0][0].PositionZ);
138 Clipping::clipPolygonAtRectangle( aTmpPoly, aScaledLogicClipDoubleRect, aPoly );
147 if(!ShapeFactory::hasPolygonAnyLines(aPoly))
156 xShape = ShapeFactory::createLine2D( xSeriesGroupShape_Shapes, aPoly );
157 PropertyMapper::setMappedProperties( *xShape
159 , PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
167 ,
const std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly
168 , std::vector<std::vector<css::drawing::Position3D>>
const * pPreviousSeriesPoly
176 std::vector<std::vector<css::drawing::Position3D>> aPoly( *pSeriesPoly );
178 if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
180 if( pPreviousSeriesPoly )
183 else if(!pPreviousSeriesPoly)
190 if(fMaxX<pPosHelper->getLogicMinX() || fMinX>pPosHelper->
getLogicMaxX())
208 ShapeFactory::closePolygon(aPoly);
212 std::vector<std::vector<css::drawing::Position3D>> aClippedPoly;
214 ShapeFactory::closePolygon(aClippedPoly);
215 aPoly = aClippedPoly;
218 if(!ShapeFactory::hasPolygonAnyLines(aPoly))
226 xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
228 PropertyMapper::setMappedProperties( *xShape
230 , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
236void NetChart::impl_createSeriesShapes()
241 for(
auto const& rZSlot : m_aZSlots )
243 for(
auto const& rXSlot : rZSlot )
245 std::map< sal_Int32, std::vector<std::vector<css::drawing::Position3D>>* > aPreviousSeriesPolyMap;
246 std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly =
nullptr;
249 for( std::unique_ptr<VDataSeries>
const & pSeries : rXSlot.m_aSeriesVector )
251 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
252 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
254 pSeriesPoly = &pSeries->m_aPolyPolygonShape3D;
257 if (!impl_createArea(pSeries.get(), pSeriesPoly,
258 aPreviousSeriesPolyMap[nAttachedAxisIndex], m_pPosHelper))
263 if (!impl_createLine(pSeries.get(), pSeriesPoly, m_pPosHelper))
266 aPreviousSeriesPolyMap[nAttachedAxisIndex] = pSeriesPoly;
275void lcl_reorderSeries( std::vector< std::vector< VDataSeriesGroup > >& rZSlots )
277 std::vector< std::vector< VDataSeriesGroup > > aRet;
278 aRet.reserve( rZSlots.size() );
280 std::vector< std::vector< VDataSeriesGroup > >::reverse_iterator aZIt( rZSlots.rbegin() );
281 std::vector< std::vector< VDataSeriesGroup > >::reverse_iterator aZEnd( rZSlots.rend() );
282 for( ; aZIt != aZEnd; ++aZIt )
284 std::vector< VDataSeriesGroup > aXSlot;
286 std::vector< VDataSeriesGroup >::reverse_iterator aXIt( aZIt->rbegin() );
287 std::vector< VDataSeriesGroup >::reverse_iterator aXEnd( aZIt->rend() );
288 for( ; aXIt != aXEnd; ++aXIt )
289 aXSlot.push_back(std::move(*aXIt));
291 aRet.push_back(std::move(aXSlot));
294 rZSlots = std::move(aRet);
300 FormerPoint(
double fX,
double fY,
double fZ )
304 :
m_fX(
std::numeric_limits<double>::quiet_NaN())
305 ,
m_fY(
std::numeric_limits<double>::quiet_NaN())
306 ,
m_fZ(
std::numeric_limits<double>::quiet_NaN())
318void NetChart::createShapes()
320 if( m_aZSlots.empty() )
324 if (officecfg::Office::Compatibility::View::ReverseSeriesOrderAreaAndNetChart::get() && m_bArea)
325 lcl_reorderSeries( m_aZSlots );
327 OSL_ENSURE(m_xLogicTarget.is()&&m_xFinalTarget.is(),
"NetChart is not proper initialized");
328 if(!(m_xLogicTarget.is()&&m_xFinalTarget.is()))
336 m_xSeriesTarget = createGroupShape( m_xLogicTarget );
337 m_xTextTarget = ShapeFactory::createGroup2D( m_xFinalTarget );
342 double fLogicZ = 1.0;
344 sal_Int32
const nStartIndex = 0;
345 sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
350 std::map< VDataSeries*, FormerPoint > aSeriesFormerPointMap;
351 m_bPointsWereSkipped =
false;
353 bool bDateCategory = (m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis());
358 std::map< sal_Int32, double > aLogicYSumMap;
359 for(
auto const& rZSlot : m_aZSlots )
362 for(
auto const& rXSlot : rZSlot )
364 for( std::unique_ptr<VDataSeries>
const & pSeries : rXSlot.m_aSeriesVector )
370 pSeries->doSortByXValues();
372 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
373 aLogicYSumMap.insert({nAttachedAxisIndex, 0.0});
375 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
377 double fAdd = pSeries->getYValue(
nIndex );
378 if( !std::isnan(fAdd) && !std::isinf(fAdd) )
379 aLogicYSumMap[nAttachedAxisIndex] += fabs( fAdd );
384 for(
auto const& rZSlot : m_aZSlots )
388 for(
auto const& rXSlot : rZSlot )
390 std::map< sal_Int32, double > aLogicYForNextSeriesMap;
392 for( std::unique_ptr<VDataSeries>
const & pSeries : rXSlot.m_aSeriesVector )
400 if( m_bArea && (rXSlot.m_aSeriesVector.size() == 1) && (
nIndex >= pSeries->getTotalPointCount()) )
405 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
406 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
408 pSeries->m_fLogicZPos = fLogicZ;
411 double fLogicX = pSeries->getXValue(
nIndex);
413 fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
414 double fLogicY = pSeries->getYValue(
nIndex);
416 if( m_bArea && ( std::isnan(fLogicY) || std::isinf(fLogicY) ) )
418 if( pSeries->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP )
420 if( rXSlot.m_aSeriesVector.size() == 1 || pSeries == rXSlot.m_aSeriesVector.front() )
422 fLogicY = m_pPosHelper->getLogicMinY();
423 if (!m_pPosHelper->isMathematicalOrientationY())
424 fLogicY = m_pPosHelper->getLogicMaxY();
431 if (m_pPosHelper->isPercentY() && aLogicYSumMap[nAttachedAxisIndex] != 0.0)
433 fLogicY = fabs( fLogicY )/aLogicYSumMap[nAttachedAxisIndex];
436 if( std::isnan(fLogicX) || std::isinf(fLogicX)
437 || std::isnan(fLogicY) || std::isinf(fLogicY)
438 || std::isnan(fLogicZ) || std::isinf(fLogicZ) )
440 if( pSeries->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP )
442 std::vector<std::vector<css::drawing::Position3D>>& rPolygon = pSeries->m_aPolyPolygonShape3D;
443 sal_Int32& rIndex = pSeries->m_nPolygonIndex;
446 if( !rPolygon[ rIndex ].empty() )
453 aLogicYForNextSeriesMap.try_emplace(nAttachedAxisIndex, 0.0);
455 double fLogicValueForLabeDisplay = fLogicY;
457 fLogicY += aLogicYForNextSeriesMap[nAttachedAxisIndex];
458 aLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
460 bool bIsVisible = m_pPosHelper->isLogicVisible(fLogicX, fLogicY, fLogicZ);
465 double& rfMinX = pSeries->m_fLogicMinX;
466 if(!
nIndex||fLogicX<rfMinX)
468 double& rfMaxX = pSeries->m_fLogicMaxX;
469 if(!
nIndex||fLogicX>rfMaxX)
473 drawing::Position3D aUnscaledLogicPosition( fLogicX, fLogicY, fLogicZ );
474 drawing::Position3D aScaledLogicPosition(aUnscaledLogicPosition);
475 m_pPosHelper->doLogicScaling(aScaledLogicPosition);
478 drawing::Position3D aScenePosition(
479 m_pPosHelper->transformLogicToScene(fLogicX, fLogicY, fLogicZ,
false));
482 FormerPoint aFormerPoint( aSeriesFormerPointMap[pSeries.get()] );
483 m_pPosHelper->setCoordinateSystemResolution(m_aCoordinateSystemResolution);
484 if( !pSeries->isAttributedDataPoint(
nIndex)
485 && m_pPosHelper->isSameForGivenResolution(
486 aFormerPoint.m_fX, aFormerPoint.m_fY, aFormerPoint.m_fZ
487 , aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ ) )
489 m_bPointsWereSkipped =
true;
492 aSeriesFormerPointMap[pSeries.get()] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ);
496 if( isValidPosition(aScaledLogicPosition) )
498 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aScaledLogicPosition, pSeries->m_nPolygonIndex );
501 if( !bIsVisible && m_bArea )
503 drawing::Position3D aClippedPos(aScaledLogicPosition);
504 m_pPosHelper->clipScaledLogicValues(
nullptr, &aClippedPos.PositionY,
506 if (m_pPosHelper->isLogicVisible(aClippedPos.PositionX,
507 aClippedPos.PositionY,
508 aClippedPos.PositionZ))
510 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aClippedPos, pSeries->m_nPolygonIndex );
511 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aScaledLogicPosition, pSeries->m_nPolygonIndex );
521 Symbol* pSymbolProperties = pSeries->getSymbolProperties(
nIndex );
522 bool bCreateSymbol = pSymbolProperties && (pSymbolProperties->Style != SymbolStyle_NONE);
524 if( !bCreateSymbol && !pSeries->getDataPointLabelIfLabel(
nIndex) )
528 OUString aPointCID = ObjectIdentifier::createPointCID(
529 pSeries->getPointCID_Stub(),
nIndex );
531 createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
535 drawing::Direction3D aSymbolSize(0,0,0);
538 if (pSymbolProperties->Style != SymbolStyle_NONE)
540 aSymbolSize.DirectionX = pSymbolProperties->Size.Width;
541 aSymbolSize.DirectionY = pSymbolProperties->Size.Height;
544 if (pSymbolProperties->Style == SymbolStyle_STANDARD)
546 sal_Int32 nSymbol = pSymbolProperties->StandardSymbol;
547 ShapeFactory::createSymbol2D(
548 xPointGroupShape_Shapes, aScenePosition, aSymbolSize, nSymbol,
549 pSymbolProperties->BorderColor, pSymbolProperties->FillColor);
551 else if (pSymbolProperties->Style == SymbolStyle_GRAPHIC)
553 ShapeFactory::createGraphic2D(xPointGroupShape_Shapes,
554 aScenePosition, aSymbolSize,
555 pSymbolProperties->Graphic);
561 if( pSeries->getDataPointLabelIfLabel(
nIndex) )
564 drawing::Position3D aScenePosition3D( aScenePosition.PositionX
565 , aScenePosition.PositionY
566 , aScenePosition.PositionZ+getTransformedDepth() );
568 sal_Int32 nLabelPlacement = pSeries->getLabelPlacement(
569 nIndex, m_xChartTypeModel, m_pPosHelper->isSwapXAndY());
571 switch(nLabelPlacement)
573 case css::chart::DataLabelPlacement::TOP:
574 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
577 case css::chart::DataLabelPlacement::BOTTOM:
578 aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
581 case css::chart::DataLabelPlacement::LEFT:
582 aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
585 case css::chart::DataLabelPlacement::RIGHT:
586 aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
589 case css::chart::DataLabelPlacement::CENTER:
594 OSL_FAIL(
"this label alignment is not implemented yet");
595 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
600 awt::Point aScreenPosition2D;
601 sal_Int32 nOffset = 100;
602 if( nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE )
606 if( pPolarPosHelper )
610 eAlignment, fLogicX, fLogicY, fLogicZ, nOffset );
621 createDataLabel( m_xTextTarget, *pSeries,
nIndex
622 , fLogicValueForLabeDisplay
623 , aLogicYSumMap[nAttachedAxisIndex], aScreenPosition2D, eAlignment, nOffset );
628 if(!xPointGroupShape_Shapes->getCount())
629 xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shapes);
636 impl_createSeriesShapes();
css::awt::Point transformSceneToScreenPosition(const css::drawing::Position3D &rScenePosition3D) const
double getBaseValueY() const
double getLogicMaxX() const
::basegfx::B2DRectangle getScaledLogicClipDoubleRect() const
void doLogicScaling(double *pX, double *pY, double *pZ) const
virtual css::drawing::Position3D transformScaledLogicToScene(double fX, double fY, double fZ, bool bClip) const
void clipLogicValues(double *pX, double *pY, double *pZ) const
css::awt::Point getLabelScreenPositionAndAlignmentForLogicValues(LabelAlignment &rAlignment, double fLogicValueOnAngleAxis, double fLogicValueOnRadiusAxis, double fLogicZ, sal_Int32 nScreenValueOffsetInRadiusDirection) const
static void setShapeName(const rtl::Reference< SvxShape > &xShape, const OUString &rName)
css::chart2::Symbol * getSymbolProperties(sal_Int32 index) const
const css::uno::Reference< css::beans::XPropertySet > & getPropertiesOfSeries() const
double getYValue(sal_Int32 index) const
sal_Int32 getMissingValueTreatment() const
OOO_DLLPUBLIC_CHARTTOOLS void AddPointToPoly(css::drawing::PolyPolygonShape3D &rPoly, const css::drawing::Position3D &rPos, sal_Int32 nSequenceIndex=0)
PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D.
OOO_DLLPUBLIC_CHARTTOOLS void addPolygon(std::vector< std::vector< css::drawing::Position3D > > &rRet, const std::vector< std::vector< css::drawing::Position3D > > &rAdd)
OOO_DLLPUBLIC_CHARTTOOLS void appendPoly(std::vector< std::vector< css::drawing::Position3D > > &rRet, const std::vector< std::vector< css::drawing::Position3D > > &rAdd)
PolyPolygonShape3D + PolyPolygonShape3D -> PolyPolygonShape3D.
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)