1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "NetChart.hxx"
21 #include <PlottingPositionHelper.hxx>
22 #include <AbstractShapeFactory.hxx>
23 #include <CommonConverters.hxx>
24 #include <ViewDefines.hxx>
25 #include <ObjectIdentifier.hxx>
26 #include <ChartTypeHelper.hxx>
27 #include <LabelPositionHelper.hxx>
28 #include <Clipping.hxx>
30 #include <PolarLabelPositionHelper.hxx>
31 #include <DateHelper.hxx>
33 #include <com/sun/star/chart2/Symbol.hpp>
34 #include <com/sun/star/chart/DataLabelPlacement.hpp>
35 #include <com/sun/star/chart/MissingValueTreatment.hpp>
37 #include <editeng/unoprnms.hxx>
38 #include <rtl/math.hxx>
40 #include <com/sun/star/drawing/DoubleSequence.hpp>
41 #include <com/sun/star/drawing/NormalsKind.hpp>
42 #include <com/sun/star/lang/XServiceName.hpp>
46 using namespace ::com::sun::star
;
47 using namespace ::rtl::math
;
48 using namespace ::com::sun::star::chart2
;
50 NetChart::NetChart( const uno::Reference
<XChartType
>& xChartTypeModel
51 , sal_Int32 nDimensionCount
53 , PlottingPositionHelper
* pPlottingPositionHelper
55 : VSeriesPlotter( xChartTypeModel
, nDimensionCount
, true )
56 , m_pMainPosHelper(pPlottingPositionHelper
)
59 , m_xSeriesTarget(nullptr)
60 , m_xTextTarget(nullptr)
62 // we only support 2D Net charts
63 assert(nDimensionCount
== 2);
65 m_pMainPosHelper
->AllowShiftXAxisPos(true);
66 m_pMainPosHelper
->AllowShiftZAxisPos(true);
68 PlotterBase::m_pPosHelper
= m_pMainPosHelper
.get();
69 VSeriesPlotter::m_pMainPosHelper
= m_pMainPosHelper
.get();
76 double NetChart::getMaximumX()
78 double fMax
= VSeriesPlotter::getMaximumX() + 1.0;
82 bool NetChart::isExpandIfValuesCloseToBorder( sal_Int32
)
87 bool NetChart::isSeparateStackingForDifferentSigns( sal_Int32
/*nDimensionIndex*/ )
89 // no separate stacking in all types of line/area charts
93 LegendSymbolStyle
NetChart::getLegendSymbolStyle()
96 return LegendSymbolStyle_BOX
;
97 return LegendSymbolStyle_LINE
;
100 uno::Any
NetChart::getExplicitSymbol( const VDataSeries
& rSeries
, sal_Int32 nPointIndex
)
104 Symbol
* pSymbolProperties
= rSeries
.getSymbolProperties( nPointIndex
);
105 if( pSymbolProperties
)
107 aRet
<<= *pSymbolProperties
;
113 drawing::Direction3D
NetChart::getPreferredDiagramAspectRatio() const
115 return drawing::Direction3D(1,1,1);
118 bool NetChart::impl_createLine( VDataSeries
* pSeries
119 , drawing::PolyPolygonShape3D
* pSeriesPoly
120 , PlottingPositionHelper
const * pPosHelper
)
122 //return true if a line was created successfully
123 uno::Reference
< drawing::XShapes
> xSeriesGroupShape_Shapes
= getSeriesGroupShapeBackChild(pSeries
, m_xSeriesTarget
);
125 drawing::PolyPolygonShape3D aPoly
;
127 bool bIsClipped
= false;
128 if( !AbstractShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly
) )
130 // do NOT connect last and first point, if one is NAN, and NAN handling is NAN_AS_GAP
131 double fFirstY
= pSeries
->getYValue( 0 );
132 double fLastY
= pSeries
->getYValue( VSeriesPlotter::getPointCount() - 1 );
133 if( (pSeries
->getMissingValueTreatment() != css::chart::MissingValueTreatment::LEAVE_GAP
)
134 || (::rtl::math::isFinite( fFirstY
) && ::rtl::math::isFinite( fLastY
)) )
136 // connect last point in last polygon with first point in first polygon
137 ::basegfx::B2DRectangle
aScaledLogicClipDoubleRect( pPosHelper
->getScaledLogicClipDoubleRect() );
138 drawing::PolyPolygonShape3D
aTmpPoly(*pSeriesPoly
);
139 drawing::Position3D
aLast(aScaledLogicClipDoubleRect
.getMaxX(),aTmpPoly
.SequenceY
[0][0],aTmpPoly
.SequenceZ
[0][0]);
140 // add connector line to last polygon
141 AddPointToPoly( aTmpPoly
, aLast
, pSeriesPoly
->SequenceX
.getLength() - 1 );
142 Clipping::clipPolygonAtRectangle( aTmpPoly
, aScaledLogicClipDoubleRect
, aPoly
);
148 Clipping::clipPolygonAtRectangle( *pSeriesPoly
, pPosHelper
->getScaledLogicClipDoubleRect(), aPoly
);
151 if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly
))
154 //transformation 3) -> 4)
155 pPosHelper
->transformScaledLogicToScene( aPoly
);
158 uno::Reference
< drawing::XShape
> xShape(nullptr);
160 xShape
= m_pShapeFactory
->createLine2D( xSeriesGroupShape_Shapes
161 , PolyToPointSequence( aPoly
) );
162 setMappedProperties( xShape
163 , pSeries
->getPropertiesOfSeries()
164 , PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
165 //because of this name this line will be used for marking
166 ::chart::AbstractShapeFactory::setShapeName(xShape
, "MarkHandles");
171 bool NetChart::impl_createArea( VDataSeries
* pSeries
172 , drawing::PolyPolygonShape3D
* pSeriesPoly
173 , drawing::PolyPolygonShape3D
const * pPreviousSeriesPoly
174 , PlottingPositionHelper
const * pPosHelper
)
176 //return true if an area was created successfully
178 uno::Reference
< drawing::XShapes
> xSeriesGroupShape_Shapes
= getSeriesGroupShapeBackChild(pSeries
, m_xSeriesTarget
);
179 double zValue
= pSeries
->m_fLogicZPos
;
181 drawing::PolyPolygonShape3D
aPoly( *pSeriesPoly
);
182 //add second part to the polygon (grounding points or previous series points)
183 if( !AbstractShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly
) )
185 if( pPreviousSeriesPoly
)
186 addPolygon( aPoly
, *pPreviousSeriesPoly
);
188 else if(!pPreviousSeriesPoly
)
190 double fMinX
= pSeries
->m_fLogicMinX
;
191 double fMaxX
= pSeries
->m_fLogicMaxX
;
192 double fY
= pPosHelper
->getBaseValueY();//logic grounding
195 if(fMaxX
<pPosHelper
->getLogicMinX() || fMinX
>pPosHelper
->getLogicMaxX())
196 return false;//no visible shape needed
197 pPosHelper
->clipLogicValues( &fMinX
, &fY
, nullptr );
198 pPosHelper
->clipLogicValues( &fMaxX
, nullptr, nullptr );
202 pPosHelper
->doLogicScaling( &fMinX
, &fY
, &zValue
);
203 pPosHelper
->doLogicScaling( &fMaxX
, nullptr, nullptr );
206 AddPointToPoly( aPoly
, drawing::Position3D( fMaxX
,fY
,zValue
) );
207 AddPointToPoly( aPoly
, drawing::Position3D( fMinX
,fY
,zValue
) );
211 appendPoly( aPoly
, *pPreviousSeriesPoly
);
213 AbstractShapeFactory::closePolygon(aPoly
);
217 drawing::PolyPolygonShape3D aClippedPoly
;
218 Clipping::clipPolygonAtRectangle( aPoly
, pPosHelper
->getScaledLogicClipDoubleRect(), aClippedPoly
, false );
219 AbstractShapeFactory::closePolygon(aClippedPoly
); //again necessary after clipping
220 aPoly
= aClippedPoly
;
223 if(!AbstractShapeFactory::hasPolygonAnyLines(aPoly
))
226 //transformation 3) -> 4)
227 pPosHelper
->transformScaledLogicToScene( aPoly
);
230 uno::Reference
< drawing::XShape
>
231 xShape
= m_pShapeFactory
->createArea2D( xSeriesGroupShape_Shapes
233 setMappedProperties( xShape
234 , pSeries
->getPropertiesOfSeries()
235 , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
236 //because of this name this line will be used for marking
237 ::chart::AbstractShapeFactory::setShapeName(xShape
, "MarkHandles");
241 void NetChart::impl_createSeriesShapes()
243 //the polygon shapes for each series need to be created before
245 //iterate through all series again to create the series shapes
246 for( auto const& rZSlot
: m_aZSlots
)
248 for( auto const& rXSlot
: rZSlot
)
250 std::map
< sal_Int32
, drawing::PolyPolygonShape3D
* > aPreviousSeriesPolyMap
;//a PreviousSeriesPoly for each different nAttachedAxisIndex
251 drawing::PolyPolygonShape3D
* pSeriesPoly
= nullptr;
253 //iterate through all series
254 for( VDataSeries
* pSeries
: rXSlot
.m_aSeriesVector
)
256 sal_Int32 nAttachedAxisIndex
= pSeries
->getAttachedAxisIndex();
257 PlottingPositionHelper
* pPosHelper
= &(getPlottingPositionHelper( nAttachedAxisIndex
));
259 pPosHelper
= m_pMainPosHelper
.get();
260 PlotterBase::m_pPosHelper
= pPosHelper
;
262 pSeriesPoly
= &pSeries
->m_aPolyPolygonShape3D
;
265 if( !impl_createArea( pSeries
, pSeriesPoly
, aPreviousSeriesPolyMap
[nAttachedAxisIndex
], pPosHelper
) )
270 if( !impl_createLine( pSeries
, pSeriesPoly
, pPosHelper
) )
273 aPreviousSeriesPolyMap
[nAttachedAxisIndex
] = pSeriesPoly
;
274 }//next series in x slot (next y slot)
282 void lcl_reorderSeries( std::vector
< std::vector
< VDataSeriesGroup
> >& rZSlots
)
284 std::vector
< std::vector
< VDataSeriesGroup
> > aRet
;
285 aRet
.reserve( rZSlots
.size() );
287 std::vector
< std::vector
< VDataSeriesGroup
> >::reverse_iterator
aZIt( rZSlots
.rbegin() );
288 std::vector
< std::vector
< VDataSeriesGroup
> >::reverse_iterator
aZEnd( rZSlots
.rend() );
289 for( ; aZIt
!= aZEnd
; ++aZIt
)
291 std::vector
< VDataSeriesGroup
> aXSlot
;
292 aXSlot
.reserve( aZIt
->size() );
294 std::vector
< VDataSeriesGroup
>::reverse_iterator
aXIt( aZIt
->rbegin() );
295 std::vector
< VDataSeriesGroup
>::reverse_iterator
aXEnd( aZIt
->rend() );
296 for( ; aXIt
!= aXEnd
; ++aXIt
)
297 aXSlot
.push_back(*aXIt
);
299 aRet
.push_back(aXSlot
);
306 }//anonymous namespace
308 //better performance for big data
311 FormerPoint( double fX
, double fY
, double fZ
)
312 : m_fX(fX
), m_fY(fY
), m_fZ(fZ
)
316 ::rtl::math::setNan( &m_fX
);
317 ::rtl::math::setNan( &m_fY
);
318 ::rtl::math::setNan( &m_fZ
);
326 void NetChart::createShapes()
328 if( m_aZSlots
.empty() ) //no series
332 lcl_reorderSeries( m_aZSlots
);
334 OSL_ENSURE(m_pShapeFactory
&&m_xLogicTarget
.is()&&m_xFinalTarget
.is(),"NetChart is not proper initialized");
335 if(!(m_pShapeFactory
&&m_xLogicTarget
.is()&&m_xFinalTarget
.is()))
338 //the text labels should be always on top of the other series shapes
339 //for area chart the error bars should be always on top of the other series shapes
341 //therefore create an own group for the texts and the error bars to move them to front
342 //(because the text group is created after the series group the texts are displayed on top)
343 m_xSeriesTarget
= createGroupShape( m_xLogicTarget
);
344 m_xTextTarget
= m_pShapeFactory
->createGroup2D( m_xFinalTarget
);
346 //check necessary here that different Y axis can not be stacked in the same group? ... hm?
348 //update/create information for current group
349 double fLogicZ
= 1.0;//as defined
351 sal_Int32
const nStartIndex
= 0; // inclusive ;..todo get somehow from x scale
352 sal_Int32 nEndIndex
= VSeriesPlotter::getPointCount();
356 //better performance for big data
357 std::map
< VDataSeries
*, FormerPoint
> aSeriesFormerPointMap
;
358 m_bPointsWereSkipped
= false;
359 sal_Int32 nSkippedPoints
= 0;
360 sal_Int32 nCreatedPoints
= 0;
362 bool bDateCategory
= (m_pExplicitCategoriesProvider
&& m_pExplicitCategoriesProvider
->isDateAxis());
364 //iterate through all x values per indices
365 for( sal_Int32 nIndex
= nStartIndex
; nIndex
< nEndIndex
; nIndex
++ )
367 std::map
< sal_Int32
, double > aLogicYSumMap
;//one for each different nAttachedAxisIndex
368 for( auto const& rZSlot
: m_aZSlots
)
370 //iterate through all x slots in this category to get 100percent sum
371 for( auto const& rXSlot
: rZSlot
)
373 for( VDataSeries
* pSeries
: rXSlot
.m_aSeriesVector
)
379 pSeries
->doSortByXValues();
381 sal_Int32 nAttachedAxisIndex
= pSeries
->getAttachedAxisIndex();
382 if( aLogicYSumMap
.find(nAttachedAxisIndex
)==aLogicYSumMap
.end() )
383 aLogicYSumMap
[nAttachedAxisIndex
]=0.0;
385 PlottingPositionHelper
* pPosHelper
= &(getPlottingPositionHelper( nAttachedAxisIndex
));
387 pPosHelper
= m_pMainPosHelper
.get();
388 PlotterBase::m_pPosHelper
= pPosHelper
;
390 double fAdd
= pSeries
->getYValue( nIndex
);
391 if( !::rtl::math::isNan(fAdd
) && !::rtl::math::isInf(fAdd
) )
392 aLogicYSumMap
[nAttachedAxisIndex
] += fabs( fAdd
);
397 for( auto const& rZSlot
: m_aZSlots
)
399 //for the area chart there should be at most one x slot (no side by side stacking available)
400 //attention different: xSlots are always interpreted as independent areas one behind the other: @todo this doesn't work why not???
401 for( auto const& rXSlot
: rZSlot
)
403 std::map
< sal_Int32
, double > aLogicYForNextSeriesMap
;//one for each different nAttachedAxisIndex
404 //iterate through all series
405 for( VDataSeries
* pSeries
: rXSlot
.m_aSeriesVector
)
410 /* #i70133# ignore points outside of series length in standard area
411 charts. Stacked area charts will use missing points as zeros. In
412 standard charts, pSeriesList contains only one series. */
413 if( m_bArea
&& (rXSlot
.m_aSeriesVector
.size() == 1) && (nIndex
>= pSeries
->getTotalPointCount()) )
416 uno::Reference
< drawing::XShapes
> xSeriesGroupShape_Shapes
= getSeriesGroupShapeFrontChild(pSeries
, m_xSeriesTarget
);
418 sal_Int32 nAttachedAxisIndex
= pSeries
->getAttachedAxisIndex();
419 PlottingPositionHelper
* pPosHelper
= &(getPlottingPositionHelper( nAttachedAxisIndex
));
421 pPosHelper
= m_pMainPosHelper
.get();
422 PlotterBase::m_pPosHelper
= pPosHelper
;
424 pSeries
->m_fLogicZPos
= fLogicZ
;
426 //collect data point information (logic coordinates, style ):
427 double fLogicX
= pSeries
->getXValue(nIndex
);
429 fLogicX
= DateHelper::RasterizeDateValue( fLogicX
, m_aNullDate
, m_nTimeResolution
);
430 double fLogicY
= pSeries
->getYValue(nIndex
);
432 if( m_bArea
&& ( ::rtl::math::isNan(fLogicY
) || ::rtl::math::isInf(fLogicY
) ) )
434 if( pSeries
->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP
)
436 if( rXSlot
.m_aSeriesVector
.size() == 1 || pSeries
== rXSlot
.m_aSeriesVector
.front() )
438 fLogicY
= pPosHelper
->getLogicMinY();
439 if( !pPosHelper
->isMathematicalOrientationY() )
440 fLogicY
= pPosHelper
->getLogicMaxY();
447 if( pPosHelper
->isPercentY() && aLogicYSumMap
[nAttachedAxisIndex
] != 0.0 )
449 fLogicY
= fabs( fLogicY
)/aLogicYSumMap
[nAttachedAxisIndex
];
452 if( ::rtl::math::isNan(fLogicX
) || ::rtl::math::isInf(fLogicX
)
453 || ::rtl::math::isNan(fLogicY
) || ::rtl::math::isInf(fLogicY
)
454 || ::rtl::math::isNan(fLogicZ
) || ::rtl::math::isInf(fLogicZ
) )
456 if( pSeries
->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP
)
458 drawing::PolyPolygonShape3D
& rPolygon
= pSeries
->m_aPolyPolygonShape3D
;
459 sal_Int32
& rIndex
= pSeries
->m_nPolygonIndex
;
460 if( 0<= rIndex
&& rIndex
< rPolygon
.SequenceX
.getLength() )
462 if( rPolygon
.SequenceX
[ rIndex
].getLength() )
463 rIndex
++; //start a new polygon for the next point if the current poly is not empty
469 if( aLogicYForNextSeriesMap
.find(nAttachedAxisIndex
) == aLogicYForNextSeriesMap
.end() )
470 aLogicYForNextSeriesMap
[nAttachedAxisIndex
] = 0.0;
472 double fLogicValueForLabeDisplay
= fLogicY
;
474 fLogicY
+= aLogicYForNextSeriesMap
[nAttachedAxisIndex
];
475 aLogicYForNextSeriesMap
[nAttachedAxisIndex
] = fLogicY
;
477 bool bIsVisible
= pPosHelper
->isLogicVisible( fLogicX
, fLogicY
, fLogicZ
);
479 //remind minimal and maximal x values for area 'grounding' points
480 //only for filled area
482 double& rfMinX
= pSeries
->m_fLogicMinX
;
483 if(!nIndex
||fLogicX
<rfMinX
)
485 double& rfMaxX
= pSeries
->m_fLogicMaxX
;
486 if(!nIndex
||fLogicX
>rfMaxX
)
490 drawing::Position3D
aUnscaledLogicPosition( fLogicX
, fLogicY
, fLogicZ
);
491 drawing::Position3D
aScaledLogicPosition(aUnscaledLogicPosition
);
492 pPosHelper
->doLogicScaling( aScaledLogicPosition
);
494 //transformation 3) -> 4)
495 drawing::Position3D
aScenePosition( pPosHelper
->transformLogicToScene( fLogicX
,fLogicY
,fLogicZ
, false ) );
497 //better performance for big data
498 FormerPoint
aFormerPoint( aSeriesFormerPointMap
[pSeries
] );
499 pPosHelper
->setCoordinateSystemResolution( m_aCoordinateSystemResolution
);
500 if( !pSeries
->isAttributedDataPoint(nIndex
)
502 pPosHelper
->isSameForGivenResolution( aFormerPoint
.m_fX
, aFormerPoint
.m_fY
, aFormerPoint
.m_fZ
503 , aScaledLogicPosition
.PositionX
, aScaledLogicPosition
.PositionY
, aScaledLogicPosition
.PositionZ
) )
506 m_bPointsWereSkipped
= true;
509 aSeriesFormerPointMap
[pSeries
] = FormerPoint(aScaledLogicPosition
.PositionX
, aScaledLogicPosition
.PositionY
, aScaledLogicPosition
.PositionZ
);
511 //store point information for series polygon
512 //for area and/or line (symbols only do not need this)
513 if( isValidPosition(aScaledLogicPosition
) )
515 AddPointToPoly( pSeries
->m_aPolyPolygonShape3D
, aScaledLogicPosition
, pSeries
->m_nPolygonIndex
);
517 //prepare clipping for filled net charts
518 if( !bIsVisible
&& m_bArea
)
520 drawing::Position3D
aClippedPos(aScaledLogicPosition
);
521 pPosHelper
->clipScaledLogicValues( nullptr, &aClippedPos
.PositionY
, nullptr );
522 if( pPosHelper
->isLogicVisible( aClippedPos
.PositionX
, aClippedPos
.PositionY
, aClippedPos
.PositionZ
) )
524 AddPointToPoly( pSeries
->m_aPolyPolygonShape3D
, aClippedPos
, pSeries
->m_nPolygonIndex
);
525 AddPointToPoly( pSeries
->m_aPolyPolygonShape3D
, aScaledLogicPosition
, pSeries
->m_nPolygonIndex
);
530 //create a single datapoint if point is visible
535 Symbol
* pSymbolProperties
= pSeries
->getSymbolProperties( nIndex
);
536 bool bCreateSymbol
= pSymbolProperties
&& (pSymbolProperties
->Style
!= SymbolStyle_NONE
);
538 if( !bCreateSymbol
&& !pSeries
->getDataPointLabelIfLabel(nIndex
) )
541 //create a group shape for this point and add to the series shape:
542 OUString aPointCID
= ObjectIdentifier::createPointCID(
543 pSeries
->getPointCID_Stub(), nIndex
);
544 uno::Reference
< drawing::XShapes
> xPointGroupShape_Shapes(
545 createGroupShape(xSeriesGroupShape_Shapes
,aPointCID
) );
546 uno::Reference
<drawing::XShape
> xPointGroupShape_Shape
=
547 uno::Reference
<drawing::XShape
>( xPointGroupShape_Shapes
, uno::UNO_QUERY
);
553 drawing::Direction3D
aSymbolSize(0,0,0);
556 if( pSymbolProperties
)
558 if( pSymbolProperties
->Style
!= SymbolStyle_NONE
)
560 aSymbolSize
.DirectionX
= pSymbolProperties
->Size
.Width
;
561 aSymbolSize
.DirectionY
= pSymbolProperties
->Size
.Height
;
564 if( pSymbolProperties
->Style
== SymbolStyle_STANDARD
)
566 sal_Int32 nSymbol
= pSymbolProperties
->StandardSymbol
;
567 m_pShapeFactory
->createSymbol2D( xPointGroupShape_Shapes
568 , aScenePosition
, aSymbolSize
570 , pSymbolProperties
->BorderColor
571 , pSymbolProperties
->FillColor
);
573 else if( pSymbolProperties
->Style
== SymbolStyle_GRAPHIC
)
575 m_pShapeFactory
->createGraphic2D( xPointGroupShape_Shapes
576 , aScenePosition
, aSymbolSize
577 , pSymbolProperties
->Graphic
);
579 //@todo other symbol styles
583 //create data point label
584 if( pSeries
->getDataPointLabelIfLabel(nIndex
) )
586 LabelAlignment eAlignment
= LABEL_ALIGN_TOP
;
587 drawing::Position3D
aScenePosition3D( aScenePosition
.PositionX
588 , aScenePosition
.PositionY
589 , aScenePosition
.PositionZ
+getTransformedDepth() );
591 sal_Int32 nLabelPlacement
= pSeries
->getLabelPlacement( nIndex
, m_xChartTypeModel
, pPosHelper
->isSwapXAndY() );
593 switch(nLabelPlacement
)
595 case css::chart::DataLabelPlacement::TOP
:
596 aScenePosition3D
.PositionY
-= (aSymbolSize
.DirectionY
/2+1);
597 eAlignment
= LABEL_ALIGN_TOP
;
599 case css::chart::DataLabelPlacement::BOTTOM
:
600 aScenePosition3D
.PositionY
+= (aSymbolSize
.DirectionY
/2+1);
601 eAlignment
= LABEL_ALIGN_BOTTOM
;
603 case css::chart::DataLabelPlacement::LEFT
:
604 aScenePosition3D
.PositionX
-= (aSymbolSize
.DirectionX
/2+1);
605 eAlignment
= LABEL_ALIGN_LEFT
;
607 case css::chart::DataLabelPlacement::RIGHT
:
608 aScenePosition3D
.PositionX
+= (aSymbolSize
.DirectionX
/2+1);
609 eAlignment
= LABEL_ALIGN_RIGHT
;
611 case css::chart::DataLabelPlacement::CENTER
:
612 eAlignment
= LABEL_ALIGN_CENTER
;
613 //todo implement this different for area charts
616 OSL_FAIL("this label alignment is not implemented yet");
617 aScenePosition3D
.PositionY
-= (aSymbolSize
.DirectionY
/2+1);
618 eAlignment
= LABEL_ALIGN_TOP
;
622 awt::Point aScreenPosition2D
;//get the screen position for the labels
623 sal_Int32 nOffset
= 100; //todo maybe calculate this font height dependent
624 if( nLabelPlacement
== css::chart::DataLabelPlacement::OUTSIDE
)
626 PolarPlottingPositionHelper
* pPolarPosHelper
= dynamic_cast<PolarPlottingPositionHelper
*>(pPosHelper
);
627 if( pPolarPosHelper
)
629 PolarLabelPositionHelper
aPolarLabelPositionHelper(pPolarPosHelper
,m_nDimension
,m_xLogicTarget
,m_pShapeFactory
);
630 aScreenPosition2D
= awt::Point( aPolarLabelPositionHelper
.getLabelScreenPositionAndAlignmentForLogicValues(
631 eAlignment
, fLogicX
, fLogicY
, fLogicZ
, nOffset
));
636 if(eAlignment
==LABEL_ALIGN_CENTER
)
638 aScreenPosition2D
= awt::Point( LabelPositionHelper(m_nDimension
,m_xLogicTarget
,m_pShapeFactory
)
639 .transformSceneToScreenPosition( aScenePosition3D
) );
642 createDataLabel( m_xTextTarget
, *pSeries
, nIndex
643 , fLogicValueForLabeDisplay
644 , aLogicYSumMap
[nAttachedAxisIndex
], aScreenPosition2D
, eAlignment
, nOffset
);
648 //remove PointGroupShape if empty
649 if(!xPointGroupShape_Shapes
->getCount())
650 xSeriesGroupShape_Shapes
->remove(xPointGroupShape_Shape
);
652 }//next series in x slot (next y slot)
657 impl_createSeriesShapes();
663 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */