code sample for creating a simple chart

94 views
Skip to first unread message

lifemichael

unread,
Jun 2, 2013, 3:04:27 AM6/2/13
to shenkar-industrial-en...@googlegroups.com
package com.example.vaadinchartsdemo;

import com.vaadin.addon.charts.Chart;
import com.vaadin.addon.charts.model.ChartType;
import com.vaadin.addon.charts.model.Configuration;
import com.vaadin.addon.charts.model.ListSeries;
import com.vaadin.addon.charts.model.XAxis;
import com.vaadin.addon.charts.model.YAxis;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

/**
 * Main UI class
 */
@SuppressWarnings("serial")
public class VaadinchartsdemoUI extends UI {

@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);

Chart chart = new Chart(ChartType.BAR);
chart.setWidth("400px");
chart.setHeight("300px");
// Modify the default configuration a bit
Configuration conf = chart.getConfiguration();
conf.setTitle("Planets");
conf.setSubTitle("The bigger they are the harder they pull");
conf.getLegend().setEnabled(false); // Disable legend
// The data
ListSeries series = new ListSeries("Diameter");
series.setData(4900, 12100, 12800, 6800, 143000, 125000, 51100, 49500);
conf.addSeries(series);
// Set the category labels on the axis correspondingly
XAxis xaxis = new XAxis();
xaxis.setCategories("Mercury", "Venus", "Earth", "Mars", "Jupiter",
"Saturn", "Uranus", "Neptune");
xaxis.setTitle("Planet");
conf.addxAxis(xaxis);
// Set the Y axis title
YAxis yaxis = new YAxis();
yaxis.setTitle("Diameter");
yaxis.getLabels().setFormatter(
"function() {return Math.floor(this.value/500) + \'Mm\';}");
yaxis.getLabels().setStep(2);
conf.addyAxis(yaxis);

// Adding chart to our layout
layout.addComponent(chart);

}

}

עמי ששון

unread,
Jun 10, 2013, 6:50:27 AM6/10/13
to shenkar-industrial-en...@googlegroups.com
מיכאל שלום רב
 ??כלומר איך אני שולף נתונים לתוך הטבלה ולא מזין את הנתונים ידנית ,JAVAרציתי לדעת איך אני מעביר את הנתונים מתוך הבסיס נתונים ל

Haim Michael

unread,
Jun 10, 2013, 5:56:26 PM6/10/13
to shenkar-industrial-en...@googlegroups.com
שלום עמי,

בשיעור האחרון הסברנו בדיוק כיצד לעשות זאת. אני לא מכיר דרך לסכם את מה שהיה בשיעור האחרון באימייל. אני מציע שתיעזר בתלמידים אחרים בכיתה... ואם יש שאלות פתוחות אני אשמח לסייע במסגרת שעת הקבלה שלי ביום חמישי הקרוב 1030 בחדר 162. 

בברכה,
חיים.


--
You received this message because you are subscribed to the Google Groups "shenkar-industrial-engineering-java-2013-02" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shenkar-industrial-engineer...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Reply all
Reply to author
Forward
0 new messages