aiCharts FAQ

How to display legend?

To display legend you need to add one
chartView.getLegends().add(new ChartLegend());

How to display label above point?

Try to use ChartSeries/ChartPoint.setShowLabel method
series.setShowLabel(true);

How to display label and percentage for pie chart?

Try to setup label format - com.artfulbits.aiCharts.Base.ChartPointAttributes.html#setLabelFormat(java.lang.String)
series.setLabelFormat("{LABEL} {PERCENT0,#.##}");

How to get point by touch?

  • Enable hit-region generation - setHitTestEnabled(boolean)
  • Add touch listener - setOnTouchListener(OnTouchListener)
  • Find point by touch coordinates - hitTest(int, int, List)
  • chartView.setHitTestEnabled(true);
    chartView.setOnTouchListener(new View.OnTouchListener()
    {
    	@Override
    	public boolean onTouch(View v, MotionEvent event)
    	{
    		switch (event.getAction())
    		{
    		case MotionEvent.ACTION_DOWN:
    			ArrayList<Object> objs = new ArrayList<Object>();
    			chartView.hitTest((int)event.getX(), (int)event.getY(), objs);
    			
    			for (Object obj : objs)
    			{
    				if(obj instanceof ChartPoint)
    				{
    					ChartPoint point = (ChartPoint)obj;
    					//TODO your code...
    				}
    			}
    			break;
    		}
    		
    		return false;
    	}
    });
    

    How to set up bottom of area/columns?

    How to set up bottom of area/columns you need set setOrigin(double) value. Use Double.POSITIVE_INFINITY value to set maximal value of scale and Double.NEGATIVE_INFINITY to set minimal value of scale.
    chartArea.getDefaultYAxis().setOrigin(3.0);
    
↑ Go to top