minLine.setLineStyle(LineStyle.THIN_LINE);
minLine.setLegend("Min");
String title = String.format("%s (k=%d, %d trials per data point)", estimator, k, NUM_TRIALS);
XYLineChart chart = GCharts.newXYLineChart(maxLine, meanLine, minLine);
/*
List<String> xAxisLabels = new ArrayList<String>(xData.length);
for(int i=0; i<xData.length; i++)
{
if(i % (xData.length / 10) == 0)
{
double d = xData[i];
xAxisLabels.add(shortenNumericLabel(d));
}
}
chart.addXAxisLabels(AxisLabelsFactory.newAxisLabels(xAxisLabels));
*/
chart.addXAxisLabels(AxisLabelsFactory.newNumericRangeAxisLabels(xData[0], xData[xData.length - 1]));
chart.addXAxisLabels(AxisLabelsFactory.newAxisLabels("Cardinality", 50));
chart.addYAxisLabels(AxisLabelsFactory.newNumericRangeAxisLabels(minMin * 100, maxMax * 100));
chart.addYAxisLabels(AxisLabelsFactory.newAxisLabels("% Error", 50));
chart.setTitle(title);
chart.setSize(533, 400);
chart.setMargins(25, 25, 25, 25);
double good = DataUtil.scaleWithinRange(minMin, maxMax, new double[]{0.01}).getData()[0];
double bad = DataUtil.scaleWithinRange(minMin, maxMax, new double[]{0.03}).getData()[0];
double wrong = DataUtil.scaleWithinRange(minMin, maxMax, new double[]{0.05}).getData()[0];
if (0 <= good && good < 100) {
chart.addHorizontalRangeMarker(good, Math.min(bad, 100), Color.LIGHTGREEN);
}
if (0 <= bad && bad < 100) {
chart.addHorizontalRangeMarker(bad, Math.min(wrong, 100), Color.LIGHTGOLDENRODYELLOW);
}
if (wrong < 100) {
chart.addHorizontalRangeMarker(Math.max(wrong, 0), 100, Color.LIGHTCORAL);
}
String url = chart.toURLForHTML();
// Somewhat less than clean
String pageStart = "<html><head><title>" + title + "</title></head><body>";
String img = String.format("<img src=\"%s\"/>", url);
String pageEnd = "</body></html>";