Uses 180K of libraries. Click here for Pure Java version (1749L/12K/39K).
!759 !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; static S title = "A Chart!", valuesTitle = "Woot?"; p { // Make values final int NUM_POINTS = 25; final double[] values = new double[NUM_POINTS]; for (int i = 0; i < NUM_POINTS; i++) values[i] = (Math.cos(30*i*Math.PI/180)*10 + 50)*i/20; Line line1 = Plots.newLine(Data.newData(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(600, 450); chart.setTitle(title, WHITE, 14); chart.addHorizontalRangeMarker(40, 60, newColor(RED, 30)); chart.addVerticalRangeMarker(70, 90, newColor(GREEN, 30)); chart.setGrid(25, 25, 3, 2); // Defining axis info and styles AxisStyle axisStyle = AxisStyle.newAxisStyle(WHITE, 12, AxisTextAlignment.CENTER); AxisLabels xAxis = AxisLabelsFactory.newAxisLabels("Nov", "Dec", "Jan", "Feb", "Mar"); xAxis.setAxisStyle(axisStyle); AxisLabels xAxis2 = AxisLabelsFactory.newAxisLabels("2007", "2007", "2008", "2008", "2008"); xAxis2.setAxisStyle(axisStyle); AxisLabels yAxis = AxisLabelsFactory.newAxisLabels("", "25", "50", "75", "100"); AxisLabels xAxis3 = AxisLabelsFactory.newAxisLabels("Month", 50.0); xAxis3.setAxisStyle(AxisStyle.newAxisStyle(WHITE, 14, AxisTextAlignment.CENTER)); yAxis.setAxisStyle(axisStyle); AxisLabels yAxis2 = AxisLabelsFactory.newAxisLabels("Hits", 50.0); yAxis2.setAxisStyle(AxisStyle.newAxisStyle(WHITE, 14, AxisTextAlignment.CENTER)); yAxis2.setAxisStyle(axisStyle); // Adding axis info to chart. chart.addXAxisLabels(xAxis); chart.addXAxisLabels(xAxis2); chart.addXAxisLabels(xAxis3); chart.addYAxisLabels(yAxis); chart.addYAxisLabels(yAxis2); // 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); String url = chart.toURLString(); print("URL: " + url); showImage(url, "A Chart!"); }
Began life as a copy of #1001957
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002469 |
Snippet name: | A simpler chart with charts4j |
Eternal ID of this version: | #1002469/1 |
Text MD5: | 32444f19d465a576246fe57a87d17f06 |
Transpilation MD5: | 1e3bc7b31e310881328bfd55f590fc64 |
Author: | stefan |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-01-25 03:04:51 |
Source code size: | 2545 bytes / 67 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 776 / 832 |
Referenced in: | #1002471 - Charts Bot (test) #3000190 - Answer for stefanreich(>> t 20 questions) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |