package kg.apc.jmeter.graphs;

import kg.apc.charting.DateTimeRenderer;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContextService;

/**
 *
 * @author apc
 */
public abstract class AbstractOverTimeVisualizer
        extends AbstractGraphPanelVisualizer {

    protected long relativeStartTime = 0;

    public AbstractOverTimeVisualizer() {
        graphPanel.getGraphObject().setxAxisLabelRenderer(new DateTimeRenderer(DateTimeRenderer.HHMMSS));
        graphPanel.getGraphObject().setxAxisLabel("Elapsed time");
        graphPanel.getGraphObject().setDisplayPrecision(true);
    }

    @Override
    public void add(SampleResult sample) {
        if (relativeStartTime == 0) {
            relativeStartTime = JMeterContextService.getTestStartTime();
            if (relativeStartTime == 0) {
                relativeStartTime = sample.getStartTime();
            }
            handleRelativeStartTime();
        }
    }

    protected void handleRelativeStartTime() {
        if (graphPanel.getGraphObject().getChartSettings().isUseRelativeTime()) {
            graphPanel.getGraphObject().setxAxisLabelRenderer(new DateTimeRenderer(DateTimeRenderer.HHMMSS, relativeStartTime));
        }
        graphPanel.getGraphObject().setTestStartTime(relativeStartTime);
        graphPanel.getGraphObject().setForcedMinX(relativeStartTime);
    }

    @Override
    public void clearData() {
        super.clearData();
        relativeStartTime = 0;
        updateGui();
    }

    protected long normalizeTime(long time) {
        return time - (time - relativeStartTime) % getGranulation();
    }
}

@@ -333,16 +333,55 @@
 ime = 0;
+%0A    private boolean isJtlLoad = false;
 %0A%0A    pu
@@ -819,32 +819,63 @@
 estStartTime();%0A
+            isJtlLoad = false;%0A
             if (
@@ -975,48 +975,421 @@
     
-%7D%0A            handleRelativeStartTime();
+    isJtlLoad = true;%0A            %7D%0A            relativeStartTime = relativeStartTime - relativeStartTime%25getGranulation();%0A            handleRelativeStartTime();%0A        %7D%0A        if(isJtlLoad) %7B%0A            if(relativeStartTime %3E sample.getStartTime()) %7B%0A                relativeStartTime = sample.getStartTime() - sample.getStartTime()%25getGranulation();%0A                handleRelativeStartTime();%0A            %7D
 %0A   
@@ -1918,24 +1918,51 @@
 rtTime = 0;%0A
+        isJtlLoad = false;%0A
         upda
@@ -2049,37 +2049,13 @@
 e - 
-(
 time
- - relativeStartTime) %25 
+%25
 getG

Fix issue 112