Example usage for java.text NumberFormat NumberFormat

List of usage examples for java.text NumberFormat NumberFormat

Introduction

In this page you can find the example usage for java.text NumberFormat NumberFormat.

Prototype

protected NumberFormat() 

Source Link

Document

Sole constructor.

Usage

From source file:com.chart.JulianChart.java

/**
 * /*  ww  w .j ava 2  s.c om*/
 * @param name Chart name
 * @param axes Configuration of axes
 * @param abcissaName Abcissa name
 */
public JulianChart(String name, List<AxisChart> axes, String abcissaName) {
    super(name, Main.skeleton, axes, abcissaName);
    NumberAxis naAbcisa = (NumberAxis) abcissaAxis;

    NumberFormat nf = new NumberFormat() {

        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer((new JulianDay(number)).toString());
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer((new JulianDay(number)).toString());
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    };

    naAbcisa.setNumberFormatOverride(nf);
    abcissaFormat = nf;

}

From source file:com.wattzap.view.graphs.MMPGraph.java

public MMPGraph(XYSeries series) {
    super();/* w w  w . j av a 2s .  co m*/

    NumberAxis yAxis = new NumberAxis(userPrefs.messages.getString("poWtt"));
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    double maxY = series.getMaxY();
    yAxis.setRange(0, maxY + 20);
    yAxis.setTickLabelPaint(Color.white);
    yAxis.setLabelPaint(Color.white);

    LogAxis xAxis = new LogAxis(userPrefs.messages.getString("time"));
    xAxis.setTickLabelPaint(Color.white);
    xAxis.setBase(4);
    xAxis.setAutoRange(false);

    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    xAxis.setRange(1, series.getMaxX() + 500);
    xAxis.setNumberFormatOverride(new NumberFormat() {

        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {

            long millis = (long) number * 1000;

            if (millis >= 60000) {
                return new StringBuffer(String.format("%d m %d s",
                        TimeUnit.MILLISECONDS.toMinutes((long) millis),
                        TimeUnit.MILLISECONDS.toSeconds((long) millis)
                                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            } else {
                return new StringBuffer(String.format("%d s",

                        TimeUnit.MILLISECONDS.toSeconds((long) millis)
                                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            }
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer(String.format("%s", number));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    XYPlot plot = new XYPlot(new XYSeriesCollection(series), xAxis, yAxis,
            new XYLineAndShapeRenderer(true, false));

    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    chart.setBackgroundPaint(Color.gray);
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.darkGray);
    /*plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);*/

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(Color.white);
    domainAxis.setLabelPaint(Color.white);

    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(100, 800);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setBackground(Color.gray);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    setBackground(Color.black);
    chartPanel.revalidate();
    setVisible(true);
}

From source file:com.wattzap.view.graphs.SCHRGraph.java

public SCHRGraph(ArrayList<Telemetry> telemetry[]) {
    super();/*  w  w w  .ja v  a2  s  .co m*/
    this.telemetry = telemetry;

    final NumberAxis domainAxis = new NumberAxis("Time (h:m:s)");

    domainAxis.setVerticalTickLabels(true);
    domainAxis.setTickLabelPaint(Color.black);
    domainAxis.setAutoRange(true);

    domainAxis.setNumberFormatOverride(new NumberFormat() {
        @Override
        public StringBuffer format(double millis, StringBuffer toAppendTo, FieldPosition pos) {
            if (millis >= 3600000) {
                // hours, minutes and seconds
                return new StringBuffer(

                        String.format("%d:%d:%d", TimeUnit.MILLISECONDS.toHours((long) millis),
                                TimeUnit.MILLISECONDS.toMinutes(
                                        (long) millis - TimeUnit.MILLISECONDS.toHours((long) millis) * 3600000),
                                TimeUnit.MILLISECONDS.toSeconds((long) millis) - TimeUnit.MINUTES
                                        .toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            } else if (millis >= 60000) {
                // minutes and seconds
                return new StringBuffer(String.format("%d:%d", TimeUnit.MILLISECONDS.toMinutes((long) millis),
                        TimeUnit.MILLISECONDS.toSeconds((long) millis)
                                - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            } else {
                return new StringBuffer(String.format("%d", TimeUnit.MILLISECONDS.toSeconds((long) millis)
                        - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes((long) millis))));
            }
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer(String.format("%s", number));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    // create plot ...
    final XYItemRenderer powerRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return orange;
        }
    };
    powerRenderer.setSeriesPaint(0, orange);
    plot = new XYPlot();
    plot.setRenderer(0, powerRenderer);
    plot.setRangeAxis(0, powerAxis);
    plot.setDomainAxis(domainAxis);

    // add a second dataset and renderer...
    final XYItemRenderer cadenceRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return cornflower;
        }

        public Shape lookupLegendShape(int series) {
            return new Rectangle(15, 15);
        }
    };

    final ValueAxis cadenceAxis = new NumberAxis(userPrefs.messages.getString("cDrpm"));
    cadenceAxis.setRange(0, 200);

    // arguments of new XYLineAndShapeRenderer are to activate or deactivate
    // the display of points or line. Set first argument to true if you want
    // to draw lines between the points for e.g.
    plot.setRenderer(1, cadenceRenderer);
    plot.setRangeAxis(1, cadenceAxis);
    plot.mapDatasetToRangeAxis(1, 1);
    cadenceRenderer.setSeriesPaint(0, cornflower);

    // add a third dataset and renderer...
    final XYItemRenderer hrRenderer = new StandardXYItemRenderer() {
        Stroke regularStroke = new BasicStroke(0.7f);
        Color color;

        public void setColor(Color color) {
            this.color = color;
        }

        @Override
        public Stroke getItemStroke(int row, int column) {
            return regularStroke;
        }

        @Override
        public Paint getItemPaint(int row, int column) {
            return straw;
        }

    };

    // arguments of new XYLineAndShapeRenderer are to activate or deactivate
    // the display of points or line. Set first argument to true if you want
    // to draw lines between the points for e.g.
    final ValueAxis heartRateAxis = new NumberAxis(userPrefs.messages.getString("hrBpm"));
    heartRateAxis.setRange(0, 200);

    plot.setRenderer(2, hrRenderer);
    hrRenderer.setSeriesPaint(0, straw);

    plot.setRangeAxis(2, heartRateAxis);
    plot.mapDatasetToRangeAxis(2, 2);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setBackgroundPaint(Color.DARK_GRAY);
    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.getLegend().setBackgroundPaint(Color.gray);

    chartPanel = new ChartPanel(chart);

    // TODO: maybe remember sizes set by user?
    this.setPreferredSize(new Dimension(1200, 500));
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setBackground(Color.gray);

    setLayout(new BorderLayout());
    add(chartPanel, BorderLayout.CENTER);

    SmoothingPanel smoothingPanel = new SmoothingPanel(this);
    add(smoothingPanel, BorderLayout.SOUTH);

    //infoPanel = new InfoPanel();
    //add(infoPanel, BorderLayout.NORTH);
    setVisible(true);
}

From source file:view.PnStatistic.java

private ChartPanel createBarChart(CategoryDataset dataset) {
    JFreeChart barChart = ChartFactory.createBarChart3D("Thng k", "Th?i gian", "Thu nhp", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(barChart);
    CategoryPlot plot = barChart.getCategoryPlot();
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setNumberFormatOverride(new NumberFormat() {
        @Override/*from w  w  w . j a v  a  2s  . c  om*/
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer(CommonFunction.convertDoubleToMoney(number));
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return new StringBuffer(CommonFunction.convertDoubleToMoney(number));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });
    return chartPanel;
}

From source file:org.lanternpowered.server.statistic.StatisticNumberFormats.java

/**
 * Creates a new {@link NumberFormat} with the specified formatter function.
 *
 * @param formatter The formatter//from   ww w.  j a v a2  s. c  om
 * @return The number format
 */
public static NumberFormat of(Long2ObjectFunction<String> formatter,
        Object2LongThrowableFunction<String, ParseException> parser) {
    return new NumberFormat() {
        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            return format((long) number, toAppendTo, pos);
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return toAppendTo.append(formatter.apply(number));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            try {
                return parser.apply(source);
            } catch (ParseException e) {
                throw new RuntimeException(e);
            }
        }
    };
}

From source file:com.netflix.ice.basic.BasicWeeklyCostEmailService.java

public BasicWeeklyCostEmailService(List<Account> accounts, List<Region> regions, List<Product> products,
        int initDelaySec, int numWeeks, String urlPrefix, ApplicationGroupService applicationGroupService,
        String fromEmail, String bccEmail, String testEmail) {

    this.accounts = accounts;
    this.regions = regions;
    this.products = products;

    this.initDelaySec = initDelaySec;
    this.numWeeks = numWeeks;
    this.urlPrefix = urlPrefix;
    this.applicationGroupService = applicationGroupService;
    this.fromEmail = fromEmail;
    this.bccEmail = bccEmail;
    this.testEmail = testEmail;

    costFormatter = new NumberFormat() {
        @Override//  w w  w . j  a v  a 2s . c o m
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            return numberFormatter.format(number, toAppendTo, pos).insert(0, "$");
        }

        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            return numberFormatter.format(number, toAppendTo, pos).insert(0, "$");
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            throw new UnsupportedOperationException();
        }
    };

    percentageFormat.setMinimumFractionDigits(1);
    percentageFormat.setMaximumFractionDigits(1);
}

From source file:edu.cuny.cat.ui.ClockPanel.java

@Override
public void setup(final ParameterDatabase parameters, final Parameter base) {
    clock = GameController.getInstance().getClock();

    dataset = new DefaultValueDataset();

    meterplot = new MyMeterPlot(dataset) {
        /**//from   w w w  .j  av  a  2s.c o  m
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void drawValueLabel(final Graphics2D g2, final Rectangle2D area) {
            g2.setFont(getValueFont());
            g2.setPaint(getValuePaint());
            String valueStr = "No value";
            if (dataset != null) {
                final Number n = dataset.getValue();
                if (n != null) {
                    if (n.intValue() == 0) {
                        valueStr = "to start";
                    } else if (n.intValue() == clock.getGameLen() * clock.getDayLen()) {
                        valueStr = "done";
                    } else {
                        valueStr = "day " + (n.intValue() / clock.getDayLen()) + ", round "
                                + (n.intValue() % clock.getDayLen());
                    }
                }
            }
            final float x = (float) area.getCenterX();
            final float y = (float) area.getCenterY() + MeterPlot.DEFAULT_CIRCLE_SIZE;
            TextUtilities.drawAlignedString(valueStr, g2, x, y, TextAnchor.TOP_CENTER);
        }

    };
    meterplot.setRange(new Range(0, clock.getDayLen() * clock.getGameLen()));

    meterplot.setNeedlePaint(
            parameters.getColorWithDefault(base.push(ClockPanel.P_NEEDLE), null, Color.darkGray));

    meterplot.setDialBackgroundPaint(new Color(0, 255, 0, 64));
    meterplot.setDialOutlinePaint(Color.gray);
    meterplot.setDialShape(DialShape.CHORD);

    meterplot.setMeterAngle(parameters.getIntWithDefault(base.push(ClockPanel.P_ANGLE), null, 260));

    meterplot.setTickLabelsVisible(true);
    meterplot.setTickLabelFont(new Font("Dialog", 1, 10));
    meterplot.setTickLabelPaint(Color.darkGray);
    meterplot.setTickSize(clock.getDayLen());
    meterplot.setTickPaint(Color.lightGray);

    meterplot.setValuePaint(Color.black);
    meterplot.setValueFont(new Font("Dialog", 1, 14));
    meterplot.setUnits("");
    meterplot.setTickLabelFormat(new NumberFormat() {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public StringBuffer format(final double number, final StringBuffer toAppendTo,
                final FieldPosition pos) {
            return format((long) number, toAppendTo, pos);
        }

        @Override
        public StringBuffer format(final long number, final StringBuffer toAppendTo, final FieldPosition pos) {

            if (number % clock.getDayLen() == 0) {
                toAppendTo.append(String.valueOf(number / clock.getDayLen()));
            }
            return toAppendTo;
        }

        @Override
        public Number parse(final String source, final ParsePosition parsePosition) {
            return null;
        }

    });

    final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, meterplot, false);

    final ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new Dimension(parameters.getIntWithDefault(base.push(ClockPanel.P_WIDTH), null, 200),
            parameters.getIntWithDefault(base.push(ClockPanel.P_HEIGHT), null, 200)));

    add(panel, BorderLayout.CENTER);

    initIterationLabel();

    initScoreReport();
}

From source file:de.citec.csra.allocation.vis.MovingChart.java

/**
 * Creates a sample chart.//from w w w. j av a2  s.  c  o m
 *
 * @param dataset the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(null, "Time", "Resource", dataset, false, true,
            false);

    final XYPlot plot = result.getXYPlot();

    plot.addDomainMarker(this.marker);
    plot.setBackgroundPaint(new Color(0xf8f8ed));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);
    xaxis.setTickLabelsVisible(false);
    //Domain axis would show data of 60 seconds for a time
    xaxis.setFixedAutoRange(this.past + this.future); // 60 seconds
    xaxis.setVerticalTickLabels(true);
    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setAutoRangeMinimumSize(1.8);
    yaxis.setAutoRange(true);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setTickUnit(new NumberTickUnit(1));
    range.setNumberFormatOverride(new NumberFormat() {
        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            return format((long) number, toAppendTo, pos);
        }

        private String getID(long number) {
            return values.entrySet().stream().filter(e -> e.equals(number)).findFirst().get().getKey();
        }

        @Override
        public StringBuffer format(long number, StringBuffer ap, FieldPosition pos) {
            String id = "N/A";
            if (number == 0) {
                id = "(Time)";
            }
            if (values.containsValue(number)) {
                for (Map.Entry<String, Long> entry : values.entrySet()) {
                    if (entry.getValue() == number) {
                        id = entry.getKey();
                        break;
                    }
                }
            }
            id = id.replaceFirst("/$", "");
            ap.append(id);
            if (id.length() > 32) {
                ap.replace(15, ap.length() - 15, "..");
            }
            return ap;
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    //      this.chart.getXYPlot().getRenderer(1).set
    //      XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) this.chart.getXYPlot().getRendererForDataset(dataset);
    return result;
}

From source file:com.projity.pm.graphic.chart.TimeChartPanel.java

protected JFreeChart buildChart() {
    JFreeChart newChart = ChartHelper.createChart(chartInfo.getModel().getDataset(), chartInfo.isHistogram(),
            chartInfo.getModel().getSecondDataset());
    NumberFormat numberFormat = NumberFormat.getPercentInstance(); // default
    Object[] traces = chartInfo.getTraces();
    // chartInfo.getModel().dumpDataset(traces);
    if (!chartInfo.isSimple() && (traces.length > 0 && traces[0] instanceof Field)) {
        Field field = (Field) traces[0];
        if (field.isMoney()) {
            numberFormat = new NumberFormat() {

                @Override/*from  w w w  . java 2  s. co  m*/
                public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
                    return toAppendTo.append(Money.formatCurrency(number, true));
                }

                @Override
                public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
                    // TODO Auto-generated method stub
                    return null;
                }

                @Override
                public Number parse(String source, ParsePosition parsePosition) {
                    // TODO Auto-generated method stub
                    return null;
                }
            };
        } else {
            Format format = field.getFormat();
            if (format instanceof NumberFormat)
                numberFormat = (NumberFormat) format;
            else
                numberFormat = NumberFormat.getNumberInstance();
        }
    }

    ((NumberAxis) newChart.getXYPlot().getRangeAxis()).setNumberFormatOverride(numberFormat);
    return newChart;
}

From source file:org.testeditor.dashboard.TableDurationTrend.java

/**
 * designs and creates graph from data sets.
 * //from w  w w.  j  av  a  2  s . co  m
 * @param objektList
 *            list of all suite GoogleSucheSuite runs <AllRunsResult>
 * @param parent
 *            composite parent
 * @param modelService
 *            to find part label
 * @param window
 *            trimmed window
 * @param app
 *            org.eclipse.e4.ide.application
 */
@SuppressWarnings({ "serial" })
@Inject
@Optional
public void createControls(@UIEventTopic("Testobjektlist") List<AllRunsResult> objektList, Composite parent,
        EModelService modelService, MWindow window, MApplication app) {
    MPart mPart = (MPart) modelService.find("org.testeditor.ui.part.2", app);
    String[] arr = objektList.get(0).getFilePath().getName().split("\\.");
    String filenameSplitted = arr[arr.length - 1];
    mPart.setLabel(translationService.translate("%dashboard.table.label.duration", CONTRIBUTOR_URI) + " "
            + filenameSplitted);
    mPart.setTooltip(translationService.translate("%dashboard.table.label.duration", CONTRIBUTOR_URI) + " "
            + objektList.get(0).getFilePath().getName());
    parent.setLayout(new FillLayout());

    // create the chart...
    chart = ChartFactory.createBarChart3D(null, // chart
            // title
            translationService.translate("%dashboard.table.label.duration.axis.dates", CONTRIBUTOR_URI), // domain
            // X axis
            // label
            translationService.translate("%dashboard.table.label.duration.axis.duration", CONTRIBUTOR_URI)
                    + " h:m:s:ms", // range
            // Y axis
            // label
            createDataset(objektList), // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    // y axis right
    plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT);
    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setNumberFormatOverride(new NumberFormat() { // show duration
        // values in
        // h:m:s:ms
        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            // return new StringBuffer(String.format("%f", number));
            return new StringBuffer(String.format(formatDuration(number)));
        }

        @Override
        public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
            // return new StringBuffer(String.format("%f", number));
            return new StringBuffer(String.format(formatDuration(number)));
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{1} "
            + translationService.translate("%dashboard.table.label.duration.axis.duration", CONTRIBUTOR_URI)
            + ": {2}ms", NumberFormat.getInstance()));
    renderer.setDrawBarOutline(false);
    renderer.setMaximumBarWidth(.15);
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(1.57));

    Color color = toAwtColor(ColorConstants.COLOR_BLUE);
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, color, 0, 0, color);
    renderer.setSeriesPaint(0, gp0);

    chartComposite = new ChartComposite(parent, SWT.EMBEDDED);
    chartComposite.setSize(800, 800);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    chartComposite.setLayoutData(data);
    chartComposite.setHorizontalAxisTrace(false);
    chartComposite.setVerticalAxisTrace(false);
    chartComposite.setChart(chart);
    chartComposite.pack(true);
    chartComposite.setVisible(true);
    chartComposite.forceRedraw();
    parent.layout();
}