LibreOffice Module chart2 (master) 1
NetChart.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "NetChart.hxx"
22#include <ShapeFactory.hxx>
24#include <CommonConverters.hxx>
25#include <ObjectIdentifier.hxx>
27#include <Clipping.hxx>
29#include <DateHelper.hxx>
30#include <ChartType.hxx>
31
32#include <com/sun/star/chart2/Symbol.hpp>
33#include <com/sun/star/chart/DataLabelPlacement.hpp>
34#include <com/sun/star/chart/MissingValueTreatment.hpp>
35
36#include <o3tl/safeint.hxx>
37#include <osl/diagnose.h>
38
39#include <officecfg/Office/Compatibility.hxx>
40
41#include <limits>
42
43namespace chart
44{
45using namespace ::com::sun::star;
46using namespace ::com::sun::star::chart2;
47
49 , sal_Int32 nDimensionCount
50 , bool bNoArea
51 , std::unique_ptr<PlottingPositionHelper> pPlottingPositionHelper
52 )
53 : VSeriesPlotter( xChartTypeModel, nDimensionCount, true )
54 , m_pMainPosHelper(std::move(pPlottingPositionHelper))
55 , m_bArea(!bNoArea)
56 , m_bLine(bNoArea)
57{
58 // we only support 2D Net charts
59 assert(nDimensionCount == 2);
60
61 m_pMainPosHelper->AllowShiftXAxisPos(true);
62 m_pMainPosHelper->AllowShiftZAxisPos(true);
63
64 PlotterBase::m_pPosHelper = m_pMainPosHelper.get();
65 VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get();
66}
67
68NetChart::~NetChart()
69{
70}
71
72double NetChart::getMaximumX()
73{
74 double fMax = VSeriesPlotter::getMaximumX() + 1.0;
75 return fMax;
76}
77
78bool NetChart::isExpandIfValuesCloseToBorder( sal_Int32 )
79{
80 return false;
81}
82
83bool NetChart::isSeparateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex*/ )
84{
85 // no separate stacking in all types of line/area charts
86 return false;
87}
88
89LegendSymbolStyle NetChart::getLegendSymbolStyle()
90{
91 if( m_bArea )
92 return LegendSymbolStyle::Box;
93 return LegendSymbolStyle::Line;
94}
95
96uno::Any NetChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex )
97{
98 uno::Any aRet;
99
100 Symbol* pSymbolProperties = rSeries.getSymbolProperties( nPointIndex );
101 if( pSymbolProperties )
102 {
103 aRet <<= *pSymbolProperties;
104 }
105
106 return aRet;
107}
108
109drawing::Direction3D NetChart::getPreferredDiagramAspectRatio() const
110{
111 return drawing::Direction3D(1,1,1);
112}
113
114bool NetChart::impl_createLine( VDataSeries* pSeries
115 , const std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly
116 , PlottingPositionHelper const * pPosHelper )
117{
118 //return true if a line was created successfully
119 rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
120
121 std::vector<std::vector<css::drawing::Position3D>> aPoly;
122 {
123 bool bIsClipped = false;
124 if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
125 {
126 // do NOT connect last and first point, if one is NAN, and NAN handling is NAN_AS_GAP
127 double fFirstY = pSeries->getYValue( 0 );
128 double fLastY = pSeries->getYValue( VSeriesPlotter::getPointCount() - 1 );
129 if( (pSeries->getMissingValueTreatment() != css::chart::MissingValueTreatment::LEAVE_GAP)
130 || (std::isfinite( fFirstY ) && std::isfinite( fLastY )) )
131 {
132 // connect last point in last polygon with first point in first polygon
133 ::basegfx::B2DRectangle aScaledLogicClipDoubleRect( pPosHelper->getScaledLogicClipDoubleRect() );
134 std::vector<std::vector<css::drawing::Position3D>> aTmpPoly(*pSeriesPoly);
135 drawing::Position3D aLast(aScaledLogicClipDoubleRect.getMaxX(),aTmpPoly[0][0].PositionY,aTmpPoly[0][0].PositionZ);
136 // add connector line to last polygon
137 AddPointToPoly( aTmpPoly, aLast, pSeriesPoly->size() - 1 );
138 Clipping::clipPolygonAtRectangle( aTmpPoly, aScaledLogicClipDoubleRect, aPoly );
139 bIsClipped = true;
140 }
141 }
142
143 if( !bIsClipped )
144 Clipping::clipPolygonAtRectangle( *pSeriesPoly, pPosHelper->getScaledLogicClipDoubleRect(), aPoly );
145 }
146
147 if(!ShapeFactory::hasPolygonAnyLines(aPoly))
148 return false;
149
150 //transformation 3) -> 4)
151 pPosHelper->transformScaledLogicToScene( aPoly );
152
153 //create line:
155 {
156 xShape = ShapeFactory::createLine2D( xSeriesGroupShape_Shapes, aPoly );
157 PropertyMapper::setMappedProperties( *xShape
158 , pSeries->getPropertiesOfSeries()
159 , PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
160 //because of this name this line will be used for marking
161 ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles");
162 }
163 return true;
164}
165
166bool NetChart::impl_createArea( VDataSeries* pSeries
167 , const std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly
168 , std::vector<std::vector<css::drawing::Position3D>> const * pPreviousSeriesPoly
169 , PlottingPositionHelper const * pPosHelper )
170{
171 //return true if an area was created successfully
172
173 rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeBackChild(pSeries, m_xSeriesTarget);
174 double zValue = pSeries->m_fLogicZPos;
175
176 std::vector<std::vector<css::drawing::Position3D>> aPoly( *pSeriesPoly );
177 //add second part to the polygon (grounding points or previous series points)
178 if( !ShapeFactory::isPolygonEmptyOrSinglePoint(*pSeriesPoly) )
179 {
180 if( pPreviousSeriesPoly )
181 addPolygon( aPoly, *pPreviousSeriesPoly );
182 }
183 else if(!pPreviousSeriesPoly)
184 {
185 double fMinX = pSeries->m_fLogicMinX;
186 double fMaxX = pSeries->m_fLogicMaxX;
187 double fY = pPosHelper->getBaseValueY();//logic grounding
188
189 //clip to scale
190 if(fMaxX<pPosHelper->getLogicMinX() || fMinX>pPosHelper->getLogicMaxX())
191 return false;//no visible shape needed
192 pPosHelper->clipLogicValues( &fMinX, &fY, nullptr );
193 pPosHelper->clipLogicValues( &fMaxX, nullptr, nullptr );
194
195 //apply scaling
196 {
197 pPosHelper->doLogicScaling( &fMinX, &fY, &zValue );
198 pPosHelper->doLogicScaling( &fMaxX, nullptr, nullptr );
199 }
200
201 AddPointToPoly( aPoly, drawing::Position3D( fMaxX,fY,zValue) );
202 AddPointToPoly( aPoly, drawing::Position3D( fMinX,fY,zValue) );
203 }
204 else
205 {
206 appendPoly( aPoly, *pPreviousSeriesPoly );
207 }
208 ShapeFactory::closePolygon(aPoly);
209
210 //apply clipping
211 {
212 std::vector<std::vector<css::drawing::Position3D>> aClippedPoly;
213 Clipping::clipPolygonAtRectangle( aPoly, pPosHelper->getScaledLogicClipDoubleRect(), aClippedPoly, false );
214 ShapeFactory::closePolygon(aClippedPoly); //again necessary after clipping
215 aPoly = aClippedPoly;
216 }
217
218 if(!ShapeFactory::hasPolygonAnyLines(aPoly))
219 return false;
220
221 //transformation 3) -> 4)
222 pPosHelper->transformScaledLogicToScene( aPoly );
223
224 //create area:
226 xShape = ShapeFactory::createArea2D( xSeriesGroupShape_Shapes
227 , aPoly );
228 PropertyMapper::setMappedProperties( *xShape
229 , pSeries->getPropertiesOfSeries()
230 , PropertyMapper::getPropertyNameMapForFilledSeriesProperties() );
231 //because of this name this line will be used for marking
232 ::chart::ShapeFactory::setShapeName(xShape, "MarkHandles");
233 return true;
234}
235
236void NetChart::impl_createSeriesShapes()
237{
238 //the polygon shapes for each series need to be created before
239
240 //iterate through all series again to create the series shapes
241 for( auto const& rZSlot : m_aZSlots )
242 {
243 for( auto const& rXSlot : rZSlot )
244 {
245 std::map< sal_Int32, std::vector<std::vector<css::drawing::Position3D>>* > aPreviousSeriesPolyMap;//a PreviousSeriesPoly for each different nAttachedAxisIndex
246 std::vector<std::vector<css::drawing::Position3D>>* pSeriesPoly = nullptr;
247
248 //iterate through all series
249 for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
250 {
251 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
252 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
253
254 pSeriesPoly = &pSeries->m_aPolyPolygonShape3D;
255 if( m_bArea )
256 {
257 if (!impl_createArea(pSeries.get(), pSeriesPoly,
258 aPreviousSeriesPolyMap[nAttachedAxisIndex], m_pPosHelper))
259 continue;
260 }
261 if( m_bLine )
262 {
263 if (!impl_createLine(pSeries.get(), pSeriesPoly, m_pPosHelper))
264 continue;
265 }
266 aPreviousSeriesPolyMap[nAttachedAxisIndex] = pSeriesPoly;
267 }//next series in x slot (next y slot)
268 }//next x slot
269 }//next z slot
270}
271
272namespace
273{
274
275void lcl_reorderSeries( std::vector< std::vector< VDataSeriesGroup > >& rZSlots )
276{
277 std::vector< std::vector< VDataSeriesGroup > > aRet;
278 aRet.reserve( rZSlots.size() );
279
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 )
283 {
284 std::vector< VDataSeriesGroup > aXSlot;
285
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));
290
291 aRet.push_back(std::move(aXSlot));
292 }
293
294 rZSlots = std::move(aRet);
295}
296
297//better performance for big data
298struct FormerPoint
299{
300 FormerPoint( double fX, double fY, double fZ )
301 : m_fX(fX), m_fY(fY), m_fZ(fZ)
302 {}
303 FormerPoint()
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())
307
308 {
309 }
310
311 double m_fX;
312 double m_fY;
313 double m_fZ;
314};
315
316}//anonymous namespace
317
318void NetChart::createShapes()
319{
320 if( m_aZSlots.empty() ) //no series
321 return;
322
323 //tdf#127813 Don't reverse the series in OOXML-heavy environments
324 if (officecfg::Office::Compatibility::View::ReverseSeriesOrderAreaAndNetChart::get() && m_bArea)
325 lcl_reorderSeries( m_aZSlots );
326
327 OSL_ENSURE(m_xLogicTarget.is()&&m_xFinalTarget.is(),"NetChart is not proper initialized");
328 if(!(m_xLogicTarget.is()&&m_xFinalTarget.is()))
329 return;
330
331 //the text labels should be always on top of the other series shapes
332 //for area chart the error bars should be always on top of the other series shapes
333
334 //therefore create an own group for the texts and the error bars to move them to front
335 //(because the text group is created after the series group the texts are displayed on top)
336 m_xSeriesTarget = createGroupShape( m_xLogicTarget );
337 m_xTextTarget = ShapeFactory::createGroup2D( m_xFinalTarget );
338
339 //check necessary here that different Y axis can not be stacked in the same group? ... hm?
340
341 //update/create information for current group
342 double fLogicZ = 1.0;//as defined
343
344 sal_Int32 const nStartIndex = 0; // inclusive ;..todo get somehow from x scale
345 sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
346 if(nEndIndex<=0)
347 nEndIndex=1;
348
349 //better performance for big data
350 std::map< VDataSeries*, FormerPoint > aSeriesFormerPointMap;
351 m_bPointsWereSkipped = false;
352
353 bool bDateCategory = (m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis());
354
355 //iterate through all x values per indices
356 for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
357 {
358 std::map< sal_Int32, double > aLogicYSumMap;//one for each different nAttachedAxisIndex
359 for( auto const& rZSlot : m_aZSlots )
360 {
361 //iterate through all x slots in this category to get 100percent sum
362 for( auto const& rXSlot : rZSlot )
363 {
364 for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
365 {
366 if(!pSeries)
367 continue;
368
369 if (bDateCategory)
370 pSeries->doSortByXValues();
371
372 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
373 aLogicYSumMap.insert({nAttachedAxisIndex, 0.0});
374
375 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
376
377 double fAdd = pSeries->getYValue( nIndex );
378 if( !std::isnan(fAdd) && !std::isinf(fAdd) )
379 aLogicYSumMap[nAttachedAxisIndex] += fabs( fAdd );
380 }
381 }
382 }
383
384 for( auto const& rZSlot : m_aZSlots )
385 {
386 //for the area chart there should be at most one x slot (no side by side stacking available)
387 //attention different: xSlots are always interpreted as independent areas one behind the other: @todo this doesn't work why not???
388 for( auto const& rXSlot : rZSlot )
389 {
390 std::map< sal_Int32, double > aLogicYForNextSeriesMap;//one for each different nAttachedAxisIndex
391 //iterate through all series
392 for( std::unique_ptr<VDataSeries> const & pSeries : rXSlot.m_aSeriesVector )
393 {
394 if(!pSeries)
395 continue;
396
397 /* #i70133# ignore points outside of series length in standard area
398 charts. Stacked area charts will use missing points as zeros. In
399 standard charts, pSeriesList contains only one series. */
400 if( m_bArea && (rXSlot.m_aSeriesVector.size() == 1) && (nIndex >= pSeries->getTotalPointCount()) )
401 continue;
402
403 rtl::Reference<SvxShapeGroupAnyD> xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(pSeries.get(), m_xSeriesTarget);
404
405 sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
406 m_pPosHelper = &getPlottingPositionHelper(nAttachedAxisIndex);
407
408 pSeries->m_fLogicZPos = fLogicZ;
409
410 //collect data point information (logic coordinates, style ):
411 double fLogicX = pSeries->getXValue(nIndex);
412 if (bDateCategory)
413 fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
414 double fLogicY = pSeries->getYValue(nIndex);
415
416 if( m_bArea && ( std::isnan(fLogicY) || std::isinf(fLogicY) ) )
417 {
418 if( pSeries->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP )
419 {
420 if( rXSlot.m_aSeriesVector.size() == 1 || pSeries == rXSlot.m_aSeriesVector.front() )
421 {
422 fLogicY = m_pPosHelper->getLogicMinY();
423 if (!m_pPosHelper->isMathematicalOrientationY())
424 fLogicY = m_pPosHelper->getLogicMaxY();
425 }
426 else
427 fLogicY = 0.0;
428 }
429 }
430
431 if (m_pPosHelper->isPercentY() && aLogicYSumMap[nAttachedAxisIndex] != 0.0)
432 {
433 fLogicY = fabs( fLogicY )/aLogicYSumMap[nAttachedAxisIndex];
434 }
435
436 if( std::isnan(fLogicX) || std::isinf(fLogicX)
437 || std::isnan(fLogicY) || std::isinf(fLogicY)
438 || std::isnan(fLogicZ) || std::isinf(fLogicZ) )
439 {
440 if( pSeries->getMissingValueTreatment() == css::chart::MissingValueTreatment::LEAVE_GAP )
441 {
442 std::vector<std::vector<css::drawing::Position3D>>& rPolygon = pSeries->m_aPolyPolygonShape3D;
443 sal_Int32& rIndex = pSeries->m_nPolygonIndex;
444 if( 0<= rIndex && o3tl::make_unsigned(rIndex) < rPolygon.size() )
445 {
446 if( !rPolygon[ rIndex ].empty() )
447 rIndex++; //start a new polygon for the next point if the current poly is not empty
448 }
449 }
450 continue;
451 }
452
453 aLogicYForNextSeriesMap.try_emplace(nAttachedAxisIndex, 0.0);
454
455 double fLogicValueForLabeDisplay = fLogicY;
456
457 fLogicY += aLogicYForNextSeriesMap[nAttachedAxisIndex];
458 aLogicYForNextSeriesMap[nAttachedAxisIndex] = fLogicY;
459
460 bool bIsVisible = m_pPosHelper->isLogicVisible(fLogicX, fLogicY, fLogicZ);
461
462 //remind minimal and maximal x values for area 'grounding' points
463 //only for filled area
464 {
465 double& rfMinX = pSeries->m_fLogicMinX;
466 if(!nIndex||fLogicX<rfMinX)
467 rfMinX=fLogicX;
468 double& rfMaxX = pSeries->m_fLogicMaxX;
469 if(!nIndex||fLogicX>rfMaxX)
470 rfMaxX=fLogicX;
471 }
472
473 drawing::Position3D aUnscaledLogicPosition( fLogicX, fLogicY, fLogicZ );
474 drawing::Position3D aScaledLogicPosition(aUnscaledLogicPosition);
475 m_pPosHelper->doLogicScaling(aScaledLogicPosition);
476
477 //transformation 3) -> 4)
478 drawing::Position3D aScenePosition(
479 m_pPosHelper->transformLogicToScene(fLogicX, fLogicY, fLogicZ, false));
480
481 //better performance for big data
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 ) )
488 {
489 m_bPointsWereSkipped = true;
490 continue;
491 }
492 aSeriesFormerPointMap[pSeries.get()] = FormerPoint(aScaledLogicPosition.PositionX, aScaledLogicPosition.PositionY, aScaledLogicPosition.PositionZ);
493
494 //store point information for series polygon
495 //for area and/or line (symbols only do not need this)
496 if( isValidPosition(aScaledLogicPosition) )
497 {
498 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aScaledLogicPosition, pSeries->m_nPolygonIndex );
499
500 //prepare clipping for filled net charts
501 if( !bIsVisible && m_bArea )
502 {
503 drawing::Position3D aClippedPos(aScaledLogicPosition);
504 m_pPosHelper->clipScaledLogicValues(nullptr, &aClippedPos.PositionY,
505 nullptr);
506 if (m_pPosHelper->isLogicVisible(aClippedPos.PositionX,
507 aClippedPos.PositionY,
508 aClippedPos.PositionZ))
509 {
510 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aClippedPos, pSeries->m_nPolygonIndex );
511 AddPointToPoly( pSeries->m_aPolyPolygonShape3D, aScaledLogicPosition, pSeries->m_nPolygonIndex );
512 }
513 }
514 }
515
516 //create a single datapoint if point is visible
517 //apply clipping:
518 if( !bIsVisible )
519 continue;
520
521 Symbol* pSymbolProperties = pSeries->getSymbolProperties( nIndex );
522 bool bCreateSymbol = pSymbolProperties && (pSymbolProperties->Style != SymbolStyle_NONE);
523
524 if( !bCreateSymbol && !pSeries->getDataPointLabelIfLabel(nIndex) )
525 continue;
526
527 //create a group shape for this point and add to the series shape:
528 OUString aPointCID = ObjectIdentifier::createPointCID(
529 pSeries->getPointCID_Stub(), nIndex );
530 rtl::Reference<SvxShapeGroupAnyD> xPointGroupShape_Shapes(
531 createGroupShape(xSeriesGroupShape_Shapes,aPointCID) );
532
533 {
534 //create data point
535 drawing::Direction3D aSymbolSize(0,0,0);
536 if (bCreateSymbol) // implies pSymbolProperties
537 {
538 if (pSymbolProperties->Style != SymbolStyle_NONE)
539 {
540 aSymbolSize.DirectionX = pSymbolProperties->Size.Width;
541 aSymbolSize.DirectionY = pSymbolProperties->Size.Height;
542 }
543
544 if (pSymbolProperties->Style == SymbolStyle_STANDARD)
545 {
546 sal_Int32 nSymbol = pSymbolProperties->StandardSymbol;
547 ShapeFactory::createSymbol2D(
548 xPointGroupShape_Shapes, aScenePosition, aSymbolSize, nSymbol,
549 pSymbolProperties->BorderColor, pSymbolProperties->FillColor);
550 }
551 else if (pSymbolProperties->Style == SymbolStyle_GRAPHIC)
552 {
553 ShapeFactory::createGraphic2D(xPointGroupShape_Shapes,
554 aScenePosition, aSymbolSize,
555 pSymbolProperties->Graphic);
556 }
557 //@todo other symbol styles
558 }
559
560 //create data point label
561 if( pSeries->getDataPointLabelIfLabel(nIndex) )
562 {
563 LabelAlignment eAlignment = LABEL_ALIGN_TOP;
564 drawing::Position3D aScenePosition3D( aScenePosition.PositionX
565 , aScenePosition.PositionY
566 , aScenePosition.PositionZ+getTransformedDepth() );
567
568 sal_Int32 nLabelPlacement = pSeries->getLabelPlacement(
569 nIndex, m_xChartTypeModel, m_pPosHelper->isSwapXAndY());
570
571 switch(nLabelPlacement)
572 {
573 case css::chart::DataLabelPlacement::TOP:
574 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
575 eAlignment = LABEL_ALIGN_TOP;
576 break;
577 case css::chart::DataLabelPlacement::BOTTOM:
578 aScenePosition3D.PositionY += (aSymbolSize.DirectionY/2+1);
579 eAlignment = LABEL_ALIGN_BOTTOM;
580 break;
581 case css::chart::DataLabelPlacement::LEFT:
582 aScenePosition3D.PositionX -= (aSymbolSize.DirectionX/2+1);
583 eAlignment = LABEL_ALIGN_LEFT;
584 break;
585 case css::chart::DataLabelPlacement::RIGHT:
586 aScenePosition3D.PositionX += (aSymbolSize.DirectionX/2+1);
587 eAlignment = LABEL_ALIGN_RIGHT;
588 break;
589 case css::chart::DataLabelPlacement::CENTER:
590 eAlignment = LABEL_ALIGN_CENTER;
591 //todo implement this different for area charts
592 break;
593 default:
594 OSL_FAIL("this label alignment is not implemented yet");
595 aScenePosition3D.PositionY -= (aSymbolSize.DirectionY/2+1);
596 eAlignment = LABEL_ALIGN_TOP;
597 break;
598 }
599
600 awt::Point aScreenPosition2D;//get the screen position for the labels
601 sal_Int32 nOffset = 100; //todo maybe calculate this font height dependent
602 if( nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE )
603 {
604 PolarPlottingPositionHelper* pPolarPosHelper
605 = dynamic_cast<PolarPlottingPositionHelper*>(m_pPosHelper);
606 if( pPolarPosHelper )
607 {
608 PolarLabelPositionHelper aPolarLabelPositionHelper(pPolarPosHelper,m_nDimension,m_xLogicTarget);
609 aScreenPosition2D = aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues(
610 eAlignment, fLogicX, fLogicY, fLogicZ, nOffset );
611 }
612 }
613 else
614 {
615 if(eAlignment==LABEL_ALIGN_CENTER )
616 nOffset = 0;
617 aScreenPosition2D = LabelPositionHelper(m_nDimension,m_xLogicTarget)
618 .transformSceneToScreenPosition( aScenePosition3D );
619 }
620
621 createDataLabel( m_xTextTarget, *pSeries, nIndex
622 , fLogicValueForLabeDisplay
623 , aLogicYSumMap[nAttachedAxisIndex], aScreenPosition2D, eAlignment, nOffset );
624 }
625 }
626
627 //remove PointGroupShape if empty
628 if(!xPointGroupShape_Shapes->getCount())
629 xSeriesGroupShape_Shapes->remove(xPointGroupShape_Shapes);
630
631 }//next series in x slot (next y slot)
632 }//next x slot
633 }//next z slot
634 }//next category
635
636 impl_createSeriesShapes();
637
638}
639
640} //namespace chart
641
642/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double m_fY
Definition: NetChart.cxx:312
double m_fX
Definition: NetChart.cxx:311
double m_fZ
Definition: NetChart.cxx:313
TYPE getMaxX() const
css::awt::Point transformSceneToScreenPosition(const css::drawing::Position3D &rScenePosition3D) const
NetChart()=delete
::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
sal_Int32 nIndex
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.
@ LABEL_ALIGN_CENTER
@ LABEL_ALIGN_TOP
@ LABEL_ALIGN_RIGHT
@ LABEL_ALIGN_LEFT
@ LABEL_ALIGN_BOTTOM
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)