Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript error "Cannot read property 'left' of undefined" in Piwik 2.13.1 #8063

Closed
splinter89 opened this issue Jun 8, 2015 · 4 comments
Closed
Labels
answered For when a question was asked and we referred to forum or answered it. Bug For errors / faults / flaws / inconsistencies etc.

Comments

@splinter89
Copy link
Contributor

Hi!
The mentioned error occurs on this line:

canvas.position().left

I wasn't able to trace conditions which lead to this error though, because breakpoints on minified JS are not very useful.

Maybe someone can fix it?

@mattab
Copy link
Member

mattab commented Jun 10, 2015

Hi @splinter89

thanks for the report. we'll take a look

@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Jun 10, 2015
@mattab mattab added this to the 2.14.0 milestone Jun 10, 2015
@mattab
Copy link
Member

mattab commented Jun 10, 2015

@splinter89 can you reproduce this issue on the demo.piwik.org as well? which browser do you use?

@mattab mattab removed this from the 2.14.0 milestone Jun 10, 2015
@splinter89
Copy link
Contributor Author

I get this error in Chrome 43.0.2357.124 m.
Also Firefox 38.0.5 shows "TypeError: canvas.position(...) is undefined"

Ok, I have found that my simple custom plugin is the reason.
When I add it to dashboard, I get these errors:

Uncaught TypeError: Cannot read property 'left' of undefined
Uncaught Error: No plot target specified
Uncaught TypeError: Cannot read property 'left' of undefined

but everything is shown correctly and working..

Graph is rendered automatically by Piwik, so I don't see how this plugin could cause that. However, if it's the case, I am sorry for taking your time.

Anyway, maybe this would help:

class OurCompany extends Plugin
{
    public function postLoad()
    {
        WidgetsList::add('OurCompany widgets', 'Banners', 'OurCompany', 'bannersGraph');
    }
}

class Controller extends \Piwik\Plugin\Controller
{
    public function bannersGraph()
    {
        $view = new View('@OurCompany/banners');
        $this->setPeriodVariablesView($view);
        $view->bannersGraph = $this->getBannersGraph(['page1', 'page2']);
        return $view->render();
    }

    public function getBannersGraph(array $defaultColumns = [])
    {
        $columns = Common::getRequestVar('columns', false);
        if (false !== $columns) {
            $columns = Piwik::getArrayFromApiParameter($columns);
        }

        $view = $this->getLastUnitGraphAcrossPlugins(
            $this->pluginName,
            __FUNCTION__,
            $columns,
            $defaultColumns,
            false,
            'OurCompany.getBannersEvolution'
        );
        $view->requestConfig->disable_generic_filters = true; // do not sort

        if (empty($view->config->columns_to_display) && !empty($defaultColumns)) {
            $view->config->columns_to_display = $defaultColumns;
        }

        return $this->renderView($view);
    }
}

class API extends \Piwik\Plugin\API
{
    public function getBannersEvolution($idSite, $period, $date, $segment = false)
    {
        $data = [/*...*/]; // sorted manually
        return DataTable::makeFromIndexedArray($data);
    }
}

and simple "banners.twig"

{{ bannersGraph|raw }}

@mattab
Copy link
Member

mattab commented Jul 15, 2015

Ok, I have found that my simple custom plugin is the reason.

Since it's not a bug in Piwik core, i'm closing. We plan to improve the Platform & APIs around displaying reports, graphs, in the future, so hopefully such issue would be fixed. if this bug is blocking you or breaking your Piwik we could maybe re-open the issue

@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Jul 15, 2015
@mattab mattab closed this as completed Jul 15, 2015
@mattab mattab modified the milestone: Short term Sep 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it. Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants