Building Graphs With Any Data

I’m working on integrating some additional metrics that are gathered outside of Piwik proper into a Piwik plugin, so my client can visit one site to view all the relevant data they wish to monitor. Obtaining and parsing this third-party data isn’t an issue, but the Piwik evolution graphing API seems to want a lot of additional data outside of the basic X increments and series of data. I’ve pored over as much of the sparse/outdated documentation as I can find, but I can’t seem to get a clear picture of the bare minimum data necessary to submit for Piwik to build an evolution graph.

Just creating a new Map and filling it with Tables seems to create numerous errors. I’ve had a bit more luck making API calls and emptying the data containers, studying the values, and replacing various pieces of data to get sort of what I’m looking for, like so:

$result = $data->getEmptyClone($keepFilters = false);

foreach($data->getDataTables() as $date => $dateTable){
foreach($dateTable->getRows() as $row){
$newTable = $dateTable->getEmptyClone($keepFilters = false);
$newTable->addRowFromSimpleArray(array(
‘label’ => “test”,
‘visits’ => 3
));
$newTable->addRowFromSimpleArray(array(
‘label’ => “test2”,
‘visits’ => 4
));
$result->addTable($newTable, $date);
}
}

But it feels like the slightest breeze will destroy everything. I get the impression that Piwik expects very specific labels for data, all pertaining to its own API - that it doesn’t want to play nicely with external data. I even tried embedding a Google chart into the plugin instead, but there’s no good place in the Piwik system to hook in the Google API.

All I want to be able to do is hook in my own data to build charts is Piwik. Is there something I’m missing?

Thanks for the feedback. The code can take a bit of used to, it is not finished, and it is lacking documentation.
We really want to make the platform better and let you easily integrate third party data. These are tasks we will tackle but the team is small.

Have you tried in your API to simply return an array of data, as it should be converted to a DataTable automatically?
If not check out simple examples like the “ExampleUI” plugin (enable this plugin in the Settings)

Hope it helps!