F2Scale

2 min read
The metric Scale is the conversion bridge from data space to graphics space, and is responsible for the mutual conversion of original data to values ​​in the [0, 1] interval. There are different types of metrics for different data types.
Depending on the type of data, F2-Native supports the following measurement types:
TypeDescription
identityThe default measure, a value of constant type, that is, a field of the data is an invariant constant
linearconsecutive numbers [1, 2, 3, 4, 5]
catCategory, ['Male','Female']
timeCatTime Type

API

- (F2Chart * (^)(NSString *filed, NSDictionary *config))scale

set metric

iOS

  F2CanvasView *f2CanvasView = [F2CanvasView canvas:CGRectMake(0, 0, 280, 280)];
  F2Chart *chart = [F2Chart chart:f2CanvasView.bounds.size name:@"F2chart"];
 chart.scale(@"date", @{@"type":@"identity" });
 chart.scale(@"value", @{ @"precision": @(1), @"max": @(200), @"min": @(0)});

Android

mChart.setScale("date", new F2Chart.ScaleConfigBuilder().tickCount(3).range(new double[]{0.1, 0.9}));
mChart.setScale("value", new F2Chart.ScaleConfigBuilder().precision(1).max(200).min(0));
  • parameters
Attribute NameTypeExplanation
fieldStringThe name of the data in the source that the current measure needs to measure
configDictionaryThe specific configuration of the measurement is detailed in the following config

-config

Property NameTypeExplanationDefault Value
typeStringmetric type
identity
linear
cat
timeCat
"identity"
precisionNumberprecision-
rangeArray<Number>Defines the range of metric values
range[0] - defines the minimum value of the metric's value range
range[1] - defines the maximum value of the metric's value range
Calculated according to actual data
tickCountNumberDefines the number of ticks-
maxNumberDefines the maximum value of the value-
minNumberDefines the minimum value of the value-