Null XValue and YValue

Hi

Is it normal for IChartDataCell::get_Value() to return nullptr? It is supposed to return SharedPtrSystem::Object

I’m using IChartDataPoint::get_XValue() which returns IStringOrDoubleChartValue instance as it should, but if I call the get_AsCell() method on that, the resulting IChartDataCell::get_Vaule() seems to return a SharedPtr that points to null. Calling any method on its results generates a NullReference exception.

So my question is: if IChartDataPoint::get_Value() returns a non-null value, is it normal for IChartDataPoint::get_XValue() or IChartDataPoint::get_YValue() to NOT have a value (i.e. produce null result)?

Example:

get_Value()->get_AsCell()->get_Value() // This has value
get_XValue()->get_AsCell()->get_Value() // This is null
get_YValue()->get_AsCell()->get_Value() // This is also null.

Is this normal or something should be wrong?

Thanks in advance!

@gtamas

Please share the source presentation along with working sample code reproducing the issue so that we may try verifying this on our end.

So that I don’t know how to do, since this is a PHP extension, so I’m not using the C++ lib in the usual way.

Anyway I’m using something like this:

 template <typename T>
    class AsposeObjectWrapper
    {
        protected: 
            System::SharedPtr<T> _asposeObj;
        public:
            AsposeObjectWrapper(System::SharedPtr<T> asposeObj) : _asposeObj(asposeObj) {};
            virtual ~AsposeObjectWrapper() {
                _asposeObj.reset();
            };
            
            void __construct(Php::Parameters &params) {};

            template <typename AsposeType, typename AsposePhpType, auto Method, class ...Args>
            AsposePhpType * wrapObject(Args &&... args)
            {
                System::SharedPtr<AsposeType> obj = (*_asposeObj.*Method)(args...);
                AsposePhpType * phpValue = new AsposePhpType(obj); 
                return phpValue;
            }

    };

This class creates classes in our namespace. Each class holds an instance of an Apsose class, so we can use it internally and export some results to PHP. The template method above instantiates a custom class using an Aspose class instance as input.

So for example Aspose::Slides::Charts::Chart class is wrapped by AsposePhp::Chart class which is instantiated using the above template class.

And this is how I call the above method:

Php::Value DoubleChartValue::get_AsCell() {
    return Php::Object("ChartDataCell", wrapObject<IChartDataCell, AsposePhp::ChartDataCell, &IDoubleChartValue::get_AsCell>());
}

What this returns is an instance of AsposePhp::ChartDataCell class whose _asposeObj member points to an instance of Aspose::Charts::chart::IChartDataCell instance.

I use this approach everywhere and it works, from Presentation to Slides, all across the board. But for some reason, the XValue() and YValue() calls don’t work.

get_YValue()->get_AsCell() returns a ChartDataCell object, but calling the get_Value() on that doesn’t work because in that case this->_asposeObj is null (even though it should be System::Object).

Anyway I know this is not a reproducible example, but please let me know if you see anything wrong here. I’m new to C++, so probably I’m doing something wrong.

@gtamas

We need a reproducible example for this. This case that you are referring may be an API issue with a particular presentation on your end. One more thing, you are trying to get X and Y values for a chart series data point? This is dependent on type of series as well. Not every chart series has X and Y values. Like in clustered column or bar charts, you have one value. So, you need to also assess that what series type you have.

Thanks for the info.
I’m working with a bar chart here, so probably that’s why I don’t have the X / Y values then. Anyway, the API docs don’t really mention that these could point to null values, so maybe the docs should be updated.

Which chart type is guaranteed to have X / Y values (I don’t know PowerPoint at all, so I’m not famailiar with the cart types it supports)

Thanks in adcvance!

@gtamas

The charts with 2 points plotting in PowerPoint have got X,Y values. Please also read this API reference guide link for AddDatapoints variants fro different chart types.