38#include <unonames.hxx>
40#include <com/sun/star/chart/ChartAxisPosition.hpp>
41#include <com/sun/star/chart2/AxisType.hpp>
42#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
51using namespace ::css::chart2;
53using ::css::uno::Reference;
54using ::css::uno::Sequence;
58 std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList)
59 : m_rVCooSysList(rVCooSysList)
61 , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false)
62 , m_nDefaultDateNumberFormat(0)
70 nC->clearMinimumAndMaximumSupplierList();
78 aRet[nN++] = aPlotter.get();
83 const std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList,
86 for (
auto& pVCooSys : rVCooSysList)
88 if (pVCooSys->getModel() == xCooSys)
89 return pVCooSys.get();
95 const std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList,
98 if (!pMinimumAndMaximumSupplier)
100 for (
auto& pVCooSys : rVCooSysList)
102 if (pVCooSys->hasMinimumAndMaximumSupplier(pMinimumAndMaximumSupplier))
103 return pVCooSys.get();
109 std::vector<std::unique_ptr<VCoordinateSystem>>& rVCooSysList,
114 if (pExistingVCooSys)
115 return pExistingVCooSys;
117 std::unique_ptr<VCoordinateSystem> pVCooSys
122 OUString aCooSysParticle(
124 pVCooSys->setParticle(aCooSysParticle);
127 rVCooSysList.push_back(std::move(pVCooSys));
128 return rVCooSysList.back().get();
138 if (rChartModel.hasInternalDataProvider() && xDiagram->isSupportingDateAxis())
141 sal_Int32 nDimensionCount = xDiagram->getDimension();
142 if (!nDimensionCount)
148 bool bSortByXValues =
false;
149 bool bConnectBars =
false;
150 bool bGroupBarsPerAxis =
true;
151 bool bIncludeHiddenCells =
true;
152 bool bSecondaryYaxisVisible =
true;
153 sal_Int32 nStartingAngle = 90;
154 sal_Int32 n3DRelativeHeight = 100;
158 xDiagram->getPropertyValue(
"ConnectBars") >>= bConnectBars;
159 xDiagram->getPropertyValue(
"GroupBarsPerAxis") >>= bGroupBarsPerAxis;
160 xDiagram->getPropertyValue(
"IncludeHiddenCells") >>= bIncludeHiddenCells;
161 xDiagram->getPropertyValue(
"StartingAngle") >>= nStartingAngle;
163 if (nDimensionCount == 3)
165 xDiagram->getPropertyValue(
"3DRelativeHeight") >>= n3DRelativeHeight;
168 catch (
const uno::Exception&)
173 if (xDiagram->getDataTable().is())
183 auto aCooSysList = xDiagram->getBaseCoordinateSystems();
184 sal_Int32 nGlobalSeriesIndex = 0;
185 for (std::size_t nCS = 0; nCS < aCooSysList.size(); ++nCS)
193 if (xCooSys->getMaximumAxisIndexByDimension(1) > 0)
196 xAxisProp->getPropertyValue(
"Show") >>= bSecondaryYaxisVisible;
199 catch (
const lang::IndexOutOfBoundsException&)
204 std::vector<rtl::Reference<ChartType>> aChartTypeList(xCooSys->getChartTypes2());
205 for (std::size_t nT = 0; nT < aChartTypeList.size(); ++nT)
208 if (nDimensionCount == 3
209 && xChartType->getChartType().equalsIgnoreAsciiCase(
214 sal_Int32 n3DRelativeHeightOldValue(100);
215 uno::Any aAny = xChartType->getFastPropertyValue(
217 aAny >>= n3DRelativeHeightOldValue;
218 if (n3DRelativeHeightOldValue != n3DRelativeHeight)
219 xChartType->setFastPropertyValue(
223 catch (
const uno::Exception&)
232 bool bExcludingPositioning
235 xChartType, nDimensionCount, bExcludingPositioning);
244 sal_Int32 nMissingValueTreatment
245 = xDiagram->getCorrectedMissingValueTreatment(xChartType);
250 sal_Int32 zSlot = -1;
251 sal_Int32 xSlot = -1;
252 sal_Int32 ySlot = -1;
253 const std::vector<rtl::Reference<DataSeries>>& aSeriesList
254 = xChartType->getDataSeries2();
255 for (std::size_t nS = 0; nS < aSeriesList.size(); ++nS)
258 if (!bIncludeHiddenCells && !xDataSeries->hasUnhiddenData())
261 std::unique_ptr<VDataSeries> pSeries(
new VDataSeries(xDataSeries));
263 pSeries->setGlobalSeriesIndex(nGlobalSeriesIndex);
264 nGlobalSeriesIndex++;
267 pSeries->doSortByXValues();
269 pSeries->setConnectBars(bConnectBars);
270 pSeries->setGroupBarsPerAxis(bGroupBarsPerAxis);
271 pSeries->setStartingAngle(nStartingAngle);
273 pSeries->setMissingValueTreatment(nMissingValueTreatment);
276 pSeries->setParticle(aSeriesParticle);
280 pSeries->setRoleOfSequenceForDataLabelNumberFormatDetection(aRole);
285 || !bSecondaryYaxisVisible))
290 StackingDirection eDirection = pSeries->getStackingDirection();
293 case StackingDirection_NO_STACKING:
299 case StackingDirection_Y_STACKING:
306 case StackingDirection_Z_STACKING:
315 pPlotter->
addSeries(std::move(pSeries), zSlot, xSlot, ySlot);
325 bool bSeriesNamesInitialized =
false;
328 if (pVCooSys->needSeriesNamesForAxis())
330 if (!bSeriesNamesInitialized)
333 bSeriesNamesInitialized =
true;
335 pVCooSys->setSeriesNamesForAxis(aSeriesNames);
341 bool bHasComplexCategories)
346 if (rSourceScale.AxisType == AxisType::CATEGORY)
347 return bHasComplexCategories || rSourceScale.ShiftedCategoryPosition
350 if (rSourceScale.AxisType == AxisType::DATE)
351 return rSourceScale.ShiftedCategoryPosition;
353 return rSourceScale.AxisType == AxisType::SERIES;
365 sal_Int32
nDimCount = xCooSys->getDimension();
369 for (sal_Int32 nDimIndex = 0; nDimIndex <
nDimCount; ++nDimIndex)
375 const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
376 for (sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; ++nAxisIndex)
387 chart2::ScaleData aSourceScale = xAxis->getScaleData();
389 = pVCooSys->getExplicitCategoriesProvider();
394 && bComplexCategoryAllowed;
395 aSourceScale.ShiftedCategoryPosition
412 sal_Int32
nDimCount = xCooSys->getDimension();
414 for (sal_Int32 nDimIndex = 0; nDimIndex <
nDimCount; ++nDimIndex)
418 sal_Int32 nLocalMax = axisUsage.second.getMaxAxisIndexForDimension(nDimIndex);
440 for (sal_Int32 nI = 1; nI <= nMaxAxisIndex; nI++)
458 sal_Int32 nDimensionCount = xCooSys->getDimension();
459 for (sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount;
462 const sal_Int32 nMaximumAxisIndex
463 = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
464 for (sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaximumAxisIndex; ++nAxisIndex)
469 = xCooSys->getAxisByDimension2(nDimensionIndex, nAxisIndex);
472 sal_Int32 nNumberFormatKey(0);
474 >>= nNumberFormatKey)
476 aAxesNumberFormats.
setFormat(nNumberFormatKey, nDimensionIndex,
479 else if (nDimensionIndex == 0)
483 nDimensionIndex, nAxisIndex);
487 catch (
const lang::IndexOutOfBoundsException&)
500 nC->updateScalesAndIncrementsOnAxes();
510 for (sal_Int32 nAxisIndex = 0; nAxisIndex <=
m_nMaxAxisIndex; ++nAxisIndex)
516 rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 0, nAxisIndex);
517 rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 2, nAxisIndex);
521 rAxisUsage.aAutoScaling.calculateExplicitScaleAndIncrement(aExplicitScale,
524 rAxisUsage.setExplicitScaleAndIncrement(0, nAxisIndex, aExplicitScale,
526 rAxisUsage.setExplicitScaleAndIncrement(2, nAxisIndex, aExplicitScale,
534 rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 1, nAxisIndex);
538 rAxisUsage.aAutoScaling.calculateExplicitScaleAndIncrement(aExplicitScale,
541 rAxisUsage.setExplicitScaleAndIncrement(0, nAxisIndex, aExplicitScale,
543 rAxisUsage.setExplicitScaleAndIncrement(1, nAxisIndex, aExplicitScale,
545 rAxisUsage.setExplicitScaleAndIncrement(2, nAxisIndex, aExplicitScale,
555 for (sal_Int32 nAxisIndex = 0; nAxisIndex <=
m_nMaxAxisIndex; nAxisIndex++)
560 std::vector<VCoordinateSystem*> aVCooSysList_Y
561 = rAxisUsage.getCoordinateSystems(1, nAxisIndex);
562 if (aVCooSysList_Y.empty())
569 bool bSeriesAttachedToThisAxis =
false;
570 sal_Int32 nAttachedAxisIndex = -1;
572 std::vector<rtl::Reference<DataSeries>> aSeriesVector = xDiagram->getDataSeries();
573 for (
auto const& series : aSeriesVector)
576 if (nAxisIndex == nCurrentIndex)
578 bSeriesAttachedToThisAxis =
true;
581 else if (nAttachedAxisIndex < 0 || nAttachedAxisIndex > nCurrentIndex)
582 nAttachedAxisIndex = nCurrentIndex;
586 if (bSeriesAttachedToThisAxis || nAttachedAxisIndex < 0)
591 nC->prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 1, nAttachedAxisIndex);
594 = nC->getExplicitScale(1, nAttachedAxisIndex);
596 = nC->getExplicitIncrement(1, nAttachedAxisIndex);
600 = nC->getExplicitIncrement(1, nAxisIndex);
608 ScaleData aScale(rAxisUsage.aAutoScaling.getScale());
609 if (!aScale.Minimum.hasValue())
611 bool bNewMinOK =
true;
613 if (aScale.Maximum >>= fMax)
614 bNewMinOK = (aExplicitScaleSource.
Minimum <= fMax);
621 if (!aScale.Maximum.hasValue())
623 bool bNewMaxOK =
true;
625 if (aScale.Minimum >>= fMin)
626 bNewMaxOK = (fMin <= aExplicitScaleSource.
Maximum);
630 if (!aScale.Origin.hasValue())
631 aExplicitScaleDest.
Origin = aExplicitScaleSource.
Origin;
633 if (!aScale.IncrementData.Distance.hasValue())
636 bool bAutoMinorInterval =
true;
637 if (aScale.IncrementData.SubIncrements.hasElements())
639 = !(aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue());
640 if (bAutoMinorInterval)
648 nC->setExplicitScaleAndIncrement(1, nAxisIndex, aExplicitScaleDest,
649 aExplicitIncrementDest);
658 sal_Int32 nAxisIndex = 0;
659 sal_Int32 nDimensionIndex = 1;
663 std::vector<VCoordinateSystem*> aVCooSysList
664 = rAxisUsage.getCoordinateSystems(nDimensionIndex, nAxisIndex);
666 for (nC = 0; nC < aVCooSysList.size(); nC++)
669 aVCooSysList[nC]->getExplicitScale(nDimensionIndex, nAxisIndex));
671 aVCooSysList[nC]->getExplicitIncrement(nDimensionIndex, nAxisIndex));
678 if (xCrossingMainAxis.is())
680 css::chart::ChartAxisPosition eCrossingMainAxisPos(
681 css::chart::ChartAxisPosition_ZERO);
682 xCrossingMainAxis->getPropertyValue(
"CrossoverPosition") >>= eCrossingMainAxisPos;
683 if (eCrossingMainAxisPos == css::chart::ChartAxisPosition_VALUE)
686 xCrossingMainAxis->getPropertyValue(
"CrossoverValue") >>= fValue;
687 aExplicitScale.
Origin = fValue;
689 else if (eCrossingMainAxisPos == css::chart::ChartAxisPosition_ZERO)
690 aExplicitScale.
Origin = 0.0;
691 else if (eCrossingMainAxisPos == css::chart::ChartAxisPosition_START)
693 else if (eCrossingMainAxisPos == css::chart::ChartAxisPosition_END)
697 aVCooSysList[nC]->setExplicitScaleAndIncrement(nDimensionIndex, nAxisIndex,
698 aExplicitScale, aExplicitIncrement);
705 drawing::Direction3D aPreferredAspectRatio(1.0, 1.0, 1.0);
713 drawing::Direction3D aSingleRatio(aPlotter->getPreferredDiagramAspectRatio());
714 if (fx < 0 && aSingleRatio.DirectionX > 0)
715 fx = aSingleRatio.DirectionX;
717 if (fy < 0 && aSingleRatio.DirectionY > 0)
719 if (fx > 0 && aSingleRatio.DirectionX > 0)
720 fy = fx * aSingleRatio.DirectionY / aSingleRatio.DirectionX;
721 else if (fz > 0 && aSingleRatio.DirectionZ > 0)
722 fy = fz * aSingleRatio.DirectionY / aSingleRatio.DirectionZ;
724 fy = aSingleRatio.DirectionY;
727 if (fz < 0 && aSingleRatio.DirectionZ > 0)
729 if (fx > 0 && aSingleRatio.DirectionX > 0)
730 fz = fx * aSingleRatio.DirectionZ / aSingleRatio.DirectionX;
731 else if (fy > 0 && aSingleRatio.DirectionY > 0)
732 fz = fy * aSingleRatio.DirectionZ / aSingleRatio.DirectionY;
734 fz = aSingleRatio.DirectionZ;
737 if (fx > 0 && fy > 0 && fz > 0)
740 aPreferredAspectRatio = drawing::Direction3D(fx, fy, fz);
741 return aPreferredAspectRatio;
static rtl::Reference< ::chart::Axis > getCrossingMainAxis(const rtl::Reference< ::chart::Axis > &xAxis, const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSys)
static void checkDateAxis(css::chart2::ScaleData &rScale, ExplicitCategoriesProvider *pExplicitCategoriesProvider, bool bChartTypeAllowsDateAxis)
static rtl::Reference< ::chart::ChartType > getChartTypeByIndex(const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSys, sal_Int32 nIndex)
static bool isAxisPositioningEnabled()
This class handles a collection of coordinate systems and is used for executing some action on all co...
void addCoordinateSystem(VCoordinateSystem *pCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
static bool shiftCategoryPosAtXAxisPerDefault(const rtl::Reference< ::chart::ChartType > &xChartType)
static bool isSupportingDateAxis(const rtl::Reference< ::chart::ChartType > &xChartType, sal_Int32 nDimensionIndex)
static bool isSupportingComplexCategory(const rtl::Reference< ::chart::ChartType > &xChartType)
static OUString getRoleOfSequenceForDataLabelNumberFormatDetection(const rtl::Reference< ::chart::ChartType > &xChartType)
static bool isSupportingSecondaryAxis(const rtl::Reference< ::chart::ChartType > &xChartType, sal_Int32 nDimensionCount)
static sal_Int32 getDateNumberFormat(const css::uno::Reference< css::util::XNumberFormatsSupplier > &xNumberFormatsSupplier)
bool hasComplexCategories() const
static OUString createParticleForCoordinateSystem(const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSys, const rtl::Reference<::chart::ChartModel > &xChartModel)
static OUString createParticleForSeries(sal_Int32 nDiagramIndex, sal_Int32 nCooSysIndex, sal_Int32 nChartTypeIndex, sal_Int32 nSeriesIndex)
virtual void setScales(std::vector< ExplicitScaleData > &&rScales, bool bSwapXAndYAxis)
This class implements the calculation of automatic axis limits.
std::map< rtl::Reference< Axis >, AxisUsage > m_aAxisUsageList
A map whose key is a XAxis interface and the related value is an object of AxisUsage type.
std::vector< std::unique_ptr< VCoordinateSystem > > & m_rVCooSysList
A vector of coordinate systems.
static VCoordinateSystem * getCooSysForPlotter(const std::vector< std::unique_ptr< VCoordinateSystem > > &rVCooSysList, MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
css::drawing::Direction3D getPreferredAspectRatio()
bool isCategoryPositionShifted(const css::chart2::ScaleData &rSourceScale, bool bHasComplexCategories)
std::vector< LegendEntryProvider * > getLegendEntryProviderList()
static VCoordinateSystem * addCooSysToList(std::vector< std::unique_ptr< VCoordinateSystem > > &rVCooSysList, const rtl::Reference< BaseCoordinateSystem > &xCooSys, ChartModel &rChartModel)
void initAxisUsageList(const Date &rNullDate)
This method is invoked by ChartView::impl_createDiagramAndContent.
bool m_bForceShiftPosition
void AdaptScaleOfYAxisWithoutAttachedSeries(ChartModel &rModel)
void setNumberFormatsFromAxes()
sal_Int32 m_nDefaultDateNumberFormat
~SeriesPlotterContainer()
sal_Int32 m_nMaxAxisIndex
Max axis index of all dimensions.
static VCoordinateSystem * findInCooSysList(const std::vector< std::unique_ptr< VCoordinateSystem > > &rVCooSysList, const rtl::Reference< BaseCoordinateSystem > &xCooSys)
void doAutoScaling(ChartModel &rModel)
Perform automatic axis scaling and determine the amount and spacing of increments.
bool m_bChartTypeUsesShiftedCategoryPositionPerDefault
void initializeCooSysAndSeriesPlotter(ChartModel &rModel)
It is used to set coordinate systems (m_rVCooSysList), this method is invoked by ChartView::createSha...
void updateScalesAndIncrementsOnAxes()
After auto-scaling is performed, call this method to set the explicit scaling and increment data to a...
void setScalesFromCooSysToPlotter()
After auto-scaling is performed, call this method to set the explicit scaling data to all the plotter...
std::vector< std::unique_ptr< VSeriesPlotter > > m_aSeriesPlotterList
A vector of series plotters.
SeriesPlotterContainer(std::vector< std::unique_ptr< VCoordinateSystem > > &rVCooSysList)
ExplicitCategoriesProvider * getExplicitCategoriesProvider()
void addMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
sal_Int32 getMaximumAxisIndexByDimension(sal_Int32 nDimensionIndex) const
std::vector< ExplicitScaleData > getExplicitScales(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
ExplicitScaleData getExplicitScale(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
bool getPropertySwapXAndYAxis() const
static std::unique_ptr< VCoordinateSystem > createCoordinateSystem(const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSysModel)
const rtl::Reference< ::chart::BaseCoordinateSystem > & getModel() const
void addSecondaryValueScale(const ExplicitScaleData &rScale, sal_Int32 nAxisIndex)
this enables you to handle series on the same x axis with different y axis the property AttachedAxisI...
void setNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier > &xNumFmtSupplier)
static VSeriesPlotter * createSeriesPlotter(const rtl::Reference< ::chart::ChartType > &xChartTypeModel, sal_Int32 nDimensionCount, bool bExcludingPositioning)
virtual void addSeries(std::unique_ptr< VDataSeries > pSeries, sal_Int32 zSlot, sal_Int32 xSlot, sal_Int32 ySlot)
A new series can be positioned relative to other series in a chart.
void setColorScheme(const css::uno::Reference< css::chart2::XColorScheme > &xColorScheme)
void setExplicitCategoriesProvider(ExplicitCategoriesProvider *pExplicitCategoriesProvider)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
OOO_DLLPUBLIC_CHARTTOOLS sal_Int32 getAttachedAxisIndex(const rtl::Reference< ::chart::DataSeries > &xSeries)
@ PROP_PIECHARTTYPE_3DRELATIVEHEIGHT
const sal_Int32 MAIN_AXIS_INDEX
constexpr OUStringLiteral CHART2_SERVICE_NAME_CHARTTYPE_PIE
describes how tickmarks are positioned on the scale of an axis.
std::vector< ExplicitSubIncrement > SubIncrements
<member>SubIncrements</member> describes the positioning of further sub tickmarks on the scale of an ...
double Distance
the other members are for not date-time axis
double BaseValue
The <member>BaseValue</member> gives a starting point on the scale to which all further main tickmark...
This structure contains the explicit values for a scale like Minimum and Maximum.
css::uno::Reference< css::chart2::XScaling > Scaling
css::chart2::AxisOrientation Orientation
constexpr OUStringLiteral CHART_UNONAME_NUMFMT
constexpr OUStringLiteral CHART_UNONAME_SORT_BY_XVALUES