本文整理匯總了Java中com.github.mikephil.charting.components.YAxis.setZeroLineWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java YAxis.setZeroLineWidth方法的具體用法?Java YAxis.setZeroLineWidth怎麽用?Java YAxis.setZeroLineWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.components.YAxis
的用法示例。
在下文中一共展示了YAxis.setZeroLineWidth方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import com.github.mikephil.charting.components.YAxis; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart_noseekbar);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setExtraTopOffset(-30f);
mChart.setExtraBottomOffset(10f);
mChart.setExtraLeftOffset(70f);
mChart.setExtraRightOffset(70f);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.getDescription().setEnabled(false);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setTextColor(Color.LTGRAY);
xAxis.setTextSize(13f);
xAxis.setLabelCount(5);
xAxis.setCenterAxisLabels(true);
xAxis.setGranularity(1f);
YAxis left = mChart.getAxisLeft();
left.setDrawLabels(false);
left.setSpaceTop(25f);
left.setSpaceBottom(25f);
left.setDrawAxisLine(false);
left.setDrawGridLines(false);
left.setDrawZeroLine(true); // draw a zero line
left.setZeroLineColor(Color.GRAY);
left.setZeroLineWidth(0.7f);
mChart.getAxisRight().setEnabled(false);
mChart.getLegend().setEnabled(false);
// THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
final List<Data> data = new ArrayList<>();
data.add(new Data(0f, -224.1f, "12-29"));
data.add(new Data(1f, 238.5f, "12-30"));
data.add(new Data(2f, 1280.1f, "12-31"));
data.add(new Data(3f, -442.3f, "01-01"));
data.add(new Data(4f, -2280.1f, "01-02"));
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return data.get(Math.min(Math.max((int) value, 0), data.size()-1)).xAxisValue;
}
});
setData(data);
}
示例2: onCreate
import com.github.mikephil.charting.components.YAxis; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart_noseekbar);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setExtraTopOffset(-30f);
mChart.setExtraBottomOffset(10f);
mChart.setExtraLeftOffset(70f);
mChart.setExtraRightOffset(70f);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setSpaceBetweenLabels(2);
xAxis.setTextColor(Color.LTGRAY);
xAxis.setTextSize(13f);
YAxis left = mChart.getAxisLeft();
left.setDrawLabels(false);
left.setStartAtZero(false);
left.setSpaceTop(25f);
left.setSpaceBottom(25f);
left.setDrawAxisLine(false);
left.setDrawGridLines(false);
left.setDrawZeroLine(true); // draw a zero line
left.setZeroLineColor(Color.GRAY);
left.setZeroLineWidth(0.7f);
mChart.getAxisRight().setEnabled(false);
mChart.getLegend().setEnabled(false);
// THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
List<Data> data = new ArrayList<>();
data.add(new Data(0, -224.1f, "12-29"));
data.add(new Data(1, 238.5f, "12-30"));
data.add(new Data(2, 1280.1f, "12-31"));
data.add(new Data(3, -442.3f, "01-01"));
data.add(new Data(4, -2280.1f, "01-02"));
setData(data);
}
示例3: setYAxisConfig
import com.github.mikephil.charting.components.YAxis; //導入方法依賴的package包/類
protected void setYAxisConfig(YAxis axis, ReadableMap propMap) {
if (BridgeUtils.validate(propMap, ReadableType.Number, "axisMaxValue")) {
axis.setAxisMaxValue((float) propMap.getDouble("axisMaxValue"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "axisMinValue")) {
axis.setAxisMinValue((float) propMap.getDouble("axisMinValue"));
}
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "inverted")) {
axis.setInverted(propMap.getBoolean("inverted"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceTop")) {
axis.setSpaceTop((float) propMap.getDouble("spaceTop"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceBottom")) {
axis.setSpaceBottom((float) propMap.getDouble("spaceBottom"));
}
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "showOnlyMinMax")) {
axis.setShowOnlyMinMax(propMap.getBoolean("showOnlyMinMax"));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "labelCount")) {
boolean labelCountForce = false;
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "labelCountForce")) {
labelCountForce = propMap.getBoolean("labelCountForce");
}
axis.setLabelCount(propMap.getInt("labelCount"), labelCountForce);
}
if (BridgeUtils.validate(propMap, ReadableType.String, "position")) {
axis.setPosition(YAxis.YAxisLabelPosition.valueOf(propMap.getString("position")));
}
if (BridgeUtils.validate(propMap, ReadableType.Number, "granularity")) {
axis.setGranularity((float) propMap.getDouble("granularity"));
}
if (BridgeUtils.validate(propMap, ReadableType.Boolean, "granularityEnabled")) {
axis.setGranularityEnabled(propMap.getBoolean("granularityEnabled"));
}
// formatting
if (BridgeUtils.validate(propMap, ReadableType.String, "valueFormatter")) {
String valueFormatter = propMap.getString("valueFormatter");
if ("largeValue".equals(valueFormatter)) {
axis.setValueFormatter(new LargeValueFormatter());
} else if ("percent".equals(valueFormatter)) {
axis.setValueFormatter(new PercentFormatter());
} else {
axis.setValueFormatter(new CustomFormatter(valueFormatter));
}
}
// TODO docs says the remaining config needs to be applied before setting data. Test it
// zero line
if (BridgeUtils.validate(propMap, ReadableType.Map, "zeroLine")) {
ReadableMap zeroLineConfig = propMap.getMap("zeroLine");
if (BridgeUtils.validate(zeroLineConfig, ReadableType.Boolean, "enabled")) {
axis.setDrawZeroLine(zeroLineConfig.getBoolean("enabled"));
}
if (BridgeUtils.validate(zeroLineConfig, ReadableType.Number, "lineWidth")) {
axis.setZeroLineWidth((float) zeroLineConfig.getDouble("lineWidth"));
}
if (BridgeUtils.validate(zeroLineConfig, ReadableType.String, "lineColor")) {
axis.setZeroLineColor(Color.parseColor(zeroLineConfig.getString("lineColor")));
}
}
}