@Override
    public void paintComponent(Graphics graphics) {
        
        super.paintComponent(graphics);
        
        if (data == null) {
            
            return;
        }
            
        final int xAxisSize = 40;
        final int yAxisSize = 60;
        final int yAxisLines = 10;
        final int xAxisLines = 10;
        final int graphWidth = getWidth() - yAxisSize;
        final int graphHeight = getHeight() - xAxisSize;
        
        double[] normalisedData = getNormalisedData(graphWidth, graphHeight);
        
        graphics.setColor(new Color(120, 120, 120));
        
        // Draw the y axis.
        for (int i = 0; i <= yAxisLines; i++) {
            
            int yPos = graphHeight * i / yAxisLines;
            Double label = currentMaxValue * (1 - i / (double)yAxisLines);
            label = (double)Math.round(label * 10000) / 100;
            
            graphics.drawLine(yAxisSize - 5, yPos, getWidth(), yPos);
            graphics.drawString(label.toString() + "%", 0, yPos);
        }
        
        // Draw the x axis.
        for (int i = 0; i <= xAxisLines; i++) {
            
            int xPos = graphWidth * i / xAxisLines + yAxisSize - 1;
            Double label = (double)(data.length * i / xAxisLines) / 1000;
            
            graphics.drawLine(xPos, 0, xPos, graphHeight + 5);
            graphics.drawString(label.toString() + "k", xPos, getHeight() - 5);
        }
        
        graphics.setColor(new Color(0, 0, 0));
        
        // Draw data lines.
        for (int x = 0; x < normalisedData.length; x++) {
            
            graphics.drawLine(x + yAxisSize, getHeight() - xAxisSize, x + yAxisSize,
                    getHeight() - ((int)normalisedData[x] + xAxisSize));
        }
    }