Graphic bug on evolution graph


(Seb_bleuroy) #1

Hi, when I use an evolution graph on a period containing too many elements, dates are stacking on X axis.
Is there any way to control how many elements will be shown under the graph ?
I have joined a screenshot to this post.
Thanks for replying !
Seb


(cn_Dark) #2

Hello,

I am writing a plugin, is it possible to set x-step for dataTable?
For example, if want to set x-step for it ,what should I do?

function echoEvolutionGraph()
    {
        $view = Piwik_ViewDataTable::factory('graphEvolution');
        $view->init( $this->pluginName,  __FUNCTION__, 'ExampleUI.getTemperaturesEvolution' );
        $view->setColumnTranslation('server1', "Temperature server piwik.org");
        $view->setColumnTranslation('server2', "Temperature server dev.piwik.org");
        $view->setAxisYUnit('°C'); // useful if the user requests the bar graph
        return $this->renderView($view);
    }

(vipsoft) #3

I think Piwik lets OFC2 auto-render the x-axis. If you can come up with a fix, let us know.

Reference: http://teethgrinder.co.uk/open-flash-chart…labels-step.php


(cn_Dark) #4

[quote=vipsoft @ Aug 19 2009, 02:07 PM]I think Piwik lets OFC2 auto-render the x-axis. If you can come up with a fix, let us know.

Reference: http://teethgrinder.co.uk/open-flash-chart…labels-step.php[/quote]
Hello vipsoft,
sorry, i didn’t notice that someone have posted the similar question.

I think piwik can set this .
I find in “core/Visualization/Chart.php”, we can set x-step.
But I don’t know how to set this in plugin.

abstract class Piwik_Visualization_Chart implements Piwik_iView
{
    /**
     * @var Piwik_Visualization_OpenFlashChart
     */
    protected $chart = null;
    
    protected $xLabels = array();
    protected $xOnClick = array();
    protected $xSteps = 2;
    
    protected $yLabels = array();
    protected $yValues = array();
    protected $yUnit = '';
    
    protected $maxValue;
    protected $minValue;
    protected $displayPercentageInTooltip = true;
....
.......

public function setXSteps($steps)
    {
        $this->xSteps = $steps;
    }
...
...

(vipsoft) #5

Add a new method to Chart.php and call it from your plugin. If it works, then submit a patch. style_emoticons/<#EMO_DIR#>/wink.gif


(cn_Dark) #6

It’s difficult for me to understand how it works detailly.
I add a funtion in “Core/ViewDataTable/GenerateGraphData” , and it seems that it can work. But the problem is that there is a difference when the xstep is odd and even number.

//add this function at the end of Core/ViewDataTable/GenerateGraphData,in class Piwik_ViewDataTable_GenerateGraphData
public function setXSteps($step) {
        $this->view->setXSteps($step);
    }

the method to use this function,example:plugins/exampleui/Controller.php

...
function echoEvolutionGraph()
    {
        $view = Piwik_ViewDataTable::factory('graphEvolution');
        $view->init( $this->pluginName,  __FUNCTION__, 'ExampleUI.getTemperaturesEvolution' );
        $view->setColumnTranslation('server1', "Temperature server piwik.org");
        $view->setColumnTranslation('server2', "Temperature server dev.piwik.org");
        $view->setAxisYUnit('°C'); 
        $view->setXSteps(6); //use this function like this
        return $this->renderView($view);
    }
...

There is 3 image, the first is default, witout set xSteps,the second is XSteps == 6,
the third is XSteps ==3. You can see the differences between odd and even numbers.
[attachment=90:2.png][attachment=92:1.png][attachment=91:0.png]


(cn_Dark) #7

How to submit a patch??? style_emoticons/<#EMO_DIR#>/huh.gif


(Matthieu Aubry) #8

Process for contributing is explained here: http://dev.piwik.org/trac/wiki/PiwikDevelo…wtosubmitapatch

thanks for your contribution!