Who worked with TeeChart Java for Android? Help is needed. Actually, I need to draw a Gannt diagram, but I cannot adjust this diagram. I draw it like this:

public class GantActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Series ser = new Gantt(); TChart chart = new TChart(this); ser = chart.addSeries(gan); ser.add(SetGantt("2012-04-04 13:40"), SetGantt("2012-04-04 17:20")); ser.add(SetGantt("2012-04-05 12:00"), SetGantt("2012-04-05 13:00")); setContentView(chart); } // Тут мы преобразовываем строку в дату-время public double SetGantt(String dateBegin) { DateTime cal = (DateTime) DateTime.getToday(); try { String str_date = dateBegin; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date date1 = formatter.parse(str_date); cal.set(DateTime.DAY_OF_MONTH, date1.getDay()); cal.set(DateTime.YEAR, date1.getYear()); cal.set(DateTime.MONTH, date1.getMonth()); cal.set(DateTime.HOUR_OF_DAY, date1.getHours()); cal.set(DateTime.MINUTE, date1.getMinutes()); } catch (Exception e) { } double ti = cal.toDouble(); return ti; } } 

as stated in the certificate:

int add(double start, double endDate, double y) Adds a new Gantt bar with start and end coordinates to the Series.

I don’t understand what I’m doing wrong ... he draws me 2 bands with incomprehensible date / time and a type of long. Instead of double, substituted DateTime, but also did not bring anything

Also help offers:

int add(DateTime start, DateTime endDate, double y, Color color) Adds a new Gantt point to the series, at the start and endDate positions. int add(DateTime start, DateTime endDate, double y, java.lang.String text) int add(DateTime start, DateTime endDate, double y, java.lang.String text, Color color) void add(double[] xValues, double[] yValues, boolean append) int add(double x, double y) Adds a new point with specified x and y values. int add(double start, double endDate, double y) Adds a new Gantt bar with start and end coordinates to the Series. int add(double start, double endDate, double y, Color color) Adds a new Gantt bar with start and end coordinates and color. int add(double start, double endDate, double y, java.lang.String text) Adds a new Gantt bar with start and end coordinates and label. int add(double start, double endDate, double y, java.lang.String text, Color color) Adds a new Gantt bar with start and end coordinates, label and color. protected void addSampleValues(int numValues) Adds random values to series.

Moreover, fillSampleValues ​​() fills everything nicely, but I cannot find out what parameters it conveys.

1 answer 1

I do not know anything about TeeChart , nevertheless, from the most general considerations I would venture to ask: why are you writing setContentView(chart); ?

The idea is to do it like this:

  1. We create main.xml - your layout, where there is a certain prepared place for inserting TChart - say, a certain ViewGroup called myView
  2. Create a TChart - approximately as you have indicated
  3. Next, we make a TChart insert into your layout, something like myView.addView(chart)

In general, if TeeChart is a normal component, then, in theory, you can immediately specify it in main.xml and take it via the chart=(TChart )findViewById() and directly add your Gantts there.

  • No, I have a difficulty with the formation of the dumb strips. I can not correctly insert the data, or I can not format the workspace ... - baralgin1003
  • or at least tell me how to properly convert DateTime to a double. DateTime inherits everything from GregorianCalendar, but also has its own buns. With the toDouble method when building the strips, an error occurs and the prog closes - baralgin1003
  • one
    DateTime in double how? Elementary Watson: take (double )Calendar.getTimeInMillis() - Barmaley
  • not everything is so simple ... does not work. getTimeInMillis () found an example on a foreign site, this is how gantt.add (new DateTime (2003, 4, 2), new DateTime (2003, 4, 8), 2, "is put C "); and how to put time in this format? - baralgin1003