Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

67
LINES

< > BotCompany Repo | #1001957 // Test charts4j

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 180K of libraries. Click here for Pure Java version (1088L/8K/25K).

1  
!752
2  
!1001955 // charts4j
3  
4  
import com.googlecode.charts4j.*;
5  
import static com.googlecode.charts4j.Color.*;
6  
import static com.googlecode.charts4j.Shape.*;
7  
import static com.googlecode.charts4j.UrlUtil.normalize;
8  
import java.awt.Color;
9  
import java.awt.Shape;
10  
11  
p {
12  
  // Defining lines
13  
  final int NUM_POINTS = 25;
14  
  final double[] competition = new double[NUM_POINTS];
15  
  final double[] mywebsite = new double[NUM_POINTS];
16  
  for (int i = 0; i < NUM_POINTS; i++) {
17  
      competition[i] = 100-(Math.cos(30*i*Math.PI/180)*10 + 50)*i/20;
18  
      mywebsite[i] = (Math.cos(30*i*Math.PI/180)*10 + 50)*i/20;
19  
  }
20  
  Line line1 = Plots.newLine(Data.newData(mywebsite), com.googlecode.charts4j.Color.newColor("CA3D05"), "My Website.com");
21  
  line1.setLineStyle(LineStyle.newLineStyle(3, 1, 0));
22  
  line1.addShapeMarkers(DIAMOND, newColor("CA3D05"), 12);
23  
  line1.addShapeMarkers(DIAMOND, WHITE, 8);
24  
  Line line2 = Plots.newLine(Data.newData(competition), SKYBLUE, "Competition.com");
25  
  line2.setLineStyle(LineStyle.newLineStyle(3, 1, 0));
26  
  line2.addShapeMarkers(DIAMOND, SKYBLUE, 12);
27  
  line2.addShapeMarkers(DIAMOND, WHITE, 8);
28  
29  
30  
  // Defining chart.
31  
  LineChart chart = GCharts.newLineChart(line1, line2);
32  
  chart.setSize(600, 450);
33  
  chart.setTitle("Web Traffic|(in billions of hits)", WHITE, 14);
34  
  chart.addHorizontalRangeMarker(40, 60, newColor(RED, 30));
35  
  chart.addVerticalRangeMarker(70, 90, newColor(GREEN, 30));
36  
  chart.setGrid(25, 25, 3, 2);
37  
38  
  // Defining axis info and styles
39  
  AxisStyle axisStyle = AxisStyle.newAxisStyle(WHITE, 12, AxisTextAlignment.CENTER);
40  
  AxisLabels xAxis = AxisLabelsFactory.newAxisLabels("Nov", "Dec", "Jan", "Feb", "Mar");
41  
  xAxis.setAxisStyle(axisStyle);
42  
  AxisLabels xAxis2 = AxisLabelsFactory.newAxisLabels("2007", "2007", "2008", "2008", "2008");
43  
  xAxis2.setAxisStyle(axisStyle);
44  
  AxisLabels yAxis = AxisLabelsFactory.newAxisLabels("", "25", "50", "75", "100");
45  
  AxisLabels xAxis3 = AxisLabelsFactory.newAxisLabels("Month", 50.0);
46  
  xAxis3.setAxisStyle(AxisStyle.newAxisStyle(WHITE, 14, AxisTextAlignment.CENTER));
47  
  yAxis.setAxisStyle(axisStyle);
48  
  AxisLabels yAxis2 = AxisLabelsFactory.newAxisLabels("Hits", 50.0);
49  
  yAxis2.setAxisStyle(AxisStyle.newAxisStyle(WHITE, 14, AxisTextAlignment.CENTER));
50  
  yAxis2.setAxisStyle(axisStyle);
51  
52  
  // Adding axis info to chart.
53  
  chart.addXAxisLabels(xAxis);
54  
  chart.addXAxisLabels(xAxis2);
55  
  chart.addXAxisLabels(xAxis3);
56  
  chart.addYAxisLabels(yAxis);
57  
  chart.addYAxisLabels(yAxis2);
58  
59  
  // Defining background and chart fills.
60  
  chart.setBackgroundFill(Fills.newSolidFill(newColor("1F1D1D")));
61  
  LinearGradientFill fill = Fills.newLinearGradientFill(0, newColor("363433"), 100);
62  
  fill.addColorAndOffset(newColor("2E2B2A"), 0);
63  
  chart.setAreaFill(fill);
64  
  String url = chart.toURLString();
65  
  print("URL: " + url);
66  
  showImage(url, "A Chart!");
67  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1189 stefan Works :) 2015-12-09 19:40:06

add comment

Snippet ID: #1001957
Snippet name: Test charts4j
Eternal ID of this version: #1001957/1
Text MD5: 1c2969219e5b0c1c9cc7ac2e70b7d851
Transpilation MD5: 42cf4371357e0e1dc2e87ee7dcc5ac51
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-09 19:51:42
Source code size: 2885 bytes / 67 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1056 / 1068
Referenced in: [show references]