28#include <com/sun/star/beans/XPropertySet.hpp>
30#include <osl/diagnose.h>
38 , sal_Int32 nDimensionCount )
39 : VSeriesPlotter( xChartTypeModel, nDimensionCount )
40 , m_pMainPosHelper( new BarPositionHelper() )
42 PlotterBase::m_pPosHelper = m_pMainPosHelper.get();
43 VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper.get();
46CandleStickChart::~CandleStickChart()
52bool CandleStickChart::isSeparateStackingForDifferentSigns( sal_Int32 )
59 return LegendSymbolStyle::Line;
62drawing::Direction3D CandleStickChart::getPreferredDiagramAspectRatio()
const
64 return drawing::Direction3D(-1,-1,-1);
67void CandleStickChart::addSeries( std::unique_ptr<VDataSeries> pSeries, sal_Int32 , sal_Int32 xSlot, sal_Int32 ySlot )
70 VSeriesPlotter::addSeries( std::move(pSeries), 0, xSlot, ySlot );
73void CandleStickChart::createShapes()
75 if( m_aZSlots.empty() )
81 OSL_ENSURE(m_xLogicTarget.is()&&m_xFinalTarget.is(),
"CandleStickChart is not proper initialized");
82 if(!(m_xLogicTarget.is()&&m_xFinalTarget.is()))
90 createGroupShape( m_xLogicTarget );
92 createGroupShape( m_xLogicTarget, ObjectIdentifier::createClassifiedIdentifier(
95 createGroupShape( m_xLogicTarget, ObjectIdentifier::createClassifiedIdentifier(
98 ShapeFactory::createGroup2D( m_xFinalTarget );
102 bool bJapaneseStyle=
true;
103 bool bShowFirst =
true;
108 if( m_xChartTypeModel.is() )
110 m_xChartTypeModel->getPropertyValue(
"ShowFirst" ) >>= bShowFirst;
114 m_xChartTypeModel->getPropertyValue(
"Japanese" ) >>= bJapaneseStyle;
115 m_xChartTypeModel->getPropertyValue(
"WhiteDay" ) >>= xWhiteDayProps;
116 m_xChartTypeModel->getPropertyValue(
"BlackDay" ) >>= xBlackDayProps;
119 PropertyMapper::getValueMap( aWhiteBox_Map, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xWhiteDayProps );
120 PropertyMapper::getMultiPropertyListsFromValueMap( aWhiteBox_Names, aWhiteBox_Values, aWhiteBox_Map );
123 PropertyMapper::getValueMap( aBlackBox_Map, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xBlackDayProps );
124 PropertyMapper::getMultiPropertyListsFromValueMap( aBlackBox_Names, aBlackBox_Values, aBlackBox_Map );
127 catch(
const uno::Exception& )
133 sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
134 double fLogicZ = 1.5;
138 for(
auto const& rZSlot : m_aZSlots )
141 if( !rZSlot.empty() )
143 sal_Int32 nAttachedAxisIndex = rZSlot.front().getAttachedAxisIndexForFirstSeries();
145 pPosHelper =
dynamic_cast<BarPositionHelper*
>(&( getPlottingPositionHelper( nAttachedAxisIndex ) ) );
147 pPosHelper = m_pMainPosHelper.get();
149 PlotterBase::m_pPosHelper = pPosHelper;
155 for(
auto const& rXSlot : rZSlot )
158 for( std::unique_ptr<VDataSeries>
const & pSeries : rXSlot.m_aSeriesVector )
161 double fUnscaledX = pSeries->getXValue(
nIndex );
162 if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() )
163 fUnscaledX = DateHelper::RasterizeDateValue( fUnscaledX, m_aNullDate, m_nTimeResolution );
164 if(fUnscaledX<pPosHelper->getLogicMinX() || fUnscaledX>pPosHelper->
getLogicMaxX())
168 double fUnscaledY_First = pSeries->getY_First(
nIndex );
169 double fUnscaledY_Last = pSeries->getY_Last(
nIndex );
170 double fUnscaledY_Min = pSeries->getY_Min(
nIndex );
171 double fUnscaledY_Max = pSeries->getY_Max(
nIndex );
174 if(fUnscaledY_Last<=fUnscaledY_First)
176 std::swap(fUnscaledY_First,fUnscaledY_Last);
179 if(fUnscaledY_Max<fUnscaledY_Min)
180 std::swap(fUnscaledY_Min,fUnscaledY_Max);
184 double fScaledY_First(fUnscaledY_First);
185 double fScaledY_Last(fUnscaledY_Last);
186 double fScaledY_Min(fUnscaledY_Min);
187 double fScaledY_Max(fUnscaledY_Max);
197 drawing::Position3D aPosLeftFirst( pPosHelper->
transformScaledLogicToScene( fScaledX-fHalfScaledWidth, fScaledY_First ,0 ,
true ) );
206 xLossGainTarget = xLossTarget;
211 OUString aPointCID = ObjectIdentifier::createPointCID( pSeries->getPointCID_Stub(),
nIndex );
213 xPointGroupShape_Shapes = createGroupShape(xSeriesGroupShape_Shapes,aPointCID);
217 if( isValidPosition(aPosMiddleMinimum) && isValidPosition(aPosMiddleMaximum) )
219 std::vector<std::vector<css::drawing::Position3D>> aPoly
221 { aPosMiddleMinimum, aPosMiddleMaximum }
225 ShapeFactory::createLine2D( xPointGroupShape_Shapes, aPoly);
226 PropertyMapper::setMappedProperties( *xShape, xPointProp, PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
230 if(bJapaneseStyle && isValidPosition(aPosLeftFirst) && isValidPosition(aPosRightLast) )
232 drawing::Direction3D aDiff = aPosRightLast-aPosLeftFirst;
235 if( aAWTSize.Height == 0 )
242 ShapeFactory::createRectangle( xLossGainTarget,
247 PropertyMapper::setMultiProperties( aBlackBox_Names, aBlackBox_Values, *xShape );
249 PropertyMapper::setMultiProperties( aWhiteBox_Names, aWhiteBox_Values, *xShape );
253 std::vector<std::vector<css::drawing::Position3D>> aPoly;
255 sal_Int32 nLineIndex = 0;
256 if( bShowFirst && pPosHelper->
isLogicVisible( fUnscaledX, fUnscaledY_First ,fLogicZ )
257 && isValidPosition(aPosLeftFirst) && isValidPosition(aPosMiddleFirst) )
262 if( pPosHelper->
isLogicVisible( fUnscaledX, fUnscaledY_Last ,fLogicZ )
263 && isValidPosition(aPosMiddleLast) && isValidPosition(aPosRightLast) )
272 ShapeFactory::createLine2D( xPointGroupShape_Shapes, aPoly );
273 PropertyMapper::setMappedProperties( *xShape, xPointProp, PropertyMapper::getPropertyNameMapForLineSeriesProperties() );
278 if( pSeries->getDataPointLabelIfLabel(
nIndex) )
280 if(isValidPosition(aPosMiddleFirst))
281 createDataLabel( xTextTarget, *pSeries,
nIndex
283 if(isValidPosition(aPosMiddleLast))
284 createDataLabel( xTextTarget, *pSeries,
nIndex
286 if(isValidPosition(aPosMiddleMinimum))
287 createDataLabel( xTextTarget, *pSeries,
nIndex
289 if(isValidPosition(aPosMiddleMaximum))
290 createDataLabel( xTextTarget, *pSeries,
nIndex
virtual double getScaledSlotPos(double fCategoryX, double fSeriesNumber) const override
void updateSeriesCount(double fSeriesCount)
CandleStickChart()=delete
double getScaledSlotWidth() const
double getLogicMaxX() const
bool isLogicVisible(double fX, double fY, double fZ) 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
#define TOOLS_WARN_EXCEPTION(area, stream)
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Point Position3DToAWTPoint(const css::drawing::Position3D &rPos)
Position3D --> awt::Point (2D)
@ OBJECTTYPE_DATA_STOCK_LOSS
@ OBJECTTYPE_DATA_STOCK_GAIN
OOO_DLLPUBLIC_CHARTTOOLS void AddPointToPoly(css::drawing::PolyPolygonShape3D &rPoly, const css::drawing::Position3D &rPos, sal_Int32 nSequenceIndex=0)
PolyPolygonShape3D + drawing::Position3D -> PolyPolygonShape3D.
css::uno::Sequence< OUString > tNameSequence
@ LABEL_ALIGN_LEFT_BOTTOM
css::uno::Sequence< css::uno::Any > tAnySequence
std::unordered_map< OUString, css::uno::Any > tPropertyNameValueMap
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Size Direction3DToAWTSize(const css::drawing::Direction3D &rDirection)
Direction3D --> awt::Size (2D)