Package com.extjs.gxt.charts.client.model

Source Code of com.extjs.gxt.charts.client.model.LineDataProvider

/*
* Sencha GXT 2.3.1 - Sencha for GWT
* Copyright(c) 2007-2013, Sencha, Inc.
* licensing@sencha.com
*
* http://www.sencha.com/products/gxt/license/
*/
package com.extjs.gxt.charts.client.model;

import com.extjs.gxt.charts.client.model.axis.XAxis;
import com.extjs.gxt.charts.client.model.charts.ChartConfig;
import com.extjs.gxt.charts.client.model.charts.LineChart;
import com.extjs.gxt.ui.client.data.ModelData;

/**
* <code>DataProvider</code> implementation for line charts.
*/
public class LineDataProvider extends PieDataProvider {

  public LineDataProvider(String valueProperty) {
    super(valueProperty);
  }

  public LineDataProvider(String valueProperty, String labelProperty, String textProperty) {
    super(valueProperty, labelProperty, textProperty);
  }

  public LineDataProvider(String valueProperty, String labelProperty) {
    super(valueProperty, labelProperty);
  }

  @Override
  public void populateData(ChartConfig config) {
    LineChart chart = (LineChart) config;
    chart.getValues().clear();

    XAxis xAxis = null;
    if (labelProperty != null || labelProvider != null) {
      xAxis = chart.getModel().getXAxis();
      if (xAxis == null) {
        xAxis = new XAxis();
        chart.getModel().setXAxis(xAxis);
      } else {
        xAxis.getLabels().getLabels().clear();
      }
    }

    boolean first = true;
    for (ModelData m : store.getModels()) {
      Number n = getValue(m);
      if (n == null) {
        chart.addNullValue();
      } else {
        chart.addValues(n);
        maxYValue = first ? n.doubleValue() : Math.max(maxYValue, n.doubleValue());
        minYValue = first ? n.doubleValue() : Math.min(minYValue, n.doubleValue());
        first = false;
      }
      if (xAxis != null) {
        xAxis.addLabels(getLabel(m));
      }
    }
  }
}
TOP

Related Classes of com.extjs.gxt.charts.client.model.LineDataProvider

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.