void __fastcall TMForm::PlotTestTestSuiteDataExecute(TObject *Sender)
{
    //Read the test suite data
    string file =  FSF->GetSelectedFileInTree();
    string path =  rr::extractFilePath(file);
    vector<string> dirs = rr::splitString(path,"\\");
    string tsDataFile;
    if(dirs.size())
    {
        string caseNr = dirs[dirs.size() -1];
        tsDataFile = rr::joinPath(path, (caseNr + "-results.csv"));
    }

    RoadRunnerData result;
    if(!result.load(tsDataFile))
    {
        return;
    }

    //Fill out data for all series
    int nrOfSeries = result.cSize() -1; //First one is time
    StringList colNames = result.getColumnNames();
    vector<TLineSeries*> series;
    for(int i = 0; i < nrOfSeries; i++)
    {
        TLineSeries* aSeries = new TLineSeries(Chart1);
        aSeries->Title = colNames[i+1].c_str();
        aSeries->Color = clGray;
        aSeries->LinePen->Width = 1;
        aSeries->Pointer->Visible = true;
        series.push_back(aSeries);
        Chart1->AddSeries(aSeries);
    }

    for(int j = 0; j < result.rSize(); j++)
    {
        double xVal = result(j,0);

        for(int i = 0; i < nrOfSeries; i++)
        {
            double yData = result(j, i+1);
            series[i]->AddXY(xVal, yData);
        }
    }
    Chart1->Update();

}
RRCDataPtr createRRCData(const RoadRunnerData& result)
{
    RRCData* rrCData  = new RRCData;
    memset(rrCData, 0, sizeof(RRCData));

    rrCData->ColumnHeaders = new char*[result.cSize()];
    for(int i = 0; i < result.cSize(); i++)
    {
        rrCData->ColumnHeaders[i] = rr::createText(result.getColumnNames()[i]);
    }

    rrCData->RSize = result.rSize();
    rrCData->CSize = result.cSize();
    int size = rrCData->RSize*rrCData->CSize;
    rrCData->Data = new double[size];

    if(result.hasWeights())
    {
    	rrCData->Weights = new double[size];
    }

    int index = 0;
    //The data layout is simple row after row, in one single long row...
    for(int row = 0; row < rrCData->RSize; row++)
    {
        for(int col = 0; col < rrCData->CSize; col++)
        {
            rrCData->Data[index] = result(row, col);
            if(result.hasWeights())
            {
            	rrCData->Weights[index] = result.weight(row, col);
            }
            ++index;
        }
    }
	return rrCData;
}