本文整理汇总了Java中org.jfree.chart.axis.DateAxis.setVerticalTickLabels方法的典型用法代码示例。如果您正苦于以下问题:Java DateAxis.setVerticalTickLabels方法的具体用法?Java DateAxis.setVerticalTickLabels怎么用?Java DateAxis.setVerticalTickLabels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.axis.DateAxis
的用法示例。
在下文中一共展示了DateAxis.setVerticalTickLabels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updatePlotter
import org.jfree.chart.axis.DateAxis; //导入方法依赖的package包/类
@Override
protected void updatePlotter() {
int categoryCount = prepareData();
String maxClassesProperty = ParameterService
.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
int maxClasses = 20;
try {
if (maxClassesProperty != null) {
maxClasses = Integer.parseInt(maxClassesProperty);
}
} catch (NumberFormatException e) {
// LogService.getGlobal().log("Series plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
// LogService.WARNING);
LogService.getRoot().log(Level.WARNING,
"com.rapidminer.gui.plotter.charts.SeriesChartPlotter.parsing_property_error");
}
boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;
JFreeChart chart = createChart(this.dataset, createLegend);
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
// domain axis
if (axis[INDEX] >= 0) {
if (!dataTable.isNominal(axis[INDEX])) {
if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
domainAxis.setTimeZone(Tools.getPreferredTimeZone());
chart.getXYPlot().setDomainAxis(domainAxis);
if (getRangeForDimension(axis[INDEX]) != null) {
domainAxis.setRange(getRangeForDimension(axis[INDEX]));
}
domainAxis.setLabelFont(LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(LABEL_FONT);
domainAxis.setVerticalTickLabels(isLabelRotating());
}
} else {
LinkedHashSet<String> values = new LinkedHashSet<String>();
for (DataTableRow row : dataTable) {
String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
if (stringValue.length() > 40) {
stringValue = stringValue.substring(0, 40);
}
values.add(stringValue);
}
ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]),
values.toArray(new String[values.size()]));
categoryAxis.setLabelFont(LABEL_FONT_BOLD);
categoryAxis.setTickLabelFont(LABEL_FONT);
categoryAxis.setVerticalTickLabels(isLabelRotating());
chart.getXYPlot().setDomainAxis(categoryAxis);
}
}
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
legend.setPosition(RectangleEdge.TOP);
legend.setFrame(BlockBorder.NONE);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
legend.setItemFont(LABEL_FONT);
}
AbstractChartPanel panel = getPlotterPanel();
if (panel == null) {
panel = createPanel(chart);
} else {
panel.setChart(chart);
}
// ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
panel.getChartRenderingInfo().setEntityCollection(null);
}
示例2: createWeeklyLoginChart
import org.jfree.chart.axis.DateAxis; //导入方法依赖的package包/类
private byte[] createWeeklyLoginChart (int width, int height)
{
IntervalXYDataset dataset1 = getWeeklyLoginsDataSet ();
IntervalXYDataset dataset2 = getWeeklySiteUserDataSet ();
if ((dataset1 == null) || (dataset2 == null)) {
return generateNoDataChart(width, height);
}
// create plot ...
XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
renderer1.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
renderer1.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
renderer1.setSeriesPaint(0, Color.RED);
renderer1.setSeriesPaint(0, Color.BLUE);
DateAxis domainAxis = new DateAxis("");
domainAxis.setTickUnit (new DateTickUnit (DateTickUnit.DAY, 7, new SimpleDateFormat ("yyyy-MM-dd")));
domainAxis.setTickMarkPosition (DateTickMarkPosition.START);
domainAxis.setVerticalTickLabels (true);
domainAxis.setLowerMargin (0.01);
domainAxis.setUpperMargin (0.01);
NumberAxis rangeAxis = new NumberAxis("count");
rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ());
XYPlot plot1 = new XYPlot(dataset1, null, rangeAxis, renderer1);
plot1.setBackgroundPaint(Color.lightGray);
plot1.setDomainGridlinePaint(Color.white);
plot1.setRangeGridlinePaint(Color.white);
// add a second dataset and renderer...
XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
renderer2.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
renderer2.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
renderer2.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
renderer2.setSeriesPaint(0, Color.GREEN);
renderer2.setSeriesPaint(1, Color.BLACK);
renderer2.setSeriesPaint(2, Color.CYAN);
rangeAxis = new NumberAxis("count");
rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ());
XYPlot plot2 = new XYPlot(dataset2, null, rangeAxis, renderer2);
plot2.setBackgroundPaint(Color.lightGray);
plot2.setDomainGridlinePaint(Color.white);
plot2.setRangeGridlinePaint(Color.white);
CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
cplot.add(plot1, 3);
cplot.add(plot2, 2);
cplot.setGap(8.0);
cplot.setDomainGridlinePaint(Color.white);
cplot.setDomainGridlinesVisible(true);
// return a new chart containing the overlaid plot...
JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
LegendTitle legend = new LegendTitle(cplot);
chart.addSubtitle(legend);
// set background
chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ()));
// set chart border
chart.setPadding (new RectangleInsets (10, 5, 5, 5));
chart.setBorderVisible (true);
chart.setBorderPaint (parseColor ("#cccccc"));
// set anti alias
chart.setAntiAlias (true);
BufferedImage img = chart.createBufferedImage (width, height);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
try{
ImageIO.write(img, "png", out);
}catch(IOException e){
log.warn("Error occurred while generating SiteStats chart image data", e);
}
return out.toByteArray();
}
示例3: createChart
import org.jfree.chart.axis.DateAxis; //导入方法依赖的package包/类
/**
* Creates a chart containing the current/baseline data (in that order) as well as markers for
* each anomaly interval. timeGranularity and windowMillis are used to determine the date format
* and spacing for tick marks on the domain (x) axis.
*/
public JFreeChart createChart(final XYDataset dataset, final String metric,
final TimeGranularity timeGranularity, final long windowMillis,
final Map<RawAnomalyResultDTO, String> anomaliesWithLabels) {
// create the chart...
final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // no chart title for email
// image
"Date (" + DEFAULT_TIME_ZONE.getID() + ")", // x axis label
metric, // y axis label
dataset, // data
true, // include legend
false, // tooltips - n/a if the chart will be saved as an img
false // urls - n/a if the chart will be saved as an img
);
// get a reference to the plot for further customisation...
final XYPlot plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
// dashboard webapp currently uses solid blue for current and dashed blue for baseline
// (5/2/2016)
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesShapesVisible(0, false);
renderer.setSeriesShapesVisible(1, false);
renderer.setSeriesPaint(0, Color.BLUE);
renderer.setSeriesPaint(1, Color.BLUE);
// http://www.java2s.com/Code/Java/Chart/JFreeChartLineChartDemo5showingtheuseofacustomdrawingsupplier.htm
// set baseline to be dashed
renderer.setSeriesStroke(1,
new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {
2.0f, 6.0f
}, 0.0f));
plot.setRenderer(renderer);
DateAxis axis = (DateAxis) plot.getDomainAxis();
DateTickUnit dateTickUnit = getDateTickUnit(timeGranularity, windowMillis);
SimpleDateFormat dateFormat = getDateFormat(timeGranularity);
axis.setDateFormatOverride(dateFormat);
axis.setTickUnit(dateTickUnit);
axis.setVerticalTickLabels(true);
List<Marker> anomalyIntervals = getAnomalyIntervals(anomaliesWithLabels);
for (Marker marker : anomalyIntervals) {
plot.addDomainMarker(marker);
}
return chart;
}
示例4: updatePlotter
import org.jfree.chart.axis.DateAxis; //导入方法依赖的package包/类
@Override
protected void updatePlotter() {
int categoryCount = prepareData();
String maxClassesProperty = ParameterService.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
int maxClasses = 20;
try {
if (maxClassesProperty != null)
maxClasses = Integer.parseInt(maxClassesProperty);
} catch (NumberFormatException e) {
//LogService.getGlobal().log("Series plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", LogService.WARNING);
LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.plotter.charts.SeriesChartPlotter.parsing_property_error");
}
boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;
JFreeChart chart = createChart(this.dataset, createLegend);
// set the background color for the chart...
chart.setBackgroundPaint(Color.white);
// domain axis
if (axis[INDEX] >= 0) {
if (!dataTable.isNominal(axis[INDEX])) {
if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
domainAxis.setTimeZone(Tools.getPreferredTimeZone());
chart.getXYPlot().setDomainAxis(domainAxis);
if (getRangeForDimension(axis[INDEX]) != null)
domainAxis.setRange(getRangeForDimension(axis[INDEX]));
domainAxis.setLabelFont(LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(LABEL_FONT);
domainAxis.setVerticalTickLabels(isLabelRotating());
}
} else {
LinkedHashSet<String> values = new LinkedHashSet<String>();
for (DataTableRow row : dataTable) {
String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
if (stringValue.length() > 40)
stringValue = stringValue.substring(0, 40);
values.add(stringValue);
}
ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]), values.toArray(new String[values.size()]));
categoryAxis.setLabelFont(LABEL_FONT_BOLD);
categoryAxis.setTickLabelFont(LABEL_FONT);
categoryAxis.setVerticalTickLabels(isLabelRotating());
chart.getXYPlot().setDomainAxis(categoryAxis);
}
}
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
legend.setPosition(RectangleEdge.TOP);
legend.setFrame(BlockBorder.NONE);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
legend.setItemFont(LABEL_FONT);
}
AbstractChartPanel panel = getPlotterPanel();
if (panel == null) {
panel = createPanel(chart);
} else {
panel.setChart(chart);
}
// ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
panel.getChartRenderingInfo().setEntityCollection(null);
}