lecho.lib.hellocharts.view.Chart Java Examples

The following examples show how to use lecho.lib.hellocharts.view.Chart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PieChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
public PieChartRenderer(Context context, Chart chart, PieChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    touchAdditional = ChartUtils.dp2px(density, DEFAULT_TOUCH_ADDITIONAL_DP);

    slicePaint.setAntiAlias(true);
    slicePaint.setStyle(Paint.Style.FILL);

    centerCirclePaint.setAntiAlias(true);
    centerCirclePaint.setStyle(Paint.Style.FILL);
    centerCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));

    centerCircleText1Paint.setAntiAlias(true);
    centerCircleText1Paint.setTextAlign(Align.CENTER);

    centerCircleText2Paint.setAntiAlias(true);
    centerCircleText2Paint.setTextAlign(Align.CENTER);

    separationLinesPaint.setAntiAlias(true);
    separationLinesPaint.setStyle(Paint.Style.STROKE);
    separationLinesPaint.setStrokeCap(Paint.Cap.ROUND);
    separationLinesPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    separationLinesPaint.setColor(Color.TRANSPARENT);
}
 
Example #2
Source File: LineChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
public LineChartRenderer(Context context, Chart chart, LineChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;

    touchToleranceMargin = ChartUtils.dp2px(density, DEFAULT_TOUCH_TOLERANCE_MARGIN_DP);

    linePaint.setAntiAlias(true);
    linePaint.setStyle(Paint.Style.STROKE);
    linePaint.setStrokeCap(Cap.ROUND);
    linePaint.setStrokeWidth(ChartUtils.dp2px(density, DEFAULT_LINE_STROKE_WIDTH_DP));

    pointPaint.setAntiAlias(true);
    pointPaint.setStyle(Paint.Style.FILL);

    checkPrecision = ChartUtils.dp2px(density, 2);

}
 
Example #3
Source File: AbstractChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
public AbstractChartRenderer(Context context, Chart chart) {
    this.density = context.getResources().getDisplayMetrics().density;
    this.scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
    this.chart = chart;
    this.computator = chart.getChartComputator();

    labelMargin = ChartUtils.dp2px(density, DEFAULT_LABEL_MARGIN_DP);
    labelOffset = labelMargin;

    labelPaint.setAntiAlias(true);
    labelPaint.setStyle(Paint.Style.FILL);
    labelPaint.setTextAlign(Align.LEFT);
    labelPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
    labelPaint.setColor(Color.WHITE);

    labelBackgroundPaint.setAntiAlias(true);
    labelBackgroundPaint.setStyle(Paint.Style.FILL);
}
 
Example #4
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float) ((86400000 / 2.5) / FUZZER), 0);
    double distance_to_move = ((new Date().getTime())/ FUZZER) - viewport.left - (((viewport.right - viewport.left) /2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #5
Source File: ChartTouchHandler.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
public ChartTouchHandler(Context context, Chart chart) {
    this.chart = chart;
    this.computator = chart.getChartComputator();
    this.renderer = chart.getChartRenderer();
    gestureDetector = new GestureDetector(context, new ChartGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(context, new ChartScaleGestureListener());
    chartScroller = new ChartScroller(context);
    chartZoomer = new ChartZoomer(context, ZoomType.HORIZONTAL_AND_VERTICAL);
}
 
Example #6
Source File: PreviewChartTouchHandler.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
public PreviewChartTouchHandler(Context context, Chart chart) {
    super(context, chart);
    gestureDetector = new GestureDetector(context, new PreviewChartGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(context, new ChartScaleGestureListener());

    // Disable value touch and selection mode, by default not needed for preview chart.
    isValueTouchEnabled = false;
    isValueSelectionEnabled = false;
}
 
Example #7
Source File: ColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
public ColumnChartRenderer(Context context, Chart chart, ColumnChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    subcolumnSpacing = ChartUtils.dp2px(density, DEFAULT_SUBCOLUMN_SPACING_DP);
    touchAdditionalWidth = ChartUtils.dp2px(density, DEFAULT_COLUMN_TOUCH_ADDITIONAL_WIDTH_DP);

    columnPaint.setAntiAlias(true);
    columnPaint.setStyle(Paint.Style.FILL);
    columnPaint.setStrokeCap(Cap.SQUARE);
}
 
Example #8
Source File: AxesRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
public AxesRenderer(Context context, Chart chart) {
    this.chart = chart;
    computator = chart.getChartComputator();
    density = context.getResources().getDisplayMetrics().density;
    scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
    axisMargin = ChartUtils.dp2px(density, DEFAULT_AXIS_MARGIN_DP);
    for (int position = 0; position < 4; ++position) {
        labelPaintTab[position].setStyle(Paint.Style.FILL);
        labelPaintTab[position].setAntiAlias(true);
        namePaintTab[position].setStyle(Paint.Style.FILL);
        namePaintTab[position].setAntiAlias(true);
        linePaintTab[position].setStyle(Paint.Style.STROKE);
        linePaintTab[position].setAntiAlias(true);
    }
}
 
Example #9
Source File: ComboLineColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
public ComboLineColumnChartRenderer(Context context, Chart chart, ColumnChartRenderer columnChartRenderer,
                                    LineChartRenderer lineChartRenderer) {
    super(context, chart);

    this.columnChartRenderer = columnChartRenderer;
    this.lineChartRenderer = lineChartRenderer;

    renderers.add(this.columnChartRenderer);
    renderers.add(this.lineChartRenderer);
}
 
Example #10
Source File: ChartViewportAnimatorV14.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
public ChartViewportAnimatorV14(Chart chart) {
    this.chart = chart;
    animator = ValueAnimator.ofFloat(0.0f, 1.0f);
    animator.addListener(this);
    animator.addUpdateListener(this);
    animator.setDuration(FAST_ANIMATION_DURATION);
}
 
Example #11
Source File: CheckableLineChartRenderer.java    From SoloPi with Apache License 2.0 5 votes vote down vote up
public CheckableLineChartRenderer(Context context, Chart chart, LineChartDataProvider dataProvider) {
    super(context, chart, dataProvider);
    this.dataProvider = dataProvider;
    checkedPaint = new Paint();
    checkedPaint.setColor(checkedColor);
    checkedPaint.setAntiAlias(true);
    checkedPaint.setStyle(Paint.Style.FILL);
}
 
Example #12
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float)((86400000 / 2.5)/fuzzer), 0);
    double distance_to_move = ((new Date().getTime())/fuzzer) - viewport.left - (((viewport.right - viewport.left) /2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #13
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart, float hours) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float) ((86400000 / hours) / FUZZER), 0);
    double distance_to_move = ((new Date().getTime()) / FUZZER) - viewport.left - (((viewport.right - viewport.left) / 2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #14
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float) ((86400000 / 2.5) / FUZZER), 0);
    double distance_to_move = ((new Date().getTime())/ FUZZER) - viewport.left - (((viewport.right - viewport.left) /2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #15
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart, float hours) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float) ((86400000 / hours) / FUZZER), 0);
    double distance_to_move = ((new Date().getTime()) / FUZZER) - viewport.left - (((viewport.right - viewport.left) / 2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #16
Source File: BgGraphBuilder.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float) ((86400000 / 2.5) / FUZZER), 0);
    double distance_to_move = ((new Date().getTime())/ FUZZER) - viewport.left - (((viewport.right - viewport.left) /2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #17
Source File: BgGraphBuilder.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float)((86400000 / 2.5)/fuzz), 0);
    double distance_to_move = ((new Date().getTime())/fuzz) - viewport.left - (((viewport.right - viewport.left) /2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #18
Source File: BgGraph.java    From HAPP with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float) (86400000 / 2.5), 0);
    double distance_to_move = (new Date().getTime()) - viewport.left - (((viewport.right - viewport.left) / 2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #19
Source File: BgGraphBuilder.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
public Viewport advanceViewport(Chart chart, Chart previewChart) {
    viewport = new Viewport(previewChart.getMaximumViewport());
    viewport.inset((float)((86400000 / 2.5)/fuzz), 0);
    double distance_to_move = ((new Date().getTime())/fuzz) - viewport.left - (((viewport.right - viewport.left) /2));
    viewport.offset((float) distance_to_move, 0);
    return viewport;
}
 
Example #20
Source File: ComboLineColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public ComboLineColumnChartRenderer(Context context, Chart chart, ColumnChartDataProvider columnChartDataProvider,
                                    LineChartRenderer lineChartRenderer) {
    this(context, chart, new ColumnChartRenderer(context, chart, columnChartDataProvider), lineChartRenderer);
}
 
Example #21
Source File: ComboChartRenderer.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public ComboChartRenderer(Context context, Chart chart) {
    super(context, chart);
    this.renderers = new ArrayList<>();
}
 
Example #22
Source File: ChartDataAnimatorV8.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public ChartDataAnimatorV8(Chart chart) {
    this.chart = chart;
    this.handler = new Handler();
}
 
Example #23
Source File: ComboLineColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public ComboLineColumnChartRenderer(Context context, Chart chart, ColumnChartRenderer columnChartRenderer,
                                    LineChartDataProvider lineChartDataProvider) {
    this(context, chart, columnChartRenderer, new LineChartRenderer(context, chart, lineChartDataProvider));
}
 
Example #24
Source File: ComboLineColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public ComboLineColumnChartRenderer(Context context, Chart chart, ColumnChartDataProvider columnChartDataProvider,
                                    LineChartDataProvider lineChartDataProvider) {
    this(context, chart, new ColumnChartRenderer(context, chart, columnChartDataProvider),
            new LineChartRenderer(context, chart, lineChartDataProvider));
}
 
Example #25
Source File: PreviewLineChartRenderer.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public PreviewLineChartRenderer(Context context, Chart chart, LineChartDataProvider dataProvider) {
    super(context, chart, dataProvider);
    previewPaint.setAntiAlias(true);
    previewPaint.setColor(Color.LTGRAY);
    previewPaint.setStrokeWidth(ChartUtils.dp2px(density, DEFAULT_PREVIEW_STROKE_WIDTH_DP));
}
 
Example #26
Source File: PreviewColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public PreviewColumnChartRenderer(Context context, Chart chart, ColumnChartDataProvider dataProvider) {
    super(context, chart, dataProvider);
    previewPaint.setAntiAlias(true);
    previewPaint.setColor(Color.LTGRAY);
    previewPaint.setStrokeWidth(ChartUtils.dp2px(density, DEFAULT_PREVIEW_STROKE_WIDTH_DP));
}
 
Example #27
Source File: ChartDataAnimatorV14.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public ChartDataAnimatorV14(Chart chart) {
    this.chart = chart;
    animator = ValueAnimator.ofFloat(0.0f, 1.0f);
    animator.addListener(this);
    animator.addUpdateListener(this);
}
 
Example #28
Source File: ChartViewportAnimatorV8.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
public ChartViewportAnimatorV8(Chart chart) {
    this.chart = chart;
    this.duration = FAST_ANIMATION_DURATION;
    this.handler = new Handler();
}
 
Example #29
Source File: BubbleChartRenderer.java    From hellocharts-android with Apache License 2.0 3 votes vote down vote up
public BubbleChartRenderer(Context context, Chart chart, BubbleChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;

    touchAdditional = ChartUtils.dp2px(density, DEFAULT_TOUCH_ADDITIONAL_DP);

    bubblePaint.setAntiAlias(true);
    bubblePaint.setStyle(Paint.Style.FILL);

}