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).

!752

!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;

p {
  // Defining lines
  final int NUM_POINTS = 25;
  final double[] competition = new double[NUM_POINTS];
  final double[] mywebsite = new double[NUM_POINTS];
  for (int i = 0; i < NUM_POINTS; i++) {
      competition[i] = 100-(Math.cos(30*i*Math.PI/180)*10 + 50)*i/20;
      mywebsite[i] = (Math.cos(30*i*Math.PI/180)*10 + 50)*i/20;
  }
  Line line1 = Plots.newLine(Data.newData(mywebsite), com.googlecode.charts4j.Color.newColor("CA3D05"), "My Website.com");
  line1.setLineStyle(LineStyle.newLineStyle(3, 1, 0));
  line1.addShapeMarkers(DIAMOND, newColor("CA3D05"), 12);
  line1.addShapeMarkers(DIAMOND, WHITE, 8);
  Line line2 = Plots.newLine(Data.newData(competition), SKYBLUE, "Competition.com");
  line2.setLineStyle(LineStyle.newLineStyle(3, 1, 0));
  line2.addShapeMarkers(DIAMOND, SKYBLUE, 12);
  line2.addShapeMarkers(DIAMOND, WHITE, 8);


  // Defining chart.
  LineChart chart = GCharts.newLineChart(line1, line2);
  chart.setSize(600, 450);
  chart.setTitle("Web Traffic|(in billions of hits)", 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!");
}

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: 1059 / 1072
Referenced in: [show references]