com.tencent.wstt.apt.chart.CPURealTimeChart.java Source code

Java tutorial

Introduction

Here is the source code for com.tencent.wstt.apt.chart.CPURealTimeChart.java

Source

/**
 * Tencent is pleased to support the open source community by making APT available.
 * Copyright (C) 2014 THL A29 Limited, a Tencent company. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 */

package com.tencent.wstt.apt.chart;

import java.awt.Font;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.XYPlot;

/**
* @Description CPU
* @date 20131110 ?5:13:49 
*
 */
public class CPURealTimeChart extends AbstractRealTimeLineChart {

    public CPURealTimeChart() {
        super();
    }

    private static final long serialVersionUID = -6638737463455176144L;

    @Override
    public JFreeChart createChart() {
        final JFreeChart chart = ChartFactory.createTimeSeriesChart("CPU", "", "CPU%", dataset,
                true, true, false);

        //??
        chart.getTitle().setFont(new Font("", Font.BOLD, 20));

        XYPlot xyPlot = (XYPlot) chart.getXYPlot();
        ValueAxis domainAxis = xyPlot.getDomainAxis();
        ValueAxis rangeAxis = xyPlot.getRangeAxis();

        domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
        domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12));

        rangeAxis.setLabelFont(new Font("", Font.BOLD, 14));
        rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
        return chart;
    }

}