summaryrefslogtreecommitdiff
path: root/chart2/source/view/charttypes
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/view/charttypes')
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx42
-rw-r--r--chart2/source/view/charttypes/AreaChart.hxx15
-rw-r--r--chart2/source/view/charttypes/BarChart.cxx76
-rw-r--r--chart2/source/view/charttypes/BarChart.hxx18
-rw-r--r--chart2/source/view/charttypes/BarPositionHelper.cxx79
-rw-r--r--chart2/source/view/charttypes/BarPositionHelper.hxx19
-rw-r--r--chart2/source/view/charttypes/BubbleChart.cxx6
-rw-r--r--chart2/source/view/charttypes/BubbleChart.hxx8
-rw-r--r--chart2/source/view/charttypes/CandleStickChart.cxx107
-rw-r--r--chart2/source/view/charttypes/CandleStickChart.hxx15
-rw-r--r--chart2/source/view/charttypes/CategoryPositionHelper.cxx17
-rw-r--r--chart2/source/view/charttypes/CategoryPositionHelper.hxx5
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx10
-rw-r--r--chart2/source/view/charttypes/PieChart.hxx18
-rwxr-xr-x[-rw-r--r--]chart2/source/view/charttypes/VSeriesPlotter.cxx360
15 files changed, 428 insertions, 367 deletions
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 7a35c3926e37..9aaa6a242ab0 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -43,13 +43,16 @@
#include "Clipping.hxx"
#include "Stripe.hxx"
#include "PolarLabelPositionHelper.hxx"
+#include "DateHelper.hxx"
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <com/sun/star/chart/MissingValueTreatment.hpp>
+
#include <tools/debug.hxx>
#include <editeng/unoprnms.hxx>
#include <rtl/math.hxx>
+
#include <com/sun/star/drawing/DoubleSequence.hpp>
#include <com/sun/star/drawing/NormalsKind.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
@@ -96,6 +99,11 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel
{
if( !m_pMainPosHelper )
m_pMainPosHelper = new PlottingPositionHelper();
+ if( m_pMainPosHelper )
+ {
+ m_pMainPosHelper->AllowShiftXAxisPos(true);
+ m_pMainPosHelper->AllowShiftZAxisPos(true);
+ }
PlotterBase::m_pPosHelper = m_pMainPosHelper;
VSeriesPlotter::m_pMainPosHelper = m_pMainPosHelper;
@@ -121,18 +129,12 @@ AreaChart::~AreaChart()
delete m_pMainPosHelper;
}
-double AreaChart::getMinimumX()
-{
- if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling
- return 1.0;//first category (index 0) matches with real number 1.0
- return VSeriesPlotter::getMinimumX();
-}
-
double AreaChart::getMaximumX()
{
+ double fMax = VSeriesPlotter::getMaximumX();
if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling
- return getPointCount()+1;
- return VSeriesPlotter::getMaximumX();
+ fMax += 1.0;
+ return fMax;
}
bool AreaChart::isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex )
@@ -152,8 +154,8 @@ bool AreaChart::isSeperateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex
LegendSymbolStyle AreaChart::getLegendSymbolStyle()
{
if( m_bArea || m_nDimension == 3 )
- return chart2::LegendSymbolStyle_BOX;
- return chart2::LegendSymbolStyle_LINE_WITH_SYMBOL;
+ return LegendSymbolStyle_BOX;
+ return LegendSymbolStyle_LINE;
}
uno::Any AreaChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex )
@@ -169,6 +171,20 @@ uno::Any AreaChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPo
return aRet;
}
+//-----------------------------------------------------------------
+// lang::XServiceInfo
+//-----------------------------------------------------------------
+/*
+APPHELPER_XSERVICEINFO_IMPL(AreaChart,CHART2_VIEW_AREACHART_SERVICE_IMPLEMENTATION_NAME)
+
+ uno::Sequence< rtl::OUString > AreaChart
+::getSupportedServiceNames_Static()
+{
+ uno::Sequence< rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[ 0 ] = CHART2_VIEW_AREACHART_SERVICE_NAME;
+ return aSNS;
+}
+*/
drawing::Direction3D AreaChart::getPreferredDiagramAspectRatio() const
{
if( m_nKeepAspectRatio == 1 )
@@ -602,7 +618,7 @@ void AreaChart::createShapes()
//check necessary here that different Y axis can not be stacked in the same group? ... hm?
//update/create information for current group
- double fLogicZ = 0.5;//as defined
+ double fLogicZ = 1.0;//as defined
sal_Int32 nStartIndex = 0; // inclusive ;..todo get somehow from x scale
sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
@@ -703,6 +719,8 @@ void AreaChart::createShapes()
//collect data point information (logic coordinates, style ):
double fLogicX = (*aSeriesIter)->getXValue(nIndex);
+ if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() )
+ fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );
double fLogicY = (*aSeriesIter)->getYValue(nIndex);
if( m_bIsPolarCooSys && m_bArea &&
diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx
index c3bd1ed3fbb4..abd887319bc1 100644
--- a/chart2/source/view/charttypes/AreaChart.hxx
+++ b/chart2/source/view/charttypes/AreaChart.hxx
@@ -56,17 +56,7 @@ public:
);
virtual ~AreaChart();
- //-------------------------------------------------------------------------
- // chart2::XPlotter
- //-------------------------------------------------------------------------
-
- virtual void SAL_CALL createShapes();
- /*
- virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException);
- */
-
+ virtual void createShapes();
virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 );
//-------------------
@@ -76,14 +66,13 @@ public:
//-------------------------------------------------------------------------
// MinimumAndMaximumSupplier
//-------------------------------------------------------------------------
- virtual double getMinimumX();
virtual double getMaximumX();
virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex );
virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex );
//-------------------------------------------------------------------------
- virtual ::com::sun::star::chart2::LegendSymbolStyle getLegendSymbolStyle();
+ virtual LegendSymbolStyle getLegendSymbolStyle();
virtual ::com::sun::star::uno::Any getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex=-1/*-1 for series symbol*/ );
//-------------------------------------------------------------------------
diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index 036136384237..ad717a74b03c 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -39,6 +39,7 @@
#include "macros.hxx"
#include "AxisIndexDefines.hxx"
#include "Clipping.hxx"
+#include "DateHelper.hxx"
#include <com/sun/star/chart/DataLabelPlacement.hpp>
@@ -86,7 +87,6 @@ BarChart::~BarChart()
PlottingPositionHelper& BarChart::getPlottingPositionHelper( sal_Int32 nAxisIndex ) const
{
PlottingPositionHelper& rPosHelper = VSeriesPlotter::getPlottingPositionHelper( nAxisIndex );
-
BarPositionHelper* pBarPosHelper = dynamic_cast<BarPositionHelper*>(&rPosHelper);
if( pBarPosHelper && nAxisIndex >= 0 )
{
@@ -95,7 +95,6 @@ PlottingPositionHelper& BarChart::getPlottingPositionHelper( sal_Int32 nAxisInde
if( nAxisIndex < m_aGapwidthSequence.getLength() )
pBarPosHelper->setOuterDistance( m_aGapwidthSequence[nAxisIndex]/100.0 );
}
-
return rPosHelper;
}
@@ -113,7 +112,7 @@ drawing::Direction3D BarChart::getPreferredDiagramAspectRatio() const
if(!m_aZSlots.empty())
fXSlotCount = m_aZSlots.begin()->size();
- aRet.DirectionZ = aScale.DirectionZ/(aScale.DirectionX + aScale.DirectionX*(fXSlotCount-1.0)*pPosHelper->getSlotWidth());
+ aRet.DirectionZ = aScale.DirectionZ/(aScale.DirectionX + aScale.DirectionX*(fXSlotCount-1.0)*pPosHelper->getScaledSlotWidth());
}
else
return VSeriesPlotter::getPreferredDiagramAspectRatio();
@@ -141,27 +140,6 @@ bool BarChart::keepAspectRatio() const
return true;
}
-//-------------------------------------------------------------------------
-// MinimumAndMaximumSupplier
-//-------------------------------------------------------------------------
-
-double BarChart::getMinimumX()
-{
- if( m_bCategoryXAxis )
- return 0.5;//first category (index 0) matches with real number 1.0
- return VSeriesPlotter::getMinimumX();
-}
-double BarChart::getMaximumX()
-{
- if( m_bCategoryXAxis )
- {
- //return category count
- sal_Int32 nPointCount = getPointCount();
- return nPointCount+0.5;//first category (index 0) matches with real number 1.0
- }
- return VSeriesPlotter::getMaximumX();
-}
-
awt::Point BarChart::getLabelScreenPositionAndAlignment(
LabelAlignment& rAlignment, sal_Int32 nLabelPlacement
, double fScaledX, double fScaledLowerYValue, double fScaledUpperYValue, double fScaledZ
@@ -467,7 +445,7 @@ void BarChart::createShapes()
m_pShapeFactory->createGroup2D( m_xFinalTarget,rtl::OUString() ));
//check necessary here that different Y axis can not be stacked in the same group? ... hm?
- double fLogicZ = 0.0;//as defined
+ double fLogicZ = 1.0;//as defined
bool bDrawConnectionLines = false;
bool bDrawConnectionLinesInited = false;
@@ -482,12 +460,11 @@ void BarChart::createShapes()
sal_Int32 nCreatedPoints = 0;
//
- //(@todo maybe different iteration for breaks in axis ?)
- sal_Int32 nStartCategoryIndex = m_pMainPosHelper->getStartCategoryIndex(); // inclusive
- sal_Int32 nEndCategoryIndex = m_pMainPosHelper->getEndCategoryIndex(); //inclusive
+ sal_Int32 nStartIndex = 0;
+ sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
//=============================================================================
- //iterate through all shown categories
- for( sal_Int32 nCatIndex = nStartCategoryIndex; nCatIndex < nEndCategoryIndex; nCatIndex++ )
+ //iterate through all x values per indices
+ for( sal_Int32 nPointIndex = nStartIndex; nPointIndex < nEndIndex; nPointIndex++ )
{
::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
@@ -506,7 +483,7 @@ void BarChart::createShapes()
aLogicYSumMap[nAttachedAxisIndex]=0.0;
double fMinimumY = 0.0, fMaximumY = 0.0;
- aXSlotIter->calculateYMinAndMaxForCategory( nCatIndex
+ aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex
, isSeperateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex );
if( !::rtl::math::isNan( fMaximumY ) && fMaximumY > 0)
@@ -542,14 +519,14 @@ void BarChart::createShapes()
//update/create information for current group
pPosHelper->updateSeriesCount( aZSlotIter->size() );
- double fLogicBaseWidth = pPosHelper->getSlotWidth();
+ double fLogicBaseWidth = pPosHelper->getScaledSlotWidth();
::std::vector< VDataSeries* >* pSeriesList = &(aXSlotIter->m_aSeriesVector);
// get distance from base value to maximum and minimum
double fMinimumY = 0.0, fMaximumY = 0.0;
- aXSlotIter->calculateYMinAndMaxForCategory( nCatIndex
+ aXSlotIter->calculateYMinAndMaxForCategory( nPointIndex
, isSeperateStackingForDifferentSigns( 1 ), fMinimumY, fMaximumY, nAttachedAxisIndex );
double fLogicPositiveYSum = 0.0;
@@ -601,7 +578,7 @@ void BarChart::createShapes()
bOnlyConnectionLinesForThisPoint = false;
- if(nCatIndex==nStartCategoryIndex)//do not create a regression line for each point
+ if(nPointIndex==nStartIndex)//do not create a regression line for each point
createRegressionCurvesShapes( **aSeriesIter, xRegressionCurveTarget, xRegressionCurveEquationTarget,
m_pPosHelper->maySkipPointsInRegressionCalculation());
@@ -626,8 +603,17 @@ void BarChart::createShapes()
getSeriesGroupShape(*aSeriesIter, xSeriesTarget) );
//collect data point information (logic coordinates, style ):
- double fLogicX = pPosHelper->getSlotPos( (*aSeriesIter)->getXValue( nCatIndex ), fSlotX );
- double fLogicBarHeight = (*aSeriesIter)->getYValue( nCatIndex );
+ double fUnscaledLogicX = (*aSeriesIter)->getXValue( nPointIndex );
+ fUnscaledLogicX = DateHelper::RasterizeDateValue( fUnscaledLogicX, m_aNullDate, m_nTimeResolution );
+ if(fUnscaledLogicX<pPosHelper->getLogicMinX())
+ continue;//point not visible
+ if(fUnscaledLogicX>pPosHelper->getLogicMaxX())
+ continue;//point not visible
+ if(pPosHelper->isStrongLowerRequested(0) && fUnscaledLogicX==pPosHelper->getLogicMaxX())
+ continue;//point not visible
+ double fLogicX = pPosHelper->getScaledSlotPos( fUnscaledLogicX, fSlotX );
+
+ double fLogicBarHeight = (*aSeriesIter)->getYValue( nPointIndex );
if( ::rtl::math::isNan( fLogicBarHeight )) //no value at this category
continue;
@@ -652,9 +638,9 @@ void BarChart::createShapes()
fNegativeLogicYForNextSeries += fLogicBarHeight;
if(m_nDimension==3)
- fLogicZ = nZ;
+ fLogicZ = nZ+0.5;
- drawing::Position3D aUnscaledLogicPosition( fLogicX, fUpperYValue, fLogicZ );
+ drawing::Position3D aUnscaledLogicPosition( fUnscaledLogicX, fUpperYValue, fLogicZ );
//@todo ... start an iteration over the different breaks of the axis
//each subsystem may add an additional shape to form the whole point
@@ -664,7 +650,7 @@ void BarChart::createShapes()
// uno::Reference<drawing::XShape>( xPointGroupShape_Shapes, uno::UNO_QUERY );
//as long as we do not iterate we do not need to create an additional group for each point
uno::Reference< drawing::XShapes > xPointGroupShape_Shapes = xSeriesGroupShape_Shapes;
- uno::Reference< beans::XPropertySet > xDataPointProperties( (*aSeriesIter)->getPropertiesOfPoint( nCatIndex ) );
+ uno::Reference< beans::XPropertySet > xDataPointProperties( (*aSeriesIter)->getPropertiesOfPoint( nPointIndex ) );
sal_Int32 nGeometry3D = DataPointGeometry3D::CUBOID;
if(m_nDimension==3) try
{
@@ -731,7 +717,7 @@ void BarChart::createShapes()
//better performance for big data
FormerBarPoint aFormerPoint( aSeriesFormerPointMap[pSeries] );
pPosHelper->setCoordinateSystemResolution( m_aCoordinateSystemResolution );
- if( !pSeries->isAttributedDataPoint(nCatIndex)
+ if( !pSeries->isAttributedDataPoint(nPointIndex)
&&
pPosHelper->isSameForGivenResolution( aFormerPoint.m_fX, aFormerPoint.m_fUpperY, aFormerPoint.m_fZ
, fLogicX, fUpperYValue, fLogicZ )
@@ -830,20 +816,20 @@ void BarChart::createShapes()
//set name/classified ObjectID (CID)
ShapeFactory::setShapeName(xShape
, ObjectIdentifier::createPointCID(
- (*aSeriesIter)->getPointCID_Stub(),nCatIndex) );
+ (*aSeriesIter)->getPointCID_Stub(),nPointIndex) );
}
//create error bar
- createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nCatIndex, m_xLogicTarget );
+ createErrorBar_Y( aUnscaledLogicPosition, **aSeriesIter, nPointIndex, m_xLogicTarget, &fLogicX );
//------------
//create data point label
- if( (**aSeriesIter).getDataPointLabelIfLabel(nCatIndex) )
+ if( (**aSeriesIter).getDataPointLabelIfLabel(nPointIndex) )
{
double fLogicSum = aLogicYSumMap[nAttachedAxisIndex];
LabelAlignment eAlignment(LABEL_ALIGN_CENTER);
- sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nCatIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() );
+ sal_Int32 nLabelPlacement = pSeries->getLabelPlacement( nPointIndex, m_xChartTypeModel, m_nDimension, pPosHelper->isSwapXAndY() );
double fLowerBarDepth = fLogicBarDepth;
double fUpperBarDepth = fLogicBarDepth;
@@ -868,7 +854,7 @@ void BarChart::createShapes()
if( m_nDimension == 3 )
nOffset = 260;
}
- this->createDataLabel( xTextTarget, **aSeriesIter, nCatIndex
+ this->createDataLabel( xTextTarget, **aSeriesIter, nPointIndex
, fLogicValueForLabeDisplay, fLogicSum, aScreenPosition2D, eAlignment, nOffset );
}
diff --git a/chart2/source/view/charttypes/BarChart.hxx b/chart2/source/view/charttypes/BarChart.hxx
index cfd3c0e618ce..93816beb33ae 100644
--- a/chart2/source/view/charttypes/BarChart.hxx
+++ b/chart2/source/view/charttypes/BarChart.hxx
@@ -48,17 +48,7 @@ public:
, sal_Int32 nDimensionCount );
virtual ~BarChart();
- //-------------------------------------------------------------------------
- // chart2::XPlotter
- //-------------------------------------------------------------------------
-
- virtual void SAL_CALL createShapes();
- /*
- virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException);
- */
-
+ virtual void createShapes();
virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 );
//-------------------
@@ -66,12 +56,6 @@ public:
virtual bool keepAspectRatio() const;
//-------------------------------------------------------------------------
- // MinimumAndMaximumSupplier
- //-------------------------------------------------------------------------
- virtual double getMinimumX();
- virtual double getMaximumX();
-
- //-------------------------------------------------------------------------
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
diff --git a/chart2/source/view/charttypes/BarPositionHelper.cxx b/chart2/source/view/charttypes/BarPositionHelper.cxx
index 271e0c5dd636..2cf585ba0097 100644
--- a/chart2/source/view/charttypes/BarPositionHelper.cxx
+++ b/chart2/source/view/charttypes/BarPositionHelper.cxx
@@ -33,6 +33,8 @@
#include "Linear3DTransformation.hxx"
#include "ViewDefines.hxx"
#include "CommonConverters.hxx"
+#include "DateHelper.hxx"
+#include <com/sun/star/chart/TimeUnit.hpp>
//.............................................................................
namespace chart
@@ -44,6 +46,8 @@ using namespace ::com::sun::star::chart2;
BarPositionHelper::BarPositionHelper( bool /* bSwapXAndY */ )
: CategoryPositionHelper( 1 )
{
+ AllowShiftXAxisPos(true);
+ AllowShiftZAxisPos(true);
}
BarPositionHelper::BarPositionHelper( const BarPositionHelper& rSource )
@@ -67,73 +71,22 @@ void BarPositionHelper::updateSeriesCount( double fSeriesCount )
m_fSeriesCount = fSeriesCount;
}
-uno::Reference< XTransformation > BarPositionHelper::getTransformationScaledLogicToScene() const
+double BarPositionHelper::getScaledSlotPos( double fUnscaledLogicX, double fSeriesNumber ) const
{
- //transformation from 2) to 4) //@todo 2) and 4) need a link to a document
+ if( m_bDateAxis )
+ fUnscaledLogicX = DateHelper::RasterizeDateValue( fUnscaledLogicX, m_aNullDate, m_nTimeResolution );
+ double fScaledLogicX(fUnscaledLogicX);
+ doLogicScaling(&fScaledLogicX,NULL,NULL);
+ fScaledLogicX = CategoryPositionHelper::getScaledSlotPos( fScaledLogicX, fSeriesNumber );
+ return fScaledLogicX;
- //we need to apply this transformation to each geometric object because of a bug/problem
- //of the old drawing layer (the UNO_NAME_3D_EXTRUDE_DEPTH is an integer value instead of an double )
-
- if( !m_xTransformationLogicToScene.is() )
- {
- ::basegfx::B3DHomMatrix aMatrix;
-
- double MinX = getLogicMinX();
- double MinY = getLogicMinY();
- double MinZ = getLogicMinZ();
- double MaxX = getLogicMaxX();
- double MaxY = getLogicMaxY();
- double MaxZ = getLogicMaxZ();
-
- AxisOrientation nXAxisOrientation = m_aScales[0].Orientation;
- AxisOrientation nYAxisOrientation = m_aScales[1].Orientation;
- AxisOrientation nZAxisOrientation = m_aScales[2].Orientation;
-
- //apply scaling
- //scaling of x axis is refused/ignored
- doLogicScaling( NULL, &MinY, &MinZ );
- doLogicScaling( NULL, &MaxY, &MaxZ);
-
- if(m_bSwapXAndY)
- {
- std::swap(MinX,MinY);
- std::swap(MaxX,MaxY);
- std::swap(nXAxisOrientation,nYAxisOrientation);
- }
-
- if( AxisOrientation_MATHEMATICAL==nXAxisOrientation )
- aMatrix.translate(-MinX,0.0,0.0);
- else
- aMatrix.translate(-MaxX,0.0,0.0);
- if( AxisOrientation_MATHEMATICAL==nYAxisOrientation )
- aMatrix.translate(0.0,-MinY,0.0);
- else
- aMatrix.translate(0.0,-MaxY,0.0);
- if( AxisOrientation_MATHEMATICAL==nZAxisOrientation )
- aMatrix.translate(0.0,0.0,-MaxZ);//z direction in draw is reverse mathematical direction
- else
- aMatrix.translate(0.0,0.0,-MinZ);
-
- double fWidthX = MaxX - MinX;
- double fWidthY = MaxY - MinY;
- double fWidthZ = MaxZ - MinZ;
-
- double fScaleDirectionX = AxisOrientation_MATHEMATICAL==nXAxisOrientation ? 1.0 : -1.0;
- double fScaleDirectionY = AxisOrientation_MATHEMATICAL==nYAxisOrientation ? 1.0 : -1.0;
- double fScaleDirectionZ = AxisOrientation_MATHEMATICAL==nZAxisOrientation ? -1.0 : 1.0;
-
- aMatrix.scale(fScaleDirectionX*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthX
- , fScaleDirectionY*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthY
- , fScaleDirectionZ*FIXED_SIZE_FOR_3D_CHART_VOLUME/fWidthZ);
-
- //if(nDim==2)
- aMatrix = m_aMatrixScreenToScene*aMatrix;
-
- m_xTransformationLogicToScene = new Linear3DTransformation(B3DHomMatrixToHomogenMatrix( aMatrix ),m_bSwapXAndY);
- }
- return m_xTransformationLogicToScene;
}
+void BarPositionHelper::setScaledCategoryWidth( double fScaledCategoryWidth )
+{
+ m_fScaledCategoryWidth = fScaledCategoryWidth;
+ CategoryPositionHelper::setCategoryWidth( m_fScaledCategoryWidth );
+}
//.............................................................................
} //namespace chart
//.............................................................................
diff --git a/chart2/source/view/charttypes/BarPositionHelper.hxx b/chart2/source/view/charttypes/BarPositionHelper.hxx
index 293a277cd332..515421957b31 100644
--- a/chart2/source/view/charttypes/BarPositionHelper.hxx
+++ b/chart2/source/view/charttypes/BarPositionHelper.hxx
@@ -50,25 +50,10 @@ public:
virtual PlottingPositionHelper* clone() const;
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >
- getTransformationScaledLogicToScene() const;
-
void updateSeriesCount( double fSeriesCount ); /*only enter the size of x stacked series*/
- sal_Int32 getStartCategoryIndex() const {
- //first category (index 0) matches with real number 1.0
- sal_Int32 nStart = static_cast<sal_Int32>(getLogicMinX() - 0.5);
- if( nStart < 0 )
- nStart = 0;
- return nStart;
- }
- sal_Int32 getEndCategoryIndex() const {
- //first category (index 0) matches with real number 1.0
- sal_Int32 nEnd = static_cast<sal_Int32>(getLogicMaxX() - 0.5);
- if( nEnd < 0 )
- nEnd = 0;
- return nEnd;
- }
+ virtual double getScaledSlotPos( double fCategoryX, double fSeriesNumber ) const;
+ virtual void setScaledCategoryWidth( double fScaledCategoryWidth );
};
//.............................................................................
diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx
index 4c35fc1dd870..0d6b3778740e 100644
--- a/chart2/source/view/charttypes/BubbleChart.cxx
+++ b/chart2/source/view/charttypes/BubbleChart.cxx
@@ -122,7 +122,7 @@ void BubbleChart::calculateMaximumLogicBubbleSize()
void BubbleChart::calculateBubbleSizeScalingFactor()
{
- double fLogicZ=0.5;
+ double fLogicZ=1.0;
drawing::Position3D aSceneMinPos( m_pMainPosHelper->transformLogicToScene( m_pMainPosHelper->getLogicMinX(),m_pMainPosHelper->getLogicMinY(),fLogicZ, false ) );
drawing::Position3D aSceneMaxPos( m_pMainPosHelper->transformLogicToScene( m_pMainPosHelper->getLogicMaxX(),m_pMainPosHelper->getLogicMaxY(),fLogicZ, false ) );
@@ -176,7 +176,7 @@ bool BubbleChart::isSeperateStackingForDifferentSigns( sal_Int32 /*nDimensionInd
LegendSymbolStyle BubbleChart::getLegendSymbolStyle()
{
- return chart2::LegendSymbolStyle_CIRCLE;
+ return LegendSymbolStyle_CIRCLE;
}
drawing::Direction3D BubbleChart::getPreferredDiagramAspectRatio() const
@@ -224,7 +224,7 @@ void BubbleChart::createShapes()
m_pShapeFactory->createGroup2D( m_xFinalTarget,rtl::OUString() ));
//update/create information for current group
- double fLogicZ = 0.5;//as defined
+ double fLogicZ = 1.0;//as defined
sal_Int32 nStartIndex = 0; // inclusive ;..todo get somehow from x scale
sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
diff --git a/chart2/source/view/charttypes/BubbleChart.hxx b/chart2/source/view/charttypes/BubbleChart.hxx
index 2216d6499f7a..2698501182c2 100644
--- a/chart2/source/view/charttypes/BubbleChart.hxx
+++ b/chart2/source/view/charttypes/BubbleChart.hxx
@@ -47,11 +47,7 @@ public:
, sal_Int32 nDimensionCount );
virtual ~BubbleChart();
- //-------------------------------------------------------------------------
- // chart2::XPlotter
- //-------------------------------------------------------------------------
-
- virtual void SAL_CALL createShapes();
+ virtual void createShapes();
virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 );
@@ -66,7 +62,7 @@ public:
//-------------------------------------------------------------------------
- virtual ::com::sun::star::chart2::LegendSymbolStyle getLegendSymbolStyle();
+ virtual LegendSymbolStyle getLegendSymbolStyle();
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx
index 971545c98415..32553a134f5d 100644
--- a/chart2/source/view/charttypes/CandleStickChart.cxx
+++ b/chart2/source/view/charttypes/CandleStickChart.cxx
@@ -39,6 +39,7 @@
#include "VLegendSymbolFactory.hxx"
#include "FormattedStringHelper.hxx"
#include "DataSeriesHelper.hxx"
+#include "DateHelper.hxx"
#include <tools/debug.hxx>
#include <rtl/math.hxx>
#include <editeng/unoprnms.hxx>
@@ -75,22 +76,6 @@ CandleStickChart::~CandleStickChart()
// MinimumAndMaximumSupplier
//-------------------------------------------------------------------------
-double CandleStickChart::getMinimumX()
-{
- if( m_bCategoryXAxis )
- return 0.5;//first category (index 0) matches with real number 1.0
- return VSeriesPlotter::getMinimumX();
-}
-double CandleStickChart::getMaximumX()
-{
- if( m_bCategoryXAxis )
- {
- //return category count
- sal_Int32 nPointCount = getPointCount();
- return nPointCount+0.5;//first category (index 0) matches with real number 1.0
- }
- return VSeriesPlotter::getMaximumX();
-}
bool CandleStickChart::isSeperateStackingForDifferentSigns( sal_Int32 /* nDimensionIndex */ )
{
return false;
@@ -102,8 +87,23 @@ bool CandleStickChart::isSeperateStackingForDifferentSigns( sal_Int32 /* nDimens
LegendSymbolStyle CandleStickChart::getLegendSymbolStyle()
{
- return chart2::LegendSymbolStyle_VERTICAL_LINE;
+ return LegendSymbolStyle_LINE;
+}
+
+//-----------------------------------------------------------------
+// lang::XServiceInfo
+//-----------------------------------------------------------------
+/*
+APPHELPER_XSERVICEINFO_IMPL(CandleStickChart,CHART2_VIEW_CANDLESTICKCHART_SERVICE_IMPLEMENTATION_NAME)
+
+ uno::Sequence< rtl::OUString > CandleStickChart
+::getSupportedServiceNames_Static()
+{
+ uno::Sequence< rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[ 0 ] = CHART2_VIEW_CANDLESTICKCHART_SERVICE_NAME;
+ return aSNS;
}
+*/
drawing::Direction3D CandleStickChart::getPreferredDiagramAspectRatio() const
{
@@ -177,11 +177,12 @@ void CandleStickChart::createShapes()
}
//(@todo maybe different iteration for breaks in axis ?)
- sal_Int32 nStartCategoryIndex = m_pMainPosHelper->getStartCategoryIndex(); // inclusive
- sal_Int32 nEndCategoryIndex = m_pMainPosHelper->getEndCategoryIndex(); //inclusive
+ sal_Int32 nStartIndex = 0;
+ sal_Int32 nEndIndex = VSeriesPlotter::getPointCount();
+ double fLogicZ = 1.5;//as defined
//=============================================================================
- //iterate through all shown categories
- for( sal_Int32 nIndex = nStartCategoryIndex; nIndex < nEndCategoryIndex; nIndex++ )
+ //iterate through all x values per indices
+ for( sal_Int32 nIndex = nStartIndex; nIndex < nEndIndex; nIndex++ )
{
::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
@@ -219,28 +220,48 @@ void CandleStickChart::createShapes()
for( ; aSeriesIter != aSeriesEnd; aSeriesIter++ )
{
//collect data point information (logic coordinates, style ):
- double fLogicX = pPosHelper->getSlotPos( (*aSeriesIter)->getXValue( nIndex ), fSlotX );
- double fY_First = (*aSeriesIter)->getY_First( nIndex );
- double fY_Last = (*aSeriesIter)->getY_Last( nIndex );
- double fY_Min = (*aSeriesIter)->getY_Min( nIndex );
- double fY_Max = (*aSeriesIter)->getY_Max( nIndex );
+ double fUnscaledX = (*aSeriesIter)->getXValue( nIndex );
+ if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() )
+ fUnscaledX = DateHelper::RasterizeDateValue( fUnscaledX, m_aNullDate, m_nTimeResolution );
+ if(fUnscaledX<pPosHelper->getLogicMinX() || fUnscaledX>pPosHelper->getLogicMaxX())
+ continue;//point not visible
+ double fScaledX = pPosHelper->getScaledSlotPos( fUnscaledX, fSlotX );
+
+ double fUnscaledY_First = (*aSeriesIter)->getY_First( nIndex );
+ double fUnscaledY_Last = (*aSeriesIter)->getY_Last( nIndex );
+ double fUnscaledY_Min = (*aSeriesIter)->getY_Min( nIndex );
+ double fUnscaledY_Max = (*aSeriesIter)->getY_Max( nIndex );
bool bBlack=false;
- if(fY_Last<=fY_First)
+ if(fUnscaledY_Last<=fUnscaledY_First)
{
- std::swap(fY_First,fY_Last);
+ std::swap(fUnscaledY_First,fUnscaledY_Last);
bBlack=true;
}
- if(fY_Max<fY_Min)
- std::swap(fY_Min,fY_Max);
+ if(fUnscaledY_Max<fUnscaledY_Min)
+ std::swap(fUnscaledY_Min,fUnscaledY_Max);
//transformation 3) -> 4)
- double fHalfWidth = pPosHelper->getSlotWidth()/2.0;
- drawing::Position3D aPosLeftFirst( pPosHelper->transformLogicToScene( fLogicX-fHalfWidth, fY_First ,0 ,true ) );
- drawing::Position3D aPosRightLast( pPosHelper->transformLogicToScene( fLogicX+fHalfWidth, fY_Last ,0 ,true ) );
- drawing::Position3D aPosMiddleFirst( pPosHelper->transformLogicToScene( fLogicX, fY_First ,0 ,true ) );
- drawing::Position3D aPosMiddleLast( pPosHelper->transformLogicToScene( fLogicX, fY_Last ,0 ,true ) );
- drawing::Position3D aPosMiddleMinimum( pPosHelper->transformLogicToScene( fLogicX, fY_Min ,0 ,true ) );
- drawing::Position3D aPosMiddleMaximum( pPosHelper->transformLogicToScene( fLogicX, fY_Max ,0 ,true ) );
+ double fHalfScaledWidth = pPosHelper->getScaledSlotWidth()/2.0;
+
+ double fScaledY_First(fUnscaledY_First);
+ double fScaledY_Last(fUnscaledY_Last);
+ double fScaledY_Min(fUnscaledY_Min);
+ double fScaledY_Max(fUnscaledY_Max);
+ pPosHelper->clipLogicValues( 0,&fScaledY_First,0 );
+ pPosHelper->clipLogicValues( 0,&fScaledY_Last,0 );
+ pPosHelper->clipLogicValues( 0,&fScaledY_Min,0 );
+ pPosHelper->clipLogicValues( 0,&fScaledY_Max,0 );
+ pPosHelper->doLogicScaling( 0,&fScaledY_First,0 );
+ pPosHelper->doLogicScaling( 0,&fScaledY_Last,0 );
+ pPosHelper->doLogicScaling( 0,&fScaledY_Min,0 );
+ pPosHelper->doLogicScaling( 0,&fScaledY_Max,0 );
+
+ drawing::Position3D aPosLeftFirst( pPosHelper->transformScaledLogicToScene( fScaledX-fHalfScaledWidth, fScaledY_First ,0 ,true ) );
+ drawing::Position3D aPosRightLast( pPosHelper->transformScaledLogicToScene( fScaledX+fHalfScaledWidth, fScaledY_Last ,0 ,true ) );
+ drawing::Position3D aPosMiddleFirst( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_First ,0 ,true ) );
+ drawing::Position3D aPosMiddleLast( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Last ,0 ,true ) );
+ drawing::Position3D aPosMiddleMinimum( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Min ,0 ,true ) );
+ drawing::Position3D aPosMiddleMaximum( pPosHelper->transformScaledLogicToScene( fScaledX, fScaledY_Max ,0 ,true ) );
uno::Reference< drawing::XShapes > xLossGainTarget( xGainTarget );
if(bBlack)
@@ -301,13 +322,13 @@ void CandleStickChart::createShapes()
drawing::PolyPolygonShape3D aPoly;
sal_Int32 nLineIndex = 0;
- if( bShowFirst && pPosHelper->isLogicVisible( fLogicX, fY_First ,0 )
+ if( bShowFirst && pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_First ,fLogicZ )
&& isValidPosition(aPosLeftFirst) && isValidPosition(aPosMiddleFirst) )
{
AddPointToPoly( aPoly, aPosLeftFirst, nLineIndex );
AddPointToPoly( aPoly, aPosMiddleFirst, nLineIndex++ );
}
- if( pPosHelper->isLogicVisible( fLogicX, fY_Last ,0 )
+ if( pPosHelper->isLogicVisible( fUnscaledX, fUnscaledY_Last ,fLogicZ )
&& isValidPosition(aPosMiddleLast) && isValidPosition(aPosRightLast) )
{
AddPointToPoly( aPoly, aPosMiddleLast, nLineIndex );
@@ -333,16 +354,16 @@ void CandleStickChart::createShapes()
{
if(isValidPosition(aPosMiddleFirst))
this->createDataLabel( xTextTarget, **aSeriesIter, nIndex
- , fY_First, 1.0, Position3DToAWTPoint(aPosMiddleFirst), LABEL_ALIGN_LEFT_BOTTOM );
+ , fUnscaledY_First, 1.0, Position3DToAWTPoint(aPosMiddleFirst), LABEL_ALIGN_LEFT_BOTTOM );
if(isValidPosition(aPosMiddleLast))
this->createDataLabel( xTextTarget, **aSeriesIter, nIndex
- , fY_Last, 1.0, Position3DToAWTPoint(aPosMiddleLast), LABEL_ALIGN_RIGHT_TOP );
+ , fUnscaledY_Last, 1.0, Position3DToAWTPoint(aPosMiddleLast), LABEL_ALIGN_RIGHT_TOP );
if(isValidPosition(aPosMiddleMinimum))
this->createDataLabel( xTextTarget, **aSeriesIter, nIndex
- , fY_Min, 1.0, Position3DToAWTPoint(aPosMiddleMinimum), LABEL_ALIGN_BOTTOM );
+ , fUnscaledY_Min, 1.0, Position3DToAWTPoint(aPosMiddleMinimum), LABEL_ALIGN_BOTTOM );
if(isValidPosition(aPosMiddleMaximum))
this->createDataLabel( xTextTarget, **aSeriesIter, nIndex
- , fY_Max, 1.0, Position3DToAWTPoint(aPosMiddleMaximum), LABEL_ALIGN_TOP );
+ , fUnscaledY_Max, 1.0, Position3DToAWTPoint(aPosMiddleMaximum), LABEL_ALIGN_TOP );
}
}//next series in x slot (next y slot)
}//next x slot
diff --git a/chart2/source/view/charttypes/CandleStickChart.hxx b/chart2/source/view/charttypes/CandleStickChart.hxx
index cd33e54af5e9..c8ef4b9a8db0 100644
--- a/chart2/source/view/charttypes/CandleStickChart.hxx
+++ b/chart2/source/view/charttypes/CandleStickChart.hxx
@@ -48,16 +48,7 @@ public:
, sal_Int32 nDimensionCount );
virtual ~CandleStickChart();
- //-------------------------------------------------------------------------
- // chart2::XPlotter
- //-------------------------------------------------------------------------
-
- virtual void SAL_CALL createShapes();
- /*
- virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException);
- */
+ virtual void createShapes();
virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 );
virtual ::com::sun::star::drawing::Direction3D getPreferredDiagramAspectRatio() const;
@@ -65,13 +56,11 @@ public:
//-------------------------------------------------------------------------
// MinimumAndMaximumSupplier
//-------------------------------------------------------------------------
- virtual double getMinimumX();
- virtual double getMaximumX();
virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex );
//-------------------------------------------------------------------------
- virtual ::com::sun::star::chart2::LegendSymbolStyle getLegendSymbolStyle();
+ virtual LegendSymbolStyle getLegendSymbolStyle();
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
diff --git a/chart2/source/view/charttypes/CategoryPositionHelper.cxx b/chart2/source/view/charttypes/CategoryPositionHelper.cxx
index c4df135927eb..cc4f917d0515 100644
--- a/chart2/source/view/charttypes/CategoryPositionHelper.cxx
+++ b/chart2/source/view/charttypes/CategoryPositionHelper.cxx
@@ -56,7 +56,7 @@ CategoryPositionHelper::~CategoryPositionHelper()
{
}
-double CategoryPositionHelper::getSlotWidth() const
+double CategoryPositionHelper::getScaledSlotWidth() const
{
double fWidth = m_fCategoryWidth /
( m_fSeriesCount
@@ -65,14 +65,14 @@ double CategoryPositionHelper::getSlotWidth() const
return fWidth;
}
-double CategoryPositionHelper::getSlotPos( double fCategoryX, double fSeriesNumber ) const
+double CategoryPositionHelper::getScaledSlotPos( double fScaledXPos, double fSeriesNumber ) const
{
//the returned position is in the middle of the rect
//fSeriesNumber 0...n-1
- double fPos = fCategoryX - (m_fCategoryWidth/2.0)
- + (m_fOuterDistance/2.0 + fSeriesNumber*(1.0+m_fInnerDistance)) * getSlotWidth()
- + getSlotWidth()/2.0;
-
+ double fPos = fScaledXPos
+ - (m_fCategoryWidth/2.0)
+ + (m_fOuterDistance/2.0 + fSeriesNumber*(1.0+m_fInnerDistance)) * getScaledSlotWidth()
+ + getScaledSlotWidth()/2.0;
return fPos;
}
@@ -94,6 +94,11 @@ void CategoryPositionHelper::setOuterDistance( double fOuterDistance )
m_fOuterDistance = fOuterDistance;
}
+void CategoryPositionHelper::setCategoryWidth( double fCategoryWidth )
+{
+ m_fCategoryWidth = fCategoryWidth;
+}
+
//.............................................................................
} //namespace chart
//.............................................................................
diff --git a/chart2/source/view/charttypes/CategoryPositionHelper.hxx b/chart2/source/view/charttypes/CategoryPositionHelper.hxx
index c48fbf98b150..63b3e6c56812 100644
--- a/chart2/source/view/charttypes/CategoryPositionHelper.hxx
+++ b/chart2/source/view/charttypes/CategoryPositionHelper.hxx
@@ -45,8 +45,9 @@ public:
CategoryPositionHelper( const CategoryPositionHelper& rSource );
virtual ~CategoryPositionHelper();
- double getSlotWidth() const;
- double getSlotPos( double fCategoryX, double fSeriesNumber ) const;
+ double getScaledSlotWidth() const;
+ virtual double getScaledSlotPos( double fCategoryX, double fSeriesNumber ) const;
+ virtual void setCategoryWidth( double fCategoryWidth );
//Distance between two neighboring bars in same category, seen relative to width of the bar
void setInnerDistance( double fInnerDistance );
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 8a618cdfeeb7..91c35c88c690 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -158,11 +158,9 @@ PieChart::~PieChart()
//-----------------------------------------------------------------
-void SAL_CALL PieChart::setScales( const uno::Sequence< ExplicitScaleData >& rScales
- , sal_Bool /* bSwapXAndYAxis */ )
- throw (uno::RuntimeException)
+void PieChart::setScales( const std::vector< ExplicitScaleData >& rScales, bool /* bSwapXAndYAxis */ )
{
- DBG_ASSERT(m_nDimension<=rScales.getLength(),"Dimension of Plotter does not fit two dimension of given scale sequence");
+ DBG_ASSERT(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
m_pPosHelper->setScales( rScales, true );
}
@@ -478,11 +476,11 @@ void PieChart::createShapes()
awt::Point aScreenPosition2D(
aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, nLabelPlacement
, fUnitCircleStartAngleDegree, fUnitCircleWidthAngleDegree
- , fUnitCircleInnerRadius, fUnitCircleOuterRadius, 0.0, 0 ));
+ , fUnitCircleInnerRadius, fUnitCircleOuterRadius, fLogicZ+0.5, 0 ));
PieLabelInfo aPieLabelInfo;
aPieLabelInfo.aFirstPosition = basegfx::B2IVector( aScreenPosition2D.X, aScreenPosition2D.Y );
- awt::Point aOrigin( aPolarPosHelper.transformSceneToScreenPosition( m_pPosHelper->transformUnitCircleToScene( 0.0, 0.0, 0.5 ) ) );
+ awt::Point aOrigin( aPolarPosHelper.transformSceneToScreenPosition( m_pPosHelper->transformUnitCircleToScene( 0.0, 0.0, fLogicZ+1.0 ) ) );
aPieLabelInfo.aOrigin = basegfx::B2IVector( aOrigin.X, aOrigin.Y );
//add a scaling independent Offset if requested
diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx
index 3f2443732899..ae08136b4031 100644
--- a/chart2/source/view/charttypes/PieChart.hxx
+++ b/chart2/source/view/charttypes/PieChart.hxx
@@ -50,24 +50,10 @@ public:
, sal_Int32 nDimensionCount, bool bExcludingPositioning );
virtual ~PieChart();
- //-------------------------------------------------------------------------
- // chart2::XPlotter
- //-------------------------------------------------------------------------
-
- virtual void SAL_CALL createShapes();
+ virtual void createShapes();
virtual void rearrangeLabelToAvoidOverlapIfRequested( const ::com::sun::star::awt::Size& rPageSize );
- virtual void SAL_CALL setScales(
- const ::com::sun::star::uno::Sequence<
- ::com::sun::star::chart2::ExplicitScaleData >& rScales
- , sal_Bool bSwapXAndYAxis )
- throw (::com::sun::star::uno::RuntimeException);
- /*
- virtual ::rtl::OUString SAL_CALL getCoordinateSystemTypeID( ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setScales( const ::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData >& rScales ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setTransformation( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToLogicTarget, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTransformation >& xTransformationToFinalPage ) throw (::com::sun::star::uno::RuntimeException);
- */
-
+ virtual void setScales( const ::std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis );
virtual void addSeries( VDataSeries* pSeries, sal_Int32 zSlot = -1, sal_Int32 xSlot = -1,sal_Int32 ySlot = -1 );
//-------------------
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 258b85c82e83..1b8783de2549 100644..100755
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -44,7 +44,7 @@
#include "ChartTypeHelper.hxx"
#include "Clipping.hxx"
#include "servicenames_charttypes.hxx"
-#include "chartview/NumberFormatterWrapper.hxx"
+#include "NumberFormatterWrapper.hxx"
#include "ContainerHelper.hxx"
#include "DataSeriesHelper.hxx"
#include "RegressionCurveHelper.hxx"
@@ -53,6 +53,8 @@
#include "ResId.hxx"
#include "Strings.hrc"
#include "RelativePositionHelper.hxx"
+#include "DateHelper.hxx"
+#include "DiagramHelper.hxx"
//only for creation: @todo remove if all plotter are uno components and instanciated via servicefactory
#include "BarChart.hxx"
@@ -63,6 +65,7 @@
//
#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/chart/TimeUnit.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
@@ -73,6 +76,7 @@
#include <rtl/math.hxx>
#include <tools/debug.hxx>
#include <basegfx/vector/b2dvector.hxx>
+#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <svx/unoshape.hxx>
@@ -103,7 +107,6 @@ VDataSeriesGroup::VDataSeriesGroup()
, m_bMaxPointCountDirty(true)
, m_nMaxPointCount(0)
, m_aListOfCachedYValues()
-
{
}
@@ -152,6 +155,8 @@ VSeriesPlotter::VSeriesPlotter( const uno::Reference<XChartType>& xChartTypeMode
, m_xChartTypeModelProps( uno::Reference< beans::XPropertySet >::query( xChartTypeModel ))
, m_aZSlots()
, m_bCategoryXAxis(bCategoryXAxis)
+ , m_nTimeResolution(::com::sun::star::chart::TimeUnit::DAY)
+ , m_aNullDate(30,12,1899)
, m_xColorScheme()
, m_pExplicitCategoriesProvider(0)
, m_bPointsWereSkipped(false)
@@ -198,7 +203,17 @@ void VSeriesPlotter::addSeries( VDataSeries* pSeries, sal_Int32 zSlot, sal_Int32
return;
if(m_bCategoryXAxis)
- pSeries->setCategoryXAxis();
+ {
+ if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() )
+ pSeries->setXValues( m_pExplicitCategoriesProvider->getOriginalCategories() );
+ else
+ pSeries->setCategoryXAxis();
+ }
+ else
+ {
+ if( m_pExplicitCategoriesProvider )
+ pSeries->setXValuesIfNone( m_pExplicitCategoriesProvider->getOriginalCategories() );
+ }
if(zSlot<0 || zSlot>=static_cast<sal_Int32>(m_aZSlots.size()))
{
@@ -378,7 +393,7 @@ OUString VSeriesPlotter::getLabelTextForValue( VDataSeries& rDataSeries
nNumberFormatKey = rDataSeries.getExplicitNumberFormat(nPointIndex,bAsPercentage);
else if( bAsPercentage )
{
- sal_Int32 nPercentFormat = ExplicitValueProvider::getPercentNumberFormat( m_apNumberFormatterWrapper->getNumberFormatsSupplier() );
+ sal_Int32 nPercentFormat = DiagramHelper::getPercentNumberFormat( m_apNumberFormatterWrapper->getNumberFormatsSupplier() );
if( nPercentFormat != -1 )
nNumberFormatKey = nPercentFormat;
}
@@ -443,13 +458,30 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
//------------------------------------------------
//prepare legend symbol
+ float fViewFontSize( 10.0 );
+ {
+ uno::Reference< beans::XPropertySet > xProps( rDataSeries.getPropertiesOfPoint( nPointIndex ) );
+ if( xProps.is() )
+ xProps->getPropertyValue( C2U( "CharHeight" )) >>= fViewFontSize;
+ // pt -> 1/100th mm
+ fViewFontSize *= (2540.0 / 72.0);
+ }
Reference< drawing::XShape > xSymbol;
if(pLabel->ShowLegendSymbol)
{
+ sal_Int32 nSymbolHeigth = static_cast< sal_Int32 >( fViewFontSize * 0.6 );
+ awt::Size aCurrentRatio = this->getPreferredLegendKeyAspectRatio();
+ sal_Int32 nSymbolWidth = aCurrentRatio.Width;
+ if( aCurrentRatio.Height > 0 )
+ {
+ nSymbolWidth = nSymbolHeigth* aCurrentRatio.Width/aCurrentRatio.Height;
+ }
+ awt::Size aMaxSymbolExtent( nSymbolWidth, nSymbolHeigth );
+
if( rDataSeries.isVaryColorsByPoint() )
- xSymbol.set( VSeriesPlotter::createLegendSymbolForPoint( rDataSeries, nPointIndex, xTarget_, m_xShapeFactory ) );
+ xSymbol.set( VSeriesPlotter::createLegendSymbolForPoint( aMaxSymbolExtent, rDataSeries, nPointIndex, xTarget_, m_xShapeFactory ) );
else
- xSymbol.set( VSeriesPlotter::createLegendSymbolForSeries( rDataSeries, xTarget_, m_xShapeFactory ) );
+ xSymbol.set( VSeriesPlotter::createLegendSymbolForSeries( aMaxSymbolExtent, rDataSeries, xTarget_, m_xShapeFactory ) );
}
//prepare text
@@ -549,25 +581,14 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
const awt::Point aOldTextPos( xTextShape->getPosition() );
awt::Point aNewTextPos( aOldTextPos );
+ awt::Point aSymbolPosition( aUnrotatedTextPos );
awt::Size aSymbolSize( xSymbol->getSize() );
awt::Size aTextSize( xTextShape->getSize() );
+ sal_Int32 nXDiff = aSymbolSize.Width + static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.22 ) );//minimum 1mm
if( !bMultiLineLabel || nLineCountForSymbolsize <= 0 )
nLineCountForSymbolsize = 1;
- sal_Int32 nYDiff = aTextSize.Height/nLineCountForSymbolsize;
- sal_Int32 nXDiff = aSymbolSize.Width * nYDiff/aSymbolSize.Height;
-
- // #i109336# Improve auto positioning in chart
- nXDiff = nXDiff * 80 / 100;
- nYDiff = nYDiff * 80 / 100;
-
- aSymbolSize.Width = nXDiff * 75/100;
- aSymbolSize.Height = nYDiff * 75/100;
-
- awt::Point aSymbolPosition( aUnrotatedTextPos );
-
- // #i109336# Improve auto positioning in chart
- aSymbolPosition.Y += ( nYDiff / 4 );
+ aSymbolPosition.Y += ((aTextSize.Height/nLineCountForSymbolsize)/4);
if(LABEL_ALIGN_LEFT==eAlignment
|| LABEL_ALIGN_LEFT_TOP==eAlignment
@@ -589,10 +610,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
aNewTextPos.X += nXDiff/2;
}
- xSymbol->setSize( aSymbolSize );
xSymbol->setPosition( aSymbolPosition );
-
- //set position
xTextShape->setPosition( aNewTextPos );
}
}
@@ -755,6 +773,17 @@ void lcl_AddErrorBottomLine( const drawing::Position3D& rPosition, ::basegfx::B2
return aMainDirection;
}
+drawing::Position3D lcl_transformMixedToScene( PlottingPositionHelper* pPosHelper
+ , double fX /*scaled*/, double fY /*unscaled*/, double fZ /*unscaled*/, bool bClip )
+{
+ if(!pPosHelper)
+ return drawing::Position3D(0,0,0);
+ pPosHelper->doLogicScaling( 0,&fY,&fZ );
+ if(bClip)
+ pPosHelper->clipScaledLogicValues( &fX,&fY,&fZ );
+ return pPosHelper->transformScaledLogicToScene( fX, fY, fZ, false );
+}
+
} // anonymous namespace
void VSeriesPlotter::createErrorBar(
@@ -764,6 +793,7 @@ void VSeriesPlotter::createErrorBar(
, const VDataSeries& rVDataSeries
, sal_Int32 nIndex
, bool bYError /* = true */
+ , double* pfScaledLogicX
)
{
if( !ChartTypeHelper::isSupportingStatisticProperties( m_xChartTypeModel, m_nDimension ) )
@@ -798,7 +828,13 @@ void VSeriesPlotter::createErrorBar(
const double fX = aUnscaledLogicPosition.PositionX;
const double fY = aUnscaledLogicPosition.PositionY;
const double fZ = aUnscaledLogicPosition.PositionZ;
- aMiddle = m_pPosHelper->transformLogicToScene( fX, fY, fZ, true );
+ double fScaledX = fX;
+ if( pfScaledLogicX )
+ fScaledX = *pfScaledLogicX;
+ else
+ m_pPosHelper->doLogicScaling( &fScaledX, 0, 0 );
+
+ aMiddle = lcl_transformMixedToScene( m_pPosHelper, fScaledX, fY, fZ, true );
drawing::Position3D aNegative(aMiddle);
drawing::Position3D aPositive(aMiddle);
@@ -813,11 +849,16 @@ void VSeriesPlotter::createErrorBar(
double fLocalX = fX;
double fLocalY = fY;
if( bYError )
+ {
fLocalY+=fLength;
+ aPositive = lcl_transformMixedToScene( m_pPosHelper, fScaledX, fLocalY, fZ, true );
+ }
else
+ {
fLocalX+=fLength;
+ aPositive = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true );
+ }
bCreatePositiveBorder = m_pPosHelper->isLogicVisible(fLocalX, fLocalY, fZ);
- aPositive = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true );
}
else
bShowPositive = false;
@@ -831,12 +872,16 @@ void VSeriesPlotter::createErrorBar(
double fLocalX = fX;
double fLocalY = fY;
if( bYError )
+ {
fLocalY-=fLength;
+ aNegative = lcl_transformMixedToScene( m_pPosHelper, fScaledX, fLocalY, fZ, true );
+ }
else
+ {
fLocalX-=fLength;
-
+ aNegative = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true );
+ }
bCreateNegativeBorder = m_pPosHelper->isLogicVisible( fLocalX, fLocalY, fZ);
- aNegative = m_pPosHelper->transformLogicToScene( fLocalX, fLocalY, fZ, true );
}
else
bShowNegative = false;
@@ -879,7 +924,8 @@ void VSeriesPlotter::createErrorBar(
void VSeriesPlotter::createErrorBar_Y( const drawing::Position3D& rUnscaledLogicPosition
, VDataSeries& rVDataSeries, sal_Int32 nPointIndex
- , const uno::Reference< drawing::XShapes >& xTarget )
+ , const uno::Reference< drawing::XShapes >& xTarget
+ , double* pfScaledLogicX )
{
if(m_nDimension!=2)
return;
@@ -893,7 +939,8 @@ void VSeriesPlotter::createErrorBar_Y( const drawing::Position3D& rUnscaledLogic
createErrorBar( xErrorBarsGroup_Shapes
, rUnscaledLogicPosition, xErrorBarProp
, rVDataSeries, nPointIndex
- , true /* bYError */ );
+ , true /* bYError */
+ , pfScaledLogicX );
}
}
@@ -931,13 +978,13 @@ void VSeriesPlotter::createRegressionCurvesShapes( VDataSeries& rVDataSeries
aRegressionPoly.SequenceZ[0].realloc(nRegressionPointCount);
sal_Int32 nRealPointCount=0;
- uno::Sequence< chart2::ExplicitScaleData > aScaleDataSeq( m_pPosHelper->getScales());
+ std::vector< ExplicitScaleData > aScales( m_pPosHelper->getScales());
uno::Reference< chart2::XScaling > xScalingX;
uno::Reference< chart2::XScaling > xScalingY;
- if( aScaleDataSeq.getLength() >= 2 )
+ if( aScales.size() >= 2 )
{
- xScalingX.set( aScaleDataSeq[0].Scaling );
- xScalingY.set( aScaleDataSeq[1].Scaling );
+ xScalingX.set( aScales[0].Scaling );
+ xScalingY.set( aScales[1].Scaling );
}
uno::Sequence< geometry::RealPoint2D > aCalculatedPoints(
@@ -1111,35 +1158,58 @@ void VSeriesPlotter::setMappedProperties(
PropertyMapper::setMappedProperties(xTargetProp,xSource,rMap,pOverwriteMap);
}
+void VSeriesPlotter::setTimeResolutionOnXAxis( long TimeResolution, const Date& rNullDate )
+{
+ m_nTimeResolution = TimeResolution;
+ m_aNullDate = rNullDate;
+}
+
//-------------------------------------------------------------------------
// MinimumAndMaximumSupplier
//-------------------------------------------------------------------------
-
-double VSeriesPlotter::getMinimumX()
+long VSeriesPlotter::calculateTimeResolutionOnXAxis()
{
- if( m_bCategoryXAxis )
+ long nRet = ::com::sun::star::chart::TimeUnit::YEAR;
+ if( m_pExplicitCategoriesProvider )
{
- double fRet = 1.0;//first category (index 0) matches with real number 1.0
- if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() )
- fRet -= 0.5;
- return fRet;
+ const std::vector< DatePlusIndex >& rDateCategories = m_pExplicitCategoriesProvider->getDateCategories();
+ std::vector< DatePlusIndex >::const_iterator aIt = rDateCategories.begin(), aEnd = rDateCategories.end();
+ Date aNullDate(30,12,1899);
+ if( m_apNumberFormatterWrapper.get() )
+ aNullDate = m_apNumberFormatterWrapper->getNullDate();
+ if( aIt!=aEnd )
+ {
+ Date aPrevious(aNullDate); aPrevious+=rtl::math::approxFloor(aIt->fValue);
+ ++aIt;
+ for(;aIt!=aEnd;++aIt)
+ {
+ Date aCurrent(aNullDate); aCurrent+=rtl::math::approxFloor(aIt->fValue);
+ if( ::com::sun::star::chart::TimeUnit::YEAR == nRet )
+ {
+ if( DateHelper::IsInSameYear( aPrevious, aCurrent ) )
+ nRet = ::com::sun::star::chart::TimeUnit::MONTH;
+ }
+ if( ::com::sun::star::chart::TimeUnit::MONTH == nRet )
+ {
+ if( DateHelper::IsInSameMonth( aPrevious, aCurrent ) )
+ nRet = ::com::sun::star::chart::TimeUnit::DAY;
+ }
+ if( ::com::sun::star::chart::TimeUnit::DAY == nRet )
+ break;
+ aPrevious=aCurrent;
+ }
+ }
}
-
+ return nRet;
+}
+double VSeriesPlotter::getMinimumX()
+{
double fMinimum, fMaximum;
this->getMinimumAndMaximiumX( fMinimum, fMaximum );
return fMinimum;
}
double VSeriesPlotter::getMaximumX()
{
- if( m_bCategoryXAxis )
- {
- //return category count
- double fRet = getPointCount();//first category (index 0) matches with real number 1.0
- if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() )
- fRet += 0.5;
- return fRet;
- }
-
double fMinimum, fMaximum;
this->getMinimumAndMaximiumX( fMinimum, fMaximum );
return fMaximum;
@@ -1147,7 +1217,7 @@ double VSeriesPlotter::getMaximumX()
double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
{
- if( !m_bCategoryXAxis )
+ if( !m_bCategoryXAxis || ( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) )
{
double fMinY, fMaxY;
this->getMinimumAndMaximiumYInContinuousXRange( fMinY, fMaxY, fMinimumX, fMaximumX, nAxisIndex );
@@ -1181,7 +1251,7 @@ double VSeriesPlotter::getMinimumYInRange( double fMinimumX, double fMaximumX, s
double VSeriesPlotter::getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
{
- if( !m_bCategoryXAxis )
+ if( !m_bCategoryXAxis || ( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->isDateAxis() ) )
{
double fMinY, fMaxY;
this->getMinimumAndMaximiumYInContinuousXRange( fMinY, fMaxY, fMinimumX, fMaximumX, nAxisIndex );
@@ -1216,13 +1286,13 @@ double VSeriesPlotter::getMaximumYInRange( double fMinimumX, double fMaximumX, s
double VSeriesPlotter::getMinimumZ()
{
//this is the default for all charts without a meaningfull z axis
- return 0.5;
+ return 1.0;
}
double VSeriesPlotter::getMaximumZ()
{
- if( 3!=m_nDimension )
- return 0.5;
- return m_aZSlots.size()+0.5;
+ if( 3!=m_nDimension || !m_aZSlots.size() )
+ return getMinimumZ()+1;
+ return m_aZSlots.size();
}
namespace
@@ -1588,7 +1658,7 @@ double VSeriesPlotter::getTransformedDepth() const
return FIXED_SIZE_FOR_3D_CHART_VOLUME/(MaxZ-MinZ);
}
-void SAL_CALL VSeriesPlotter::addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex )
+void VSeriesPlotter::addSecondaryValueScale( const ExplicitScaleData& rScale, sal_Int32 nAxisIndex )
throw (uno::RuntimeException)
{
if( nAxisIndex<1 )
@@ -1618,9 +1688,9 @@ PlottingPositionHelper& VSeriesPlotter::getPlottingPositionHelper( sal_Int32 nAx
}
}
if( !pRet )
- {
pRet = m_pMainPosHelper;
- }
+ if(pRet)
+ pRet->setTimeResolution( m_nTimeResolution, m_aNullDate );
return *pRet;
}
@@ -1736,13 +1806,14 @@ bool VSeriesPlotter::shouldSnapRectToUsedArea()
return true;
}
-Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries(
- LegendExpansion eLegendExpansion
+std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries(
+ const awt::Size& rEntryKeyAspectRatio
+ , ::com::sun::star::chart::ChartLegendExpansion eLegendExpansion
, const Reference< beans::XPropertySet >& xTextProperties
, const Reference< drawing::XShapes >& xTarget
, const Reference< lang::XMultiServiceFactory >& xShapeFactory
, const Reference< uno::XComponentContext >& xContext
- ) throw (uno::RuntimeException)
+ )
{
std::vector< ViewLegendEntry > aResult;
@@ -1769,7 +1840,7 @@ Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries(
if(!pSeries)
continue;
- std::vector< ViewLegendEntry > aSeriesEntries( this->createLegendEntriesForSeries(
+ std::vector< ViewLegendEntry > aSeriesEntries( this->createLegendEntriesForSeries( rEntryKeyAspectRatio,
*pSeries, xTextProperties, xTarget, xShapeFactory, xContext ) );
//add series entries to the result now
@@ -1783,7 +1854,7 @@ Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries(
// If the legend is wide and we have a stacked bar-chart the normal order
// is the correct one
bool bReverse = false;
- if( eLegendExpansion != LegendExpansion_WIDE )
+ if( eLegendExpansion != ::com::sun::star::chart::ChartLegendExpansion_WIDE )
{
StackingDirection eStackingDirection( pSeries->getStackingDirection() );
bReverse = ( eStackingDirection == StackingDirection_Y_STACKING );
@@ -1798,24 +1869,119 @@ Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries(
}
}
}
+ }
+
+ return aResult;
+}
- //add charttype specific entries if any
+::std::vector< VDataSeries* > VSeriesPlotter::getAllSeries()
+{
+ ::std::vector< VDataSeries* > aAllSeries;
+ ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin();
+ const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end();
+ for( ; aZSlotIter != aZSlotEnd; aZSlotIter++ )
+ {
+ ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin();
+ const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end();
+ for( ; aXSlotIter != aXSlotEnd; aXSlotIter++ )
{
- std::vector< ViewLegendEntry > aChartTypeEntries( this->createLegendEntriesForChartType(
- xTextProperties, xTarget, xShapeFactory, xContext ) );
- aResult.insert( aResult.end(), aChartTypeEntries.begin(), aChartTypeEntries.end() );
+ ::std::vector< VDataSeries* > aSeriesList = aXSlotIter->m_aSeriesVector;
+ aAllSeries.insert( aAllSeries.end(), aSeriesList.begin(), aSeriesList.end() );
}
}
-
- return ::chart::ContainerHelper::ContainerToSequence( aResult );
+ return aAllSeries;
}
+namespace
+{
+bool lcl_HasVisibleLine( const uno::Reference< beans::XPropertySet >& xProps, bool& rbHasDashedLine )
+{
+ bool bHasVisibleLine = false;
+ rbHasDashedLine = false;
+ drawing::LineStyle aLineStyle = drawing::LineStyle_NONE;
+ if( xProps.is() && ( xProps->getPropertyValue( C2U("LineStyle")) >>= aLineStyle ) )
+ {
+ if( aLineStyle != drawing::LineStyle_NONE )
+ bHasVisibleLine = true;
+ if( aLineStyle == drawing::LineStyle_DASH )
+ rbHasDashedLine = true;
+ }
+ return bHasVisibleLine;
+}
+bool lcl_HasRegressionCurves( const VDataSeries& rSeries, bool& rbHasDashedLine )
+{
+ bool bHasRegressionCurves = false;
+ Reference< XRegressionCurveContainer > xRegrCont( rSeries.getModel(), uno::UNO_QUERY );
+ if( xRegrCont.is())
+ {
+ Sequence< Reference< XRegressionCurve > > aCurves( xRegrCont->getRegressionCurves() );
+ sal_Int32 i = 0, nCount = aCurves.getLength();
+ for( i=0; i<nCount; ++i )
+ {
+ if( aCurves[i].is() )
+ {
+ bHasRegressionCurves = true;
+ lcl_HasVisibleLine( uno::Reference< beans::XPropertySet >( aCurves[i], uno::UNO_QUERY ), rbHasDashedLine );
+ }
+ }
+ }
+ return bHasRegressionCurves;
+}
+}
LegendSymbolStyle VSeriesPlotter::getLegendSymbolStyle()
{
- return chart2::LegendSymbolStyle_BOX;
+ return LegendSymbolStyle_BOX;
}
+awt::Size VSeriesPlotter::getPreferredLegendKeyAspectRatio()
+{
+ awt::Size aRet(1000,1000);
+ if( m_nDimension==3 )
+ return aRet;
+
+ bool bSeriesAllowsLines = (getLegendSymbolStyle() == LegendSymbolStyle_LINE);
+ bool bHasLines = false;
+ bool bHasDashedLines = false;
+ ::std::vector< VDataSeries* > aAllSeries( getAllSeries() );
+ ::std::vector< VDataSeries* >::const_iterator aSeriesIter = aAllSeries.begin();
+ const ::std::vector< VDataSeries* >::const_iterator aSeriesEnd = aAllSeries.end();
+ //iterate through all series
+ for( ; aSeriesIter != aSeriesEnd; aSeriesIter++ )
+ {
+ if( bSeriesAllowsLines )
+ {
+ bool bCurrentDashed = false;
+ if( lcl_HasVisibleLine( (*aSeriesIter)->getPropertiesOfSeries(), bCurrentDashed ) )
+ {
+ bHasLines = true;
+ if( bCurrentDashed )
+ {
+ bHasDashedLines = true;
+ break;
+ }
+ }
+ }
+ bool bRegressionHasDashedLines=false;
+ if( lcl_HasRegressionCurves( **aSeriesIter, bRegressionHasDashedLines ) )
+ {
+ bHasLines = true;
+ if( bRegressionHasDashedLines )
+ {
+ bHasDashedLines = true;
+ break;
+ }
+ }
+ }
+ if( bHasLines )
+ {
+ if( bHasDashedLines )
+ aRet = awt::Size(1600,-1);
+ else
+ aRet = awt::Size(800,-1);
+ }
+ return aRet;
+}
uno::Any VSeriesPlotter::getExplicitSymbol( const VDataSeries& /*rSeries*/, sal_Int32 /*nPointIndex*/ )
{
@@ -1823,7 +1989,8 @@ uno::Any VSeriesPlotter::getExplicitSymbol( const VDataSeries& /*rSeries*/, sal_
}
Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForSeries(
- const VDataSeries& rSeries
+ const awt::Size& rEntryKeyAspectRatio
+ , const VDataSeries& rSeries
, const Reference< drawing::XShapes >& xTarget
, const Reference< lang::XMultiServiceFactory >& xShapeFactory )
{
@@ -1838,17 +2005,13 @@ Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForSeries(
// legend-symbol type
switch( eLegendSymbolStyle )
{
- case LegendSymbolStyle_HORIZONTAL_LINE:
- case LegendSymbolStyle_VERTICAL_LINE:
- case LegendSymbolStyle_DIAGONAL_LINE:
- case LegendSymbolStyle_LINE_WITH_BOX:
- case LegendSymbolStyle_LINE_WITH_SYMBOL:
+ case LegendSymbolStyle_LINE:
ePropType = VLegendSymbolFactory::PROP_TYPE_LINE_SERIES;
break;
default:
break;
};
- Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol(
+ Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( rEntryKeyAspectRatio,
xTarget, eLegendSymbolStyle, xShapeFactory
, rSeries.getPropertiesOfSeries(), ePropType, aExplicitSymbol ));
@@ -1856,7 +2019,8 @@ Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForSeries(
}
Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForPoint(
- const VDataSeries& rSeries
+ const awt::Size& rEntryKeyAspectRatio
+ , const VDataSeries& rSeries
, sal_Int32 nPointIndex
, const Reference< drawing::XShapes >& xTarget
, const Reference< lang::XMultiServiceFactory >& xShapeFactory )
@@ -1872,11 +2036,7 @@ Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForPoint(
// legend-symbol type
switch( eLegendSymbolStyle )
{
- case LegendSymbolStyle_HORIZONTAL_LINE:
- case LegendSymbolStyle_VERTICAL_LINE:
- case LegendSymbolStyle_DIAGONAL_LINE:
- case LegendSymbolStyle_LINE_WITH_BOX:
- case LegendSymbolStyle_LINE_WITH_SYMBOL:
+ case LegendSymbolStyle_LINE:
ePropType = VLegendSymbolFactory::PROP_TYPE_LINE_SERIES;
break;
default:
@@ -1907,14 +2067,15 @@ Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForPoint(
}
}
- Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol(
+ Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( rEntryKeyAspectRatio,
xTarget, eLegendSymbolStyle, xShapeFactory, xPointSet, ePropType, aExplicitSymbol ));
return xShape;
}
-std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSeries(
- const VDataSeries& rSeries
+std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries(
+ const awt::Size& rEntryKeyAspectRatio
+ , const VDataSeries& rSeries
, const Reference< beans::XPropertySet >& xTextProperties
, const Reference< drawing::XShapes >& xTarget
, const Reference< lang::XMultiServiceFactory >& xShapeFactory
@@ -1943,7 +2104,7 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe
uno::Reference< drawing::XShapes > xSymbolGroup( ShapeFactory(xShapeFactory).createGroup2D( xTarget ));
// create the symbol
- Reference< drawing::XShape > xShape( this->createLegendSymbolForPoint(
+ Reference< drawing::XShape > xShape( this->createLegendSymbolForPoint( rEntryKeyAspectRatio,
rSeries, nIdx, xSymbolGroup, xShapeFactory ) );
// set CID to symbol for selection
@@ -1973,7 +2134,7 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe
// create the symbol
Reference< drawing::XShape > xShape( this->createLegendSymbolForSeries(
- rSeries, xSymbolGroup, xShapeFactory ) );
+ rEntryKeyAspectRatio, rSeries, xSymbolGroup, xShapeFactory ) );
// set CID to symbol for selection
if( xShape.is())
@@ -2003,11 +2164,10 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe
sal_Int32 i = 0, nCount = aCurves.getLength();
for( i=0; i<nCount; ++i )
{
- if( aCurves[i].is() && !RegressionCurveHelper::isMeanValueLine( aCurves[i] ) )
+ if( aCurves[i].is() )
{
//label
- OUString aResStr( SchResId::getResString( STR_STATISTICS_IN_LEGEND ));
- replaceParamterInString( aResStr, C2U("%REGRESSIONCURVE"), RegressionCurveHelper::getUINameForRegressionCurve( aCurves[i] ));
+ OUString aResStr( RegressionCurveHelper::getUINameForRegressionCurve( aCurves[i] ) );
replaceParamterInString( aResStr, C2U("%SERIESNAME"), aLabelText );
aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( xContext, aResStr, xTextProperties );
@@ -2015,8 +2175,8 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe
uno::Reference< drawing::XShapes > xSymbolGroup( ShapeFactory(xShapeFactory).createGroup2D( xTarget ));
// create the symbol
- Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol(
- xSymbolGroup, chart2::LegendSymbolStyle_DIAGONAL_LINE, xShapeFactory,
+ Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( rEntryKeyAspectRatio,
+ xSymbolGroup, LegendSymbolStyle_LINE, xShapeFactory,
Reference< beans::XPropertySet >( aCurves[i], uno::UNO_QUERY ),
VLegendSymbolFactory::PROP_TYPE_LINE, uno::Any() ));
@@ -2025,7 +2185,7 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe
{
aEntry.aSymbol = uno::Reference< drawing::XShape >( xSymbolGroup, uno::UNO_QUERY );
- bool bAverageLine = false;//@todo find out wether this is an average line or a regression curve
+ bool bAverageLine = RegressionCurveHelper::isMeanValueLine( aCurves[i] );
ObjectType eObjectType = bAverageLine ? OBJECTTYPE_DATA_AVERAGE_LINE : OBJECTTYPE_DATA_CURVE;
OUString aChildParticle( ObjectIdentifier::createChildParticleWithIndex( eObjectType, i ) );
aChildParticle = ObjectIdentifier::addChildParticle( aChildParticle, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_LEGEND_ENTRY, 0 ) );
@@ -2045,16 +2205,6 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe
return aResult;
}
-std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForChartType(
- const Reference< beans::XPropertySet >& /* xTextProperties */,
- const Reference< drawing::XShapes >& /* xTarget */,
- const Reference< lang::XMultiServiceFactory >& /* xShapeFactory */,
- const Reference< uno::XComponentContext >& /* xContext */
- )
-{
- return std::vector< ViewLegendEntry >();
-}
-
VSeriesPlotter* VSeriesPlotter::createSeriesPlotter(
const uno::Reference<XChartType>& xChartTypeModel
, sal_Int32 nDimensionCount