Uses 180K of libraries. Click here for Pure Java version (4271L/29K/96K).
!7 lib 1001955 // charts4j import com.googlecode.charts4j.*; import static com.googlecode.charts4j.Color.*; import static com.googlecode.charts4j.Shape.*; import static com.googlecode.charts4j.UrlUtil.normalize; import java.awt.Color; import java.awt.Shape; answer { if (jmatchStart("chart", s, m)) exceptionToUser { S title = s; int width = 300, height = 220; // Make values s = m.rest(); print("Chart: rest = " + quote(s)); if (jmatchStart("*", s, m) && isQuoted(m.get(0))) { title = unquote(m.get(0)); s = m.rest(); print("Chart: rest2 = " + quote(s)); } Double base = null; if (jmatchStart("base *", s, m)) { base = parseDouble(m.unq(0)); s = m.rest(); } L<S> tok = asList(s.split(" +")); if (!empty(tok)) { final int NUM_POINTS = l(tok); final double[] values = new double[NUM_POINTS]; for (int i = 0; i < NUM_POINTS; i++) values[i] = parseDouble(tok.get(i)); print("Chart values: " + structure(values)); double minValue = base != null ? base : min(values), maxValue = max(values); print("Chart: min/max=" + minValue + "/" + maxValue); Line line1 = Plots.newLine(DataUtil.scaleWithinRange(minValue, maxValue, values), com.googlecode.charts4j.Color.newColor("CA3D05"), ""/*valuesTitle*/); line1.setLineStyle(LineStyle.newLineStyle(3, 1, 0)); line1.addShapeMarkers(DIAMOND, newColor("CA3D05"), 12); line1.addShapeMarkers(DIAMOND, WHITE, 8); // Defining chart. LineChart chart = GCharts.newLineChart(line1); chart.setSize(width, height); chart.setTitle(title, BLACK, 14); //chart.setGrid(25, 25, 3, 2); // Adding axis info to chart. // Let's try this... works with positive values chart.addYAxisLabels(AxisLabelsFactory.newNumericRangeAxisLabels(minValue, maxValue)); // Defining background and chart fills. /* chart.setBackgroundFill(Fills.newSolidFill(newColor("1F1D1D"))); LinearGradientFill fill = Fills.newLinearGradientFill(0, newColor("363433"), 100); fill.addColorAndOffset(newColor("2E2B2A"), 0); chart.setAreaFill(fill); */ ret returnImage(chart.toURLString()); } } }
Began life as a copy of #1002471
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xfasiavlzxuf
No comments. add comment