清理告警

Signed-off-by: zwx1284308 <zhanglei732@huawei.com>
This commit is contained in:
zwx1284308 2024-04-22 12:00:34 +08:00
parent af8235253f
commit 23ad06d8c7
141 changed files with 9946 additions and 9151 deletions

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="26b02461-9211-422f-b77d-11efbf9a8ad8" name="Changes" comment="清理告警" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../../../../.." />
</component>
<component name="GitSEFilterConfiguration">
<file-type-list>
<filtered-out-file-type name="LOCAL_BRANCH" />
<filtered-out-file-type name="REMOTE_BRANCH" />
<filtered-out-file-type name="TAG" />
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
</file-type-list>
</component>
<component name="ProjectId" id="2fGIR2jf4lrSsjPQn6aWO1EuDBR" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="清理告警" />
<option name="LAST_COMMIT_MESSAGE" value="清理告警" />
</component>
</project>

View File

@ -13,11 +13,11 @@
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyApplication MyAbilityStage onCreate")
globalThis.hapModuleName = "entry"
console.log('MyApplication MyAbilityStage onCreate');
globalThis.hapModuleName = 'entry';
}
}

View File

@ -13,69 +13,78 @@
* limitations under the License.
*/
import Ability from '@ohos.app.ability.UIAbility'
import { initDb } from '../common/database/LocalRepository'
import { FloatWindowFun } from '../common/ui/floatwindow/FloatWindowFun'
import Ability from '@ohos.app.ability.UIAbility';
import { initDb } from '../common/database/LocalRepository';
import { FloatWindowFun } from '../common/ui/floatwindow/FloatWindowFun';
import { NetWork } from '../common/profiler/item/NetWork';
import BundleManager from '../common/utils/BundleMangerUtils';
import display from '@ohos.display' // 导入模块
import display from '@ohos.display'; // 导入模块
import WorkerHandler from '../common/profiler/WorkerHandler';
import worker from '@ohos.worker';
let MainWorker = new worker.Worker("entry/ets/workers/worker.js")
globalThis.MainWorker = MainWorker
let MainWorker = new worker.Worker('entry/ets/workers/worker.js');
globalThis.MainWorker = MainWorker;
MainWorker.onmessage = function (result) {
WorkerHandler.socketHandler(result)
}
WorkerHandler.socketHandler(result);
};
let abilityWindowStage;
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('cm-MainAbility-onCreate');
globalThis.showFloatingWindow=false
BundleManager.getAppList().then(appList => {
globalThis.appList = appList
})
}
onDestroy() {
console.log('cm-MainAbility-onDestroy');
MainWorker.terminate()
}
onWindowStageCreate(windowStage) {
globalThis.abilityContext = this.context
abilityWindowStage = windowStage;
abilityWindowStage.setUIContent(this.context, "pages/LoginPage", null)
globalThis.useDaemon = false
display.getDefaultDisplay().then((disp) => {
globalThis.screenWith = disp.width
if(globalThis.screenWith>1400){
globalThis.coefficient=1
console.log('globalThis.screenWith :coefficient-- ' + globalThis.coefficient);
}else if( globalThis.screenWith>800&&globalThis.screenWith<1400){
globalThis.coefficient=1.8
console.log('globalThis.screenWith :coefficient-- ' + globalThis.coefficient);
}else{
globalThis.coefficient=1
console.log('globalThis.screenWith :coefficient-- ' + globalThis.coefficient);
}
console.log('globalThis.screenWith : ' + globalThis.screenWith);
}, (err) => {
console.log('display.getDefaultDisplay failed, error : ' + JSON.stringify(err));
})
}
onWindowStageDestroy() {}
onForeground() {
console.log('cm-MainAbility-onForeground');
initDb()
FloatWindowFun.initAllFun()
//NetWork.getInstance().init()
MainWorker.postMessage({ "testConnection": true })
}
onBackground() {}
};
onCreate(want, launchParam) {
console.log('cm-MainAbility-onCreate');
globalThis.showFloatingWindow = false;
BundleManager.getAppList().then((appList) => {
globalThis.appList = appList;
});
}
onDestroy() {
console.log('cm-MainAbility-onDestroy');
MainWorker.terminate();
}
onWindowStageCreate(windowStage) {
globalThis.abilityContext = this.context;
abilityWindowStage = windowStage;
abilityWindowStage.setUIContent(this.context, 'pages/LoginPage', null);
globalThis.useDaemon = false;
display.getDefaultDisplay().then(
(disp) => {
globalThis.screenWith = disp.width;
if (globalThis.screenWith > 1400) {
globalThis.coefficient = 1;
console.log(
'globalThis.screenWith :coefficient-- ' + globalThis.coefficient
);
} else if (
globalThis.screenWith > 800 &&
globalThis.screenWith < 1400
) {
globalThis.coefficient = 1.8;
console.log(
'globalThis.screenWith :coefficient-- ' + globalThis.coefficient
);
} else {
globalThis.coefficient = 1;
console.log(
'globalThis.screenWith :coefficient-- ' + globalThis.coefficient
);
}
console.log('globalThis.screenWith : ' + globalThis.screenWith);
},
(err) => {
console.log(
'display.getDefaultDisplay failed, error : ' + JSON.stringify(err)
);
}
);
}
onWindowStageDestroy() {}
onForeground() {
console.log('cm-MainAbility-onForeground');
initDb();
FloatWindowFun.initAllFun();
//NetWork.getInstance().init()
MainWorker.postMessage({ testConnection: true });
}
onBackground() {}
}

View File

@ -12,105 +12,114 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const dbName = "gp.db"
export const dbName = 'gp.db';
export const dbVersion = 1
export const dbVersion = 1;
export const sql_t_general_info =
"CREATE TABLE IF NOT EXISTS " + "t_general_info" + "(" +
"sessionId TEXT PRIMARY KEY, " +
"taskId TEXT NOT NULL," +
"appName TEXT," +
"appVersion TEXT," +
"packageName TEXT," +
"startTime TEXT," +
"endTime TEXT," +
"testDuration TEXT," +
"taskName TEXT," +
"testCase TEXT," +
"testType TEXT," +
"user TEXT," +
"userId TEXT," +
"projectId TEXT," +
"dataSource TEXT," +
"spVersion TEXT," +
"deviceTypeName TEXT," +
"brand TEXT," +
"deviceName TEXT," +
"board TEXT," +
"version TEXT," +
"plat TEXT," +
"cpuCluster TEXT," +
"sn TEXT," +
"resolution TEXT," +
"screenBrightness TEXT," +
"volume TEXT," +
"batteryVolume TEXT," +
"isOnline TEXT," +
"deviceNum TEXT," +
"roomNumber TEXT," +
"taskType TEXT" +
")"
'CREATE TABLE IF NOT EXISTS ' +
't_general_info' +
'(' +
'sessionId TEXT PRIMARY KEY, ' +
'taskId TEXT NOT NULL,' +
'appName TEXT,' +
'appVersion TEXT,' +
'packageName TEXT,' +
'startTime TEXT,' +
'endTime TEXT,' +
'testDuration TEXT,' +
'taskName TEXT,' +
'testCase TEXT,' +
'testType TEXT,' +
'user TEXT,' +
'userId TEXT,' +
'projectId TEXT,' +
'dataSource TEXT,' +
'spVersion TEXT,' +
'deviceTypeName TEXT,' +
'brand TEXT,' +
'deviceName TEXT,' +
'board TEXT,' +
'version TEXT,' +
'plat TEXT,' +
'cpuCluster TEXT,' +
'sn TEXT,' +
'resolution TEXT,' +
'screenBrightness TEXT,' +
'volume TEXT,' +
'batteryVolume TEXT,' +
'isOnline TEXT,' +
'deviceNum TEXT,' +
'roomNumber TEXT,' +
'taskType TEXT' +
')';
export const sql_t_index_info = "CREATE TABLE IF NOT EXISTS " + "t_index_info" + "(" +
"timestamp TEXT PRIMARY KEY, " +
"taskId TEXT NOT NULL, " +
"flag TEXT, " +
"shellBackTemp TEXT," +
"shellFrameTemp TEXT," +
"shellFrontTemp TEXT," +
"socThermalTemp TEXT," +
"systemHTemp TEXT," +
"gpuTemp TEXT," +
"ambientTemp TEXT," +
"batteryTemp TEXT," +
"ddrFrequency TEXT," +
"fps TEXT," +
"fpsJitters TEXT," +
"cpu0Frequency TEXT," +
"cpu0Load TEXT," +
"cpu1Frequency TEXT," +
"cpu1Load TEXT," +
"cpu2Frequency TEXT," +
"cpu2Load TEXT," +
"cpu3Frequency TEXT," +
"cpu3Load TEXT," +
"cpu4Frequency TEXT," +
"cpu4Load TEXT," +
"cpu5Frequency TEXT," +
"cpu5Load TEXT," +
"cpu6Frequency TEXT," +
"cpu6Load TEXT," +
"cpu7Frequency TEXT," +
"cpu7Load TEXT," +
"cpuLoad TEXT," +
"gpuFrequency TEXT," +
"gpuLoad TEXT," +
"currentNow TEXT," +
"capacity TEXT," +
"enableHiz TEXT," +
"status TEXT," +
"voltageNow TEXT," +
"pss TEXT," +
"networkUpSpeed TEXT," +
"networkDownSpeed TEXT" +
")"
export const sql_t_index_info =
'CREATE TABLE IF NOT EXISTS ' +
't_index_info' +
'(' +
'timestamp TEXT PRIMARY KEY, ' +
'taskId TEXT NOT NULL, ' +
'flag TEXT, ' +
'shellBackTemp TEXT,' +
'shellFrameTemp TEXT,' +
'shellFrontTemp TEXT,' +
'socThermalTemp TEXT,' +
'systemHTemp TEXT,' +
'gpuTemp TEXT,' +
'ambientTemp TEXT,' +
'batteryTemp TEXT,' +
'ddrFrequency TEXT,' +
'fps TEXT,' +
'fpsJitters TEXT,' +
'cpu0Frequency TEXT,' +
'cpu0Load TEXT,' +
'cpu1Frequency TEXT,' +
'cpu1Load TEXT,' +
'cpu2Frequency TEXT,' +
'cpu2Load TEXT,' +
'cpu3Frequency TEXT,' +
'cpu3Load TEXT,' +
'cpu4Frequency TEXT,' +
'cpu4Load TEXT,' +
'cpu5Frequency TEXT,' +
'cpu5Load TEXT,' +
'cpu6Frequency TEXT,' +
'cpu6Load TEXT,' +
'cpu7Frequency TEXT,' +
'cpu7Load TEXT,' +
'cpuLoad TEXT,' +
'gpuFrequency TEXT,' +
'gpuLoad TEXT,' +
'currentNow TEXT,' +
'capacity TEXT,' +
'enableHiz TEXT,' +
'status TEXT,' +
'voltageNow TEXT,' +
'pss TEXT,' +
'networkUpSpeed TEXT,' +
'networkDownSpeed TEXT' +
')';
export const task_powersensor_info =
"CREATE TABLE IF NOT EXISTS " + "task_powersensor_info" + "(" +
"id TEXT PRIMARY KEY," +
"taskId TEXT NOT NULL," +
"sensor TEXT," +
"power TEXT," +
"current TEXT," +
"percent TEXT" +
")"
'CREATE TABLE IF NOT EXISTS ' +
'task_powersensor_info' +
'(' +
'id TEXT PRIMARY KEY,' +
'taskId TEXT NOT NULL,' +
'sensor TEXT,' +
'power TEXT,' +
'current TEXT,' +
'percent TEXT' +
')';
export const task_powerapp_info =
"CREATE TABLE IF NOT EXISTS " + "task_powerapp_info" + "(" +
"id TEXT PRIMARY KEY," +
"taskId TEXT NOT NULL," +
"process TEXT," +
"energy TEXT," +
"percent TEXT" +
")"
'CREATE TABLE IF NOT EXISTS ' +
'task_powerapp_info' +
'(' +
'id TEXT PRIMARY KEY,' +
'taskId TEXT NOT NULL,' +
'process TEXT,' +
'energy TEXT,' +
'percent TEXT' +
')';

View File

@ -14,6 +14,6 @@
*/
//实际存储路径 对应 沙箱路径 globalThis.abilityContext.getApplicationContext().filesDir 即/data/storage/base/files
export const AppFileRealDir = "/data/app/el2/100/base/com.ohos.smartperf/files/"
export const AppFileRealDir =
'/data/app/el2/100/base/com.ohos.smartperf/files/';
//export const AppFileRealDir= "/data/system_ce/0/dubai"

View File

@ -12,95 +12,112 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import relationalStore from '@ohos.data.relationalStore'
import database from './DatabaseUtils'
import relationalStore from '@ohos.data.relationalStore';
import database from './DatabaseUtils';
import BundleManager from '../utils/BundleMangerUtils';
import { dateFormat } from '../utils/TimeUtils'
import { ReportItem } from '../entity/LocalConfigEntity'
import { sql_t_general_info, dbVersion, dbName, sql_t_index_info } from '../constant/ConstantSQL';
import { AppFileRealDir } from '../constant/ConstantsPath'
import SPLogger from '../utils/SPLogger'
import { dateFormat } from '../utils/TimeUtils';
import { ReportItem } from '../entity/LocalConfigEntity';
import {
sql_t_general_info,
dbVersion,
dbName,
sql_t_index_info,
} from '../constant/ConstantSQL';
import { AppFileRealDir } from '../constant/ConstantsPath';
import SPLogger from '../utils/SPLogger';
const TAG = "LocalRepository"
const TAG = 'LocalRepository';
export function initDbIndex(): void {
try {
const STORE_CONFIG:relationalStore.StoreConfig = {
const STORE_CONFIG: relationalStore.StoreConfig = {
name: globalThis.dbTime + '.db',
securityLevel: relationalStore.SecurityLevel.S1
securityLevel: relationalStore.SecurityLevel.S1,
};
relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG)
.then(rdbStore => {
relationalStore
.getRdbStore(globalThis.abilityContext, STORE_CONFIG)
.then((rdbStore) => {
rdbStore.executeSql(sql_t_index_info, null);
return rdbStore;
});
} catch (err) {
SPLogger.DEBUG(TAG, '--> createTable start execute sql_t_index_info:' + sql_t_index_info);
SPLogger.DEBUG(
TAG,
'--> createTable start execute sql_t_index_info:' + sql_t_index_info
);
}
}
export function initDb(): void {
try {
const STORE_CONFIG:relationalStore.StoreConfig = {
const STORE_CONFIG: relationalStore.StoreConfig = {
name: dbName,
securityLevel: relationalStore.SecurityLevel.S1
}
relationalStore.getRdbStore(globalThis.abilityContext, STORE_CONFIG)
.then(rdbStore => {
securityLevel: relationalStore.SecurityLevel.S1,
};
relationalStore
.getRdbStore(globalThis.abilityContext, STORE_CONFIG)
.then((rdbStore) => {
rdbStore.executeSql(sql_t_general_info, null);
return rdbStore
})
return rdbStore;
});
} catch (err) {
SPLogger.DEBUG(TAG, "--> createTable start execute sql_t_genneral_info catch:" + sql_t_general_info)
SPLogger.DEBUG(
TAG,
'--> createTable start execute sql_t_genneral_info catch:' +
sql_t_general_info
);
}
getReportListDb().then(res => {
globalThis.reportList = res
let bundleNameArr = []
for (let reportItemKey in globalThis.reportList) {
bundleNameArr.push(globalThis.reportList[reportItemKey].packageName)
}
getReportListDb()
.then((res) => {
globalThis.reportList = res;
let bundleNameArr = [];
for (let reportItemKey in globalThis.reportList) {
bundleNameArr.push(globalThis.reportList[reportItemKey].packageName);
}
BundleManager.getIconByBundleName(bundleNameArr).then(map => {
globalThis.iconMap = map
BundleManager.getIconByBundleName(bundleNameArr).then((map) => {
globalThis.iconMap = map;
});
let resReport: Array<ReportItem> = res;
globalThis.sumTest = resReport.length;
globalThis.sumTestTime = 0;
let sumTestAppMap = new Map();
for (let resReportKey in resReport) {
sumTestAppMap.set(resReport[resReportKey].appName, '');
globalThis.sumTestTime += Number(
resReport[resReportKey].testDuration
).valueOf();
}
globalThis.sumTestApp = sumTestAppMap.size;
})
let resReport: Array<ReportItem> = res
globalThis.sumTest = resReport.length
globalThis.sumTestTime = 0
let sumTestAppMap = new Map
for (let resReportKey in resReport) {
sumTestAppMap.set(resReport[resReportKey].appName, "")
globalThis.sumTestTime += Number(resReport[resReportKey].testDuration).valueOf()
}
globalThis.sumTestApp = sumTestAppMap.size
}).catch(err => {
SPLogger.DEBUG(TAG, "getReportListDb ERR:" + err);
})
.catch((err) => {
SPLogger.DEBUG(TAG, 'getReportListDb ERR:' + err);
});
}
export async function getReportListDb(): Promise<Array<ReportItem>> {
var result = Array<ReportItem>()
await database.queryGeneralData().then(generals => {
var result = Array<ReportItem>();
await database.queryGeneralData().then((generals) => {
for (var i = 0; i < generals.length; i++) {
var curGeneralInfo = generals[i]
var curGeneralInfo = generals[i];
result.push(
new ReportItem(
curGeneralInfo.taskId.toString(),
AppFileRealDir + curGeneralInfo.sessionId.toString(),
curGeneralInfo.packageName,
"",
'',
curGeneralInfo.taskName,
curGeneralInfo.appName,
dateFormat(curGeneralInfo.startTime),
curGeneralInfo.testDuration.toString(),
false
))
)
);
}
})
return result
}
});
return result;
}

View File

@ -17,9 +17,9 @@
* GPData实体类
*/
export class GPData {
public moduleType: String
public timeStamp: number
public values: Map<String, String>
public moduleType: String;
public timeStamp: number;
public values: Map<String, String>;
constructor(moduleType: String, timeStamp: number, values: Map<String, String>) {
this.moduleType = moduleType;
@ -34,11 +34,17 @@ export class GPData {
var key = iterator.next().value;
obj[key] = this.values.get(key);
}
return "GPData{" +
"module='" + this.moduleType + '\'' +
", timeStamp=" + this.timeStamp +
", values=" + JSON.stringify(obj) +
'}';
return (
'GPData{' +
"module='" +
this.moduleType +
"'" +
', timeStamp=' +
this.timeStamp +
', values=' +
JSON.stringify(obj) +
'}'
);
}
}
@ -47,80 +53,90 @@ export class GPData {
*/
export class TGeneralInfo {
//目录生成的UUID 作为主键
public sessionId: String
public sessionId: String;
//任务Id
public taskId: String
public taskId: String;
//测试游戏名称
public appName: String
public appName: String;
//测试游戏版本
public appVersion: String
public appVersion: String;
//游戏包名
public packageName: String
public packageName: String;
//开始时间
public startTime: number
public startTime: number;
//结束时间
public endTime: number
public endTime: number;
//测试时长
public testDuration: number
public testDuration: number;
//任务名称
public taskName: String
public taskName: String;
//测试方式 middle
public testCase: String
public testCase: String;
//测试类型 smartPerf beta
public testType: String
public testType: String;
//用户名
public user: String
public user: String;
//用户id
public userId: String
public userId: String;
//项目Id
public projectId: String
public projectId: String;
//报告来源
public dataSource: String
public dataSource: String;
//sp版本
public spVersion: String
public spVersion: String;
//设备类型
public deviceTypeName: String
public deviceTypeName: String;
//设备品牌
public brand: String
public brand: String;
//设备名称 XX-XXX(****00018)
public deviceName: String
public deviceName: String;
//设备型号
public board: String
public board: String;
//手机版本
public version: String
public version: String;
//芯片平台
public plat: String
public plat: String;
//大中小核心
public cpuCluster: String
public cpuCluster: String;
//设备sn号
public sn: String
public sn: String;
//分辨类
public resolution: String
public resolution: String;
//当前亮度
public screenBrightness: String
public screenBrightness: String;
//设备当前音量
public volume: String
public volume: String;
//当前电池电量
public batteryVolume: String
public batteryVolume: String;
//是否是多路测试
public isOnline: boolean
public isOnline: boolean;
//设备号
public deviceNum: number
public deviceNum: number;
//房间号
public roomNumber: String
public roomNumber: String;
//任务类型 主控、被控
public taskType: number
public taskType: number;
constructor(sessionId ?: String, taskId ?: String, appName ?: String, appVersion ?: String, packageName ?: String, startTime ?: number, endTime ?: number, testDuration ?: number, taskName ?: String) {
this.sessionId = sessionId
this.taskId = taskId
this.appName = appName
this.appVersion = appVersion
this.packageName = packageName
this.startTime = startTime
this.endTime = endTime
this.testDuration = testDuration
this.taskName = taskName
constructor(
sessionId?: String,
taskId?: String,
appName?: String,
appVersion?: String,
packageName?: String,
startTime?: number,
endTime?: number,
testDuration?: number,
taskName?: String
) {
this.sessionId = sessionId;
this.taskId = taskId;
this.appName = appName;
this.appVersion = appVersion;
this.packageName = packageName;
this.startTime = startTime;
this.endTime = endTime;
this.testDuration = testDuration;
this.taskName = taskName;
}
}
@ -233,131 +249,179 @@ export class TIndexInfo {
constructor(
timestamp?: String,
taskId?: String,
cpu0Freq?: String, cpu1Freq?: String, cpu2Freq?: String, cpu3Freq?: String, cpu4Freq?: String, cpu5Freq?: String, cpu6Freq?: String, cpu7Freq?: String,
cpu0Load?: string, cpu1Load?: string, cpu2Load?: string, cpu3Load?: string, cpu4Load?: string, cpu5Load?: string, cpu6Load?: string, cpu7Load?: string,
gpuFreq?: String, gpuLoad?: String,
cpu0Freq?: String,
cpu1Freq?: String,
cpu2Freq?: String,
cpu3Freq?: String,
cpu4Freq?: String,
cpu5Freq?: String,
cpu6Freq?: String,
cpu7Freq?: String,
cpu0Load?: string,
cpu1Load?: string,
cpu2Load?: string,
cpu3Load?: string,
cpu4Load?: string,
cpu5Load?: string,
cpu6Load?: string,
cpu7Load?: string,
gpuFreq?: String,
gpuLoad?: String,
ddrFreq?: String,
shellFrame?: String, shellFront?: String, shellBack?: String, socThermal?: String, systemH?: String, gpu?: String, ambient?: String, battery?: String,
currentNow?: String, voltageNow?: String,
shellFrame?: String,
shellFront?: String,
shellBack?: String,
socThermal?: String,
systemH?: String,
gpu?: String,
ambient?: String,
battery?: String,
currentNow?: String,
voltageNow?: String,
pss?: String,
fps?: String,
fpsJitters?: String,
networkUpSpeed?: String, networkDownSpeed?: String
networkUpSpeed?: String,
networkDownSpeed?: String
) {
this.timestamp = timestamp
this.taskId = taskId
this.cpu0Frequency = cpu0Freq
this.cpu1Frequency = cpu1Freq
this.cpu2Frequency = cpu2Freq
this.cpu3Frequency = cpu3Freq
this.cpu4Frequency = cpu4Freq
this.cpu5Frequency = cpu5Freq
this.cpu6Frequency = cpu6Freq
this.cpu7Frequency = cpu7Freq
this.cpu0Load = cpu0Load
this.cpu1Load = cpu1Load
this.cpu2Load = cpu2Load
this.cpu3Load = cpu3Load
this.cpu4Load = cpu4Load
this.cpu5Load = cpu5Load
this.cpu6Load = cpu6Load
this.cpu7Load = cpu7Load
this.gpuFrequency = gpuFreq
this.gpuLoad = gpuLoad
this.ddrFrequency = ddrFreq
this.shellFrameTemp = shellFrame
this.shellFrontTemp = shellFront
this.shellBackTemp = shellBack
this.socThermalTemp = socThermal
this.systemHTemp = systemH
this.gpuTemp = gpu
this.ambientTemp = ambient
this.batteryTemp = battery
this.currentNow = currentNow
this.voltageNow = voltageNow
this.pss = pss
this.fps = fps
this.fpsJitters = fpsJitters
this.networkUpSpeed = networkUpSpeed
this.networkDownSpeed = networkDownSpeed
this.timestamp = timestamp;
this.taskId = taskId;
this.cpu0Frequency = cpu0Freq;
this.cpu1Frequency = cpu1Freq;
this.cpu2Frequency = cpu2Freq;
this.cpu3Frequency = cpu3Freq;
this.cpu4Frequency = cpu4Freq;
this.cpu5Frequency = cpu5Freq;
this.cpu6Frequency = cpu6Freq;
this.cpu7Frequency = cpu7Freq;
this.cpu0Load = cpu0Load;
this.cpu1Load = cpu1Load;
this.cpu2Load = cpu2Load;
this.cpu3Load = cpu3Load;
this.cpu4Load = cpu4Load;
this.cpu5Load = cpu5Load;
this.cpu6Load = cpu6Load;
this.cpu7Load = cpu7Load;
this.gpuFrequency = gpuFreq;
this.gpuLoad = gpuLoad;
this.ddrFrequency = ddrFreq;
this.shellFrameTemp = shellFrame;
this.shellFrontTemp = shellFront;
this.shellBackTemp = shellBack;
this.socThermalTemp = socThermal;
this.systemHTemp = systemH;
this.gpuTemp = gpu;
this.ambientTemp = ambient;
this.batteryTemp = battery;
this.currentNow = currentNow;
this.voltageNow = voltageNow;
this.pss = pss;
this.fps = fps;
this.fpsJitters = fpsJitters;
this.networkUpSpeed = networkUpSpeed;
this.networkDownSpeed = networkDownSpeed;
}
setTimeStamp(timestamp: String) {
this.timestamp = timestamp
this.timestamp = timestamp;
}
setTaskId(taskId: String) {
this.taskId = taskId
this.taskId = taskId;
}
setCPUData(cpu0Freq: String, cpu1Freq: String, cpu2Freq: String, cpu3Freq: String, cpu4Freq: String, cpu5Freq: String, cpu6Freq: String, cpu7Freq: String) {
this.cpu0Frequency = cpu0Freq
this.cpu1Frequency = cpu1Freq
this.cpu2Frequency = cpu2Freq
this.cpu3Frequency = cpu3Freq
this.cpu4Frequency = cpu4Freq
this.cpu5Frequency = cpu5Freq
this.cpu6Frequency = cpu6Freq
this.cpu7Frequency = cpu7Freq
setCPUData(
cpu0Freq: String,
cpu1Freq: String,
cpu2Freq: String,
cpu3Freq: String,
cpu4Freq: String,
cpu5Freq: String,
cpu6Freq: String,
cpu7Freq: String
) {
this.cpu0Frequency = cpu0Freq;
this.cpu1Frequency = cpu1Freq;
this.cpu2Frequency = cpu2Freq;
this.cpu3Frequency = cpu3Freq;
this.cpu4Frequency = cpu4Freq;
this.cpu5Frequency = cpu5Freq;
this.cpu6Frequency = cpu6Freq;
this.cpu7Frequency = cpu7Freq;
}
setCPULoadData(cpu0Load: String, cpu1Load: String, cpu2Load: String, cpu3Load: String, cpu4Load: String, cpu5Load: String, cpu6Load: String, cpu7Load: String) {
this.cpu0Load = cpu0Load
this.cpu1Load = cpu1Load
this.cpu2Load = cpu2Load
this.cpu3Load = cpu3Load
this.cpu4Load = cpu4Load
this.cpu5Load = cpu5Load
this.cpu6Load = cpu6Load
this.cpu7Load = cpu7Load
setCPULoadData(
cpu0Load: String,
cpu1Load: String,
cpu2Load: String,
cpu3Load: String,
cpu4Load: String,
cpu5Load: String,
cpu6Load: String,
cpu7Load: String
) {
this.cpu0Load = cpu0Load;
this.cpu1Load = cpu1Load;
this.cpu2Load = cpu2Load;
this.cpu3Load = cpu3Load;
this.cpu4Load = cpu4Load;
this.cpu5Load = cpu5Load;
this.cpu6Load = cpu6Load;
this.cpu7Load = cpu7Load;
}
setGPUData(gpuFreq: String, gpuLoad: String) {
this.gpuFrequency = gpuFreq
this.gpuLoad = gpuLoad
this.gpuFrequency = gpuFreq;
this.gpuLoad = gpuLoad;
}
setDDRData(ddrFreq: String) {
this.ddrFrequency = ddrFreq
this.ddrFrequency = ddrFreq;
}
setTempData(shellFrame: String, shellFront: String, shellBack: String, soc_thermal: String, system_h: String, gpu: String, ambient: String) {
this.shellFrameTemp = shellFrame
this.shellFrontTemp = shellFront
this.shellBackTemp = shellBack
this.socThermalTemp = soc_thermal
this.systemHTemp = system_h
this.gpuTemp = gpu
this.ambientTemp = ambient
setTempData(
shellFrame: String,
shellFront: String,
shellBack: String,
soc_thermal: String,
system_h: String,
gpu: String,
ambient: String
) {
this.shellFrameTemp = shellFrame;
this.shellFrontTemp = shellFront;
this.shellBackTemp = shellBack;
this.socThermalTemp = soc_thermal;
this.systemHTemp = system_h;
this.gpuTemp = gpu;
this.ambientTemp = ambient;
}
setPowerData(currentNow: String, voltageNow: String,batteryTemp:String) {
this.currentNow = currentNow
this.voltageNow = voltageNow
this.batteryTemp = batteryTemp
setPowerData(currentNow: String, voltageNow: String, batteryTemp: String) {
this.currentNow = currentNow;
this.voltageNow = voltageNow;
this.batteryTemp = batteryTemp;
}
setFpsData(fps: String, fpsJitter: String) {
this.fps = fps
this.fpsJitters = fpsJitter
this.fps = fps;
this.fpsJitters = fpsJitter;
}
setRamData(pss: String) {
this.pss = pss
this.pss = pss;
}
setNetWorkData(networkUpSpeed:String, networkDownSpeed:String){
this.networkDownSpeed = networkDownSpeed
this.networkUpSpeed = networkUpSpeed
setNetWorkData(networkUpSpeed: String, networkDownSpeed: String) {
this.networkDownSpeed = networkDownSpeed;
this.networkUpSpeed = networkUpSpeed;
}
setDefaultValue() {
let properties = Object.keys(this)
properties.forEach(property => {
this[property] = "-1"
})
let properties = Object.keys(this);
properties.forEach((property) => {
this[property] = '-1';
});
}
}
@ -371,26 +435,34 @@ export class TPowerAppInfo {
public current: String;
public percent: String;
public color: Resource;
constructor(id ?: String, taskId ?: String, application ?: String, power ?: String, current ?: String, percent ?: String,color?: Resource) {
this.id = id
this.taskId = taskId
this.application = application
this.power = power
this.current = current
this.percent = percent
this.color = color
constructor(
id?: String,
taskId?: String,
application?: String,
power?: String,
current?: String,
percent?: String,
color?: Resource
) {
this.id = id;
this.taskId = taskId;
this.application = application;
this.power = power;
this.current = current;
this.percent = percent;
this.color = color;
}
setColor(color?: Resource){
this.color = color
setColor(color?: Resource) {
this.color = color;
}
setPower(power?: String){
this.power = power
setPower(power?: String) {
this.power = power;
}
setPercent(percent?: String){
this.percent = percent
setPercent(percent?: String) {
this.percent = percent;
}
setCurrent(current?: String){
this.current = current
setCurrent(current?: String) {
this.current = current;
}
}
@ -404,24 +476,24 @@ export class TPowerSensorInfo {
public current: string;
public percent: string;
public color: Resource;
constructor( taskId ?: string, sensor ?:string, power ?: string, current ?: string, percent ?: string,color?: Resource) {
this.taskId = taskId
this.sensor = sensor
this.power = power
this.current = current
this.percent = percent
this.color = color
constructor(taskId?: string, sensor?: string, power?: string, current?: string, percent?: string, color?: Resource) {
this.taskId = taskId;
this.sensor = sensor;
this.power = power;
this.current = current;
this.percent = percent;
this.color = color;
}
setPerenct(percent: string) {
this.percent = percent
this.percent = percent;
}
setColor(color: Resource) {
this.color = color
this.color = color;
}
setPower(power: string) {
this.power = power
this.power = power;
}
setCurrent(current: string) {
this.current = current
this.current = current;
}
}
}

View File

@ -13,151 +13,164 @@
* limitations under the License.
*/
export enum TestMode {
ONLINE,
BRIGHTNESS,
STARTUP
ONLINE,
BRIGHTNESS,
STARTUP,
}
export class OtherSupport {
public testName: string
public testSrc: string
public testMode: TestMode
public resource: Resource
public testName: string;
public testSrc: string;
public testMode: TestMode;
public resource: Resource;
constructor(testName: string, testSrc: string, testMode: TestMode, resource: Resource) {
this.testName = testName
this.testSrc = testSrc
this.testMode = testMode
this.resource = resource
}
constructor(testName: string, testSrc: string, testMode: TestMode, resource: Resource) {
this.testName = testName;
this.testSrc = testSrc;
this.testMode = testMode;
this.resource = resource;
}
}
export class SwitchItem {
public id: string
public switchName: string
public switchSrc: Resource
public isOpen: boolean
public enable: boolean
public id: string;
public switchName: string;
public switchSrc: Resource;
public isOpen: boolean;
public enable: boolean;
constructor(id: string, switchName: string, switchSrc: Resource, isOpen: boolean, enable: boolean) {
this.id = id
this.switchName = switchName
this.switchSrc = switchSrc
this.isOpen = isOpen
this.enable = enable
}
constructor(id: string, switchName: string, switchSrc: Resource, isOpen: boolean, enable: boolean) {
this.id = id;
this.switchName = switchName;
this.switchSrc = switchSrc;
this.isOpen = isOpen;
this.enable = enable;
}
}
export class CollectItem {
public name: string
public isSupport: boolean
public isSelect: boolean
public name: string;
public isSupport: boolean;
public isSelect: boolean;
constructor(name: string, isSupport: boolean, isSelect: boolean) {
this.name = name
this.isSupport = isSupport
this.isSelect = isSelect
}
constructor(name: string, isSupport: boolean, isSelect: boolean) {
this.name = name;
this.isSupport = isSupport;
this.isSelect = isSelect;
}
}
export class TaskInfoConfig {
public testName: string
public collectItem: Array<CollectItem>
public switchItem: Array<SwitchItem>
public testName: string;
public collectItem: Array<CollectItem>;
public switchItem: Array<SwitchItem>;
constructor(testName?: string, collectItem?: Array<CollectItem>, switchItem?: Array<SwitchItem>) {
this.testName = testName
this.collectItem = collectItem
this.switchItem = switchItem
}
constructor(testName?: string, collectItem?: Array<CollectItem>, switchItem?: Array<SwitchItem>) {
this.testName = testName;
this.collectItem = collectItem;
this.switchItem = switchItem;
}
}
export class AppInfoItem {
public id: number
public packageName: string
public appName: string
public appVersion: String
public appIcon: string
public abilityName: string
public id: number;
public packageName: string;
public appName: string;
public appVersion: String;
public appIcon: string;
public abilityName: string;
constructor(packageName: string, appName: string, appVersion: String, appIcon: string, abilityName: string) {
this.packageName = packageName
this.appName = appName
this.appVersion = appVersion
this.appIcon = appIcon
this.abilityName = abilityName
}
constructor(packageName: string, appName: string, appVersion: String, appIcon: string, abilityName: string) {
this.packageName = packageName;
this.appName = appName;
this.appVersion = appVersion;
this.appIcon = appIcon;
this.abilityName = abilityName;
}
}
export class ReportItem {
public sessionId: String;
public dbPath: String;
public packageName: String;
public iconId: String;
public name: String;
public appName: String;
public startTime: String;
public testDuration: String;
public upStatus: boolean;
public sessionId: String;
public dbPath: String;
public packageName: String;
public iconId: String;
public name: String;
public appName: String;
public startTime: String;
public testDuration: String;
public upStatus: boolean;
constructor(sessionId: String, dbPath: String, packageName: String, iconId: String, name: String, appName: String, startTime: String, testDuration: String, upStatus: boolean) {
this.sessionId = sessionId
this.dbPath = dbPath
this.packageName = packageName
this.iconId = iconId
this.name = name
this.appName = appName
this.startTime = startTime
this.testDuration = testDuration
this.upStatus = upStatus
}
constructor(
sessionId: String,
dbPath: String,
packageName: String,
iconId: String,
name: String,
appName: String,
startTime: String,
testDuration: String,
upStatus: boolean
) {
this.sessionId = sessionId;
this.dbPath = dbPath;
this.packageName = packageName;
this.iconId = iconId;
this.name = name;
this.appName = appName;
this.startTime = startTime;
this.testDuration = testDuration;
this.upStatus = upStatus;
}
public getStartTime(): string{
return this.startTime.valueOf()
}
public getStartTime(): string {
return this.startTime.valueOf();
}
public getTestDuration(): string{
return this.testDuration.valueOf()
}
public getTestDuration(): string {
return this.testDuration.valueOf();
}
public getDbPath(): string{
return this.dbPath.valueOf()
}
public getDbPath(): string {
return this.dbPath.valueOf();
}
}
export class QuestionItem {
public question: string
public answer: string
public question: string;
public answer: string;
constructor(question: string, answer: string) {
this.answer = answer
this.question = question
}
constructor(question: string, answer: string) {
this.answer = answer;
this.question = question;
}
}
export const questionList = new Array(
new QuestionItem('1.SP工具怎么使用', '如何使用可以查看以下地址https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/client/client_ui/README_zh.md'),
new QuestionItem('2.SP工具支持FPS采集吗?', '可以fps依赖Hidumper能力..'),
new QuestionItem('3.SP工具支持RAM采集吗?', 'ram采集目前是 读取进程节点内存信息中的PSS值...'),
new QuestionItem('4.FPS采集不到?', '可能是视频应用,需要联系开发添加对应的图层,做采集适配'),
new QuestionItem('5.SP采集原理?', '目前除fps外,其他采集均是通过cat 系统节点获取'),
new QuestionItem('6.报告页的值是怎么算的?', '最终以一场测试结果的平均值为准'),
new QuestionItem('7.SP后续规划?', '集成更多采集能力,如trace采集,counter采集,网络采集等等;优化数据展示方式,报告上传网站端,在线分析性能功耗问题')
)
new QuestionItem(
'1.SP工具怎么使用',
'如何使用可以查看以下地址https://gitee.com/openharmony/developtools_profiler/blob/master/host/smartperf/client/client_ui/README_zh.md'
),
new QuestionItem('2.SP工具支持FPS采集吗?', '可以fps依赖Hidumper能力..'),
new QuestionItem('3.SP工具支持RAM采集吗?', 'ram采集目前是 读取进程节点内存信息中的PSS值...'),
new QuestionItem('4.FPS采集不到?', '可能是视频应用,需要联系开发添加对应的图层,做采集适配'),
new QuestionItem('5.SP采集原理?', '目前除fps外,其他采集均是通过cat 系统节点获取'),
new QuestionItem('6.报告页的值是怎么算的?', '最终以一场测试结果的平均值为准'),
new QuestionItem(
'7.SP后续规划?',
'集成更多采集能力,如trace采集,counter采集,网络采集等等;优化数据展示方式,报告上传网站端,在线分析性能功耗问题'
)
);
export class SummaryItem {
public icon: Resource
public content: string
public value: string
public backColor: string
public icon: Resource;
public content: string;
public value: string;
public backColor: string;
constructor(icon: Resource, content: string, value: string, backColor: string) {
this.icon = icon
this.content = content
this.value = value
this.backColor = backColor
}
constructor(icon: Resource, content: string, value: string, backColor: string) {
this.icon = icon;
this.content = content;
this.value = value;
this.backColor = backColor;
}
}

View File

@ -40,4 +40,4 @@ export interface ProcessRunningInfo {
* @syscap SystemCapability.Ability.AbilityRuntime.Mission
*/
bundleNames: Array<string>;
}
}

View File

@ -21,10 +21,10 @@ export class User {
public token_type: String; //token类型
constructor(token?: String, expires_in?: String, refresh_token?: String, expires_at?: String, token_type?: String) {
this.token = token
this.expires_in = expires_in
this.refresh_token = refresh_token
this.expires_at = expires_at
this.token_type = token_type
this.token = token;
this.expires_in = expires_in;
this.refresh_token = refresh_token;
this.expires_at = expires_at;
this.token_type = token_type;
}
}
}

View File

@ -12,259 +12,303 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import deviceInfo from '@ohos.deviceInfo'
import CommonEvent from '@ohos.commonEvent'
import database from '../database/DatabaseUtils'
import deviceInfo from '@ohos.deviceInfo';
import CommonEvent from '@ohos.commonEvent';
import database from '../database/DatabaseUtils';
import { CPU } from './item/CPU';
import { Power } from './item/Power';
import { dateFormat } from '../utils/TimeUtils';
import { TPowerAppInfo } from '../entity/DatabaseEntity';
import { csvGeneralInfo, csvTIndexInfo } from '../utils/CSVUtils'
import { createFilePath } from '../utils/IOUtils'
import CheckEmptyUtils from '../utils/CheckEmptyUtils'
import { GPData, TIndexInfo, TGeneralInfo, TPowerSensorInfo } from '../entity/DatabaseEntity'
import { ProfilerFactory } from './base/ProfilerFactory'
import { CollectorType } from './base/ProfilerConstant'
import SPLogger from '../../common/utils/SPLogger'
import { csvGeneralInfo, csvTIndexInfo } from '../utils/CSVUtils';
import { createFilePath } from '../utils/IOUtils';
import CheckEmptyUtils from '../utils/CheckEmptyUtils';
import { GPData, TIndexInfo, TGeneralInfo, TPowerSensorInfo } from '../entity/DatabaseEntity';
import { ProfilerFactory } from './base/ProfilerFactory';
import { CollectorType } from './base/ProfilerConstant';
import SPLogger from '../../common/utils/SPLogger';
import { initDbIndex } from '../../common/database/LocalRepository';
export class ProfilerTask {
private collectItems:Array<string> = []
private static instance: ProfilerTask
private collectItems: Array<string> = [];
private static instance: ProfilerTask;
public static getInstance(): ProfilerTask {
if (this.instance == null) {
this.instance = new ProfilerTask
this.instance = new ProfilerTask();
}
return ProfilerTask.instance
return ProfilerTask.instance;
}
initModule() {
SPLogger.DEBUG(ProfilerTask.name,'ProfilerTask initModule configs: ' + JSON.stringify(globalThis.collectConfigs))
const keys: any[] = Object.keys(globalThis.collectConfigs)
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask initModule configs: ' + JSON.stringify(globalThis.collectConfigs));
const keys: any[] = Object.keys(globalThis.collectConfigs);
for (var key of keys) {
if (globalThis.collectConfigs[key]) {
let typeCollect = ProfilerFactory.getProfilerByConfig(key.toString())
SPLogger.DEBUG(ProfilerTask.name,'ProfilerTask initModule: ' + typeCollect)
let typeCollect = ProfilerFactory.getProfilerByConfig(key.toString());
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask initModule: ' + typeCollect);
if (typeCollect == null) {
continue
}else{
this.collectItems.push(typeCollect.init())
continue;
} else {
this.collectItems.push(typeCollect.init());
}
}
}
}
getSupports(keys:string[]){
let supports : Map<string,Boolean> = new Map<string,Boolean>()
getSupports(keys: string[]) {
let supports: Map<string, Boolean> = new Map<string, Boolean>();
for (var key of keys) {
let typeCollect = ProfilerFactory.getProfilerByConfig(key)
let isSupport = typeCollect.isSupport()
supports.set(key.toString(),isSupport)
let typeCollect = ProfilerFactory.getProfilerByConfig(key);
let isSupport = typeCollect.isSupport();
supports.set(key.toString(), isSupport);
}
return supports
return supports;
}
taskInit() {
SPLogger.INFO(ProfilerTask.name,'ProfilerUtils taskInit call');
var now = new Date()
SPLogger.INFO(ProfilerTask.name, 'ProfilerUtils taskInit call');
var now = new Date();
//数据库时间戳标记
globalThis.dbTime = now.getTime()
globalThis.dbTime = now.getTime();
//开始时间
globalThis.startTime = now.getTime()
globalThis.startTime = now.getTime();
//结束时间
globalThis.endTime = -1
globalThis.endTime = -1;
//时间计数器
globalThis.collectIntervalNum = -1
globalThis.collectIntervalNum = -1;
//入库数据
globalThis.tTndexs = new Array<TIndexInfo>()
globalThis.tTndexs = new Array<TIndexInfo>();
//实时数据
globalThis.tTndex = new TIndexInfo()
globalThis.tTndex = new TIndexInfo();
// ram队列
globalThis.ramArr = new Array<String>()
globalThis.ramArr = new Array<String>();
// fps队列
globalThis.fpsArr = new Array<String>()
globalThis.fpsArr = new Array<String>();
// fpsJitter队列
globalThis.fpsJitterArr = new Array<String>()
globalThis.fpsJitterArr = new Array<String>();
// fps队列
globalThis.fpsArr = new Array<String>()
globalThis.fpsArr = new Array<String>();
// power 电流队列
globalThis.powerCurArr = new Array<String>()
globalThis.powerCurArr = new Array<String>();
// power 电压队列
globalThis.powerVoltArr = new Array<String>()
globalThis.powerVoltArr = new Array<String>();
globalThis.taskId = -1;
initDbIndex();
//初始化数据库 2022-02-23 dbName改为时间戳
database.createTable(globalThis.dbTime)
SPLogger.INFO(ProfilerTask.name,'ProfilerUtils taskInit called');
database.createTable(globalThis.dbTime);
SPLogger.INFO(ProfilerTask.name, 'ProfilerUtils taskInit called');
}
taskStart() {
SPLogger.DEBUG(ProfilerTask.name,'ProfilerTask taskStart call');
var gpDataArr: Array<GPData> = new Array<GPData>()
this.collectItems.forEach(
(moduleName)=>{
let typeCollect = ProfilerFactory.getProfilerByConfig(moduleName.toString())
if (typeCollect != null) {
let gpData:GPData = typeCollect.readData()
if(typeCollect instanceof CPU){
gpDataArr.push(typeCollect.readCPULoad())
}
gpDataArr.push(gpData)
SPLogger.DEBUG(ProfilerTask.name,"profiler ProfilerTask:curData:"+gpData);
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask taskStart call');
var gpDataArr: Array<GPData> = new Array<GPData>();
this.collectItems.forEach((moduleName) => {
let typeCollect = ProfilerFactory.getProfilerByConfig(moduleName.toString());
if (typeCollect != null) {
let gpData: GPData = typeCollect.readData();
if (typeCollect instanceof CPU) {
gpDataArr.push(typeCollect.readCPULoad());
}
gpDataArr.push(gpData);
SPLogger.DEBUG(ProfilerTask.name, 'profiler ProfilerTask:curData:' + gpData);
}
)
});
//防止cpuLoad -1
if (globalThis.collectIntervalNum > 0) {
let tTndex = database.gpArray2Index(gpDataArr)
globalThis.tTndexs.push(tTndex)
let tTndex = database.gpArray2Index(gpDataArr);
globalThis.tTndexs.push(tTndex);
globalThis.tTndex = tTndex;
CommonEvent.publish("event", { code: 0, data: JSON.stringify(tTndex), }, (err)=>{});
CommonEvent.publish('event', { code: 0, data: JSON.stringify(tTndex) }, (err) => {});
}
globalThis.collectIntervalNum++
SPLogger.DEBUG(ProfilerTask.name,"profiler globalThis.collectIntervalNum " + globalThis.collectIntervalNum)
globalThis.collectIntervalNum++;
SPLogger.DEBUG(ProfilerTask.name, 'profiler globalThis.collectIntervalNum ' + globalThis.collectIntervalNum);
SPLogger.DEBUG(ProfilerTask.name,'ProfilerTask taskStart called');
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask taskStart called');
}
taskSingleItemStart(collectorType : CollectorType) {
SPLogger.ERROR("ProfilerTaskTest",'ProfilerTask taskStart call collectorType' + collectorType.toString());
let typeCollect = ProfilerFactory.getProfilerByConfig(collectorType.toString())
if(typeCollect instanceof Power) {
typeCollect.readFourTimesData()
taskSingleItemStart(collectorType: CollectorType) {
SPLogger.ERROR('ProfilerTaskTest', 'ProfilerTask taskStart call collectorType' + collectorType.toString());
let typeCollect = ProfilerFactory.getProfilerByConfig(collectorType.toString());
if (typeCollect instanceof Power) {
typeCollect.readFourTimesData();
}
}
taskStop() {
SPLogger.DEBUG(ProfilerTask.name,'ProfilerTask taskStop call');
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask taskStop call');
// t_index_info 入库
if (globalThis.tTndexs.length > 2) {
for (var index = 2; index < globalThis.tTndexs.length; index++) {
const tTndex = globalThis.tTndexs[index];
database.insertData("t_index_info", globalThis.dbTime, tTndex)
database.insertData('t_index_info', globalThis.dbTime, tTndex);
}
}
createFilePath(globalThis.abilityContext.getApplicationContext().filesDir + "/" + globalThis.dbTime + "/t_index_info.csv", csvTIndexInfo(globalThis.tTndexs))
createFilePath(
globalThis.abilityContext.getApplicationContext().filesDir + '/' + globalThis.dbTime + '/t_index_info.csv',
csvTIndexInfo(globalThis.tTndexs)
);
// t_general_info 入库
globalThis.endTime = new Date().getTime()
globalThis.endTime = new Date().getTime();
let tGeneralInfo = new TGeneralInfo(
globalThis.dbTime.toString(),
"NA",
globalThis.appName,
globalThis.appVersion,
globalThis.packageName,
globalThis.startTime,
globalThis.endTime,
globalThis.collectIntervalNum,
globalThis.testTaskName
)
tGeneralInfo.board = deviceInfo.brand
tGeneralInfo.deviceTypeName = deviceInfo.deviceType
tGeneralInfo.brand = deviceInfo.brand
tGeneralInfo.version = deviceInfo.displayVersion
tGeneralInfo.sn = deviceInfo.serial
database.insertGeneraData("t_general_info", tGeneralInfo)
createFilePath(globalThis.abilityContext.getApplicationContext().filesDir + "/" + globalThis.dbTime + "/t_general_info.csv", csvGeneralInfo(tGeneralInfo))
globalThis.dbTime.toString(),
'NA',
globalThis.appName,
globalThis.appVersion,
globalThis.packageName,
globalThis.startTime,
globalThis.endTime,
globalThis.collectIntervalNum,
globalThis.testTaskName
);
tGeneralInfo.board = deviceInfo.brand;
tGeneralInfo.deviceTypeName = deviceInfo.deviceType;
tGeneralInfo.brand = deviceInfo.brand;
tGeneralInfo.version = deviceInfo.displayVersion;
tGeneralInfo.sn = deviceInfo.serial;
database.insertGeneraData('t_general_info', tGeneralInfo);
createFilePath(
globalThis.abilityContext.getApplicationContext().filesDir + '/' + globalThis.dbTime + '/t_general_info.csv',
csvGeneralInfo(tGeneralInfo)
);
SPLogger.DEBUG(ProfilerTask.name,'ProfilerTask taskStop called');
SPLogger.DEBUG(ProfilerTask.name, 'ProfilerTask taskStop called');
}
taskGetDubai(){
let tPowers:Array<TPowerSensorInfo> =new Array()
SPLogger.INFO("TAG","resultSet query_applications_display-----startTime" + JSON.stringify(dateFormat(globalThis.startTime) ))
SPLogger.INFO("TAG","resultSet query_applications_display-----endTime" + JSON.stringify(dateFormat(globalThis.endTime)))
SPLogger.INFO("TAG","resultSet query_applications_display-----dbTime" + JSON.stringify(globalThis.dbTime))
database.query_applications_display(dateFormat(globalThis.startTime) , dateFormat(globalThis.endTime),globalThis.packageName).then(data => {
if(data.length!=0)
tPowers.push(data[0])
database.query_applications_cpu(dateFormat(globalThis.startTime) , dateFormat(globalThis.endTime),globalThis.packageName).then(data => {
if(data.length!=0)
tPowers.push(data[0])
database.query_applications_gpu(dateFormat(globalThis.startTime) , dateFormat(globalThis.endTime),globalThis.packageName).then(data => {
if(data.length!=0)
tPowers.push(data[0])
database.query_applications_audio(dateFormat(globalThis.startTime) , dateFormat(globalThis.endTime),globalThis.packageName).then(data => {
if(data.length!=0)
tPowers.push(data[0])
database.query_applications_ddr(dateFormat(globalThis.startTime) , dateFormat(globalThis.endTime),globalThis.packageName).then(data => {
if(data.length!=0)
tPowers.push(data[0])
database.query_applications_dss(dateFormat(globalThis.startTime) , dateFormat(globalThis.endTime),globalThis.packageName).then(data => {
if(data.length!=0)
tPowers.push(data[0])
database.query_applications_system_idle(dateFormat(globalThis.startTime) , dateFormat(globalThis.endTime),globalThis.packageName).then(data => {
if(data.length!=0)
tPowers.push(data[0])
database.query_applications_wifi_data(dateFormat(globalThis.startTime) , dateFormat(globalThis.endTime),globalThis.packageName).then(data => {
if(data.length!=0)
tPowers.push(data[0])
for (var i = 0; i < tPowers.length; i++) {
database.insertPowerSensor("task_powersensor_info",globalThis.dbTime,tPowers[i])
}
}).then(()=>{
return database.query_applications_power_info(dateFormat(globalThis.startTime), dateFormat(globalThis.endTime))
}).then((tArr:Array<TPowerAppInfo>)=>{
tArr.forEach(t=>{
database.insertPowerAppInfo("task_powerapp_info",globalThis.dbTime,t)
})
})
})
})
})
})
})
})
})
taskGetDubai() {
let tPowers: Array<TPowerSensorInfo> = new Array();
SPLogger.INFO(
'TAG',
'resultSet query_applications_display-----startTime' + JSON.stringify(dateFormat(globalThis.startTime))
);
SPLogger.INFO(
'TAG',
'resultSet query_applications_display-----endTime' + JSON.stringify(dateFormat(globalThis.endTime))
);
SPLogger.INFO('TAG', 'resultSet query_applications_display-----dbTime' + JSON.stringify(globalThis.dbTime));
database
.query_applications_display(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime),
globalThis.packageName
)
.then((data) => {
if (data.length != 0) tPowers.push(data[0]);
database
.query_applications_cpu(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime),
globalThis.packageName
)
.then((data) => {
if (data.length != 0) tPowers.push(data[0]);
database
.query_applications_gpu(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime),
globalThis.packageName
)
.then((data) => {
if (data.length != 0) tPowers.push(data[0]);
database
.query_applications_audio(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime),
globalThis.packageName
)
.then((data) => {
if (data.length != 0) tPowers.push(data[0]);
database
.query_applications_ddr(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime),
globalThis.packageName
)
.then((data) => {
if (data.length != 0) tPowers.push(data[0]);
database
.query_applications_dss(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime),
globalThis.packageName
)
.then((data) => {
if (data.length != 0) tPowers.push(data[0]);
database
.query_applications_system_idle(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime),
globalThis.packageName
)
.then((data) => {
if (data.length != 0) tPowers.push(data[0]);
database
.query_applications_wifi_data(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime),
globalThis.packageName
)
.then((data) => {
if (data.length != 0) tPowers.push(data[0]);
for (var i = 0; i < tPowers.length; i++) {
database.insertPowerSensor(
'task_powersensor_info',
globalThis.dbTime,
tPowers[i]
);
}
})
.then(() => {
return database.query_applications_power_info(
dateFormat(globalThis.startTime),
dateFormat(globalThis.endTime)
);
})
.then((tArr: Array<TPowerAppInfo>) => {
tArr.forEach((t) => {
database.insertPowerAppInfo('task_powerapp_info', globalThis.dbTime, t);
});
});
});
});
});
});
});
});
});
}
taskDestroy() {
//数据库时间戳标记
globalThis.dbTime = -1
globalThis.dbTime = -1;
//开始时间
globalThis.startTime = -1
globalThis.startTime = -1;
//结束时间
globalThis.endTime = -1
globalThis.endTime = -1;
//入库数据
globalThis.tTndexs = new Array<TIndexInfo>()
globalThis.tTndexs = new Array<TIndexInfo>();
//采集配置恢复fileOpen
globalThis.collectConfigs = -1
globalThis.collectPkg = -1
globalThis.collectConfigs = -1;
globalThis.collectPkg = -1;
//采集定时器 配置
globalThis.collectInterval = -1
globalThis.collectIntervalCollect = -1
globalThis.collectPowerCollect = -1
globalThis.collectIntervalNum = -1
globalThis.collectInterval = -1;
globalThis.collectIntervalCollect = -1;
globalThis.collectPowerCollect = -1;
globalThis.collectIntervalNum = -1;
globalThis.powerValue = 0
globalThis.powerValue = 0;
//socket采集队列 fps ram
globalThis.fpsArr = new Array<String>()
globalThis.fpsArr = new Array<String>();
// power 电流队列
globalThis.powerCurArr = new Array<String>()
globalThis.powerCurArr = new Array<String>();
// power 电压队列
globalThis.powerVoltArr = new Array<String>()
globalThis.fpsJitterArr = new Array<String>()
globalThis.ramArr = new Array<String>()
globalThis.powerVoltArr = new Array<String>();
globalThis.fpsJitterArr = new Array<String>();
globalThis.ramArr = new Array<String>();
}
}

View File

@ -12,47 +12,53 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CatchTraceStatus } from './base/ProfilerConstant'
import { CatchTraceStatus } from './base/ProfilerConstant';
export default class WorkerHandler {
static socketHandler(result) {
let arr = result.data.split("$")
switch (arr[0]) {
case "RAM":
globalThis.ramArr.push(arr[1])
break;
case "FPS":
globalThis.fpsArr.push(arr[1])
globalThis.fpsJitterArr.push(arr[2])
globalThis.timerFps = arr[1]
if (
globalThis.catchTraceState == CatchTraceStatus.catch_trace_start ||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_finish ||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_first_running) {
if (globalThis.fpsJitterArr != undefined && globalThis.fpsJitterArr != null && globalThis.fpsJitterArr != "") {
let tempQueue: Array<String> = globalThis.fpsJitterArr
let curJitter = tempQueue.pop()
let tempJitterArr = curJitter.split("==")
for (var i = 0; i < tempJitterArr.length; i++) {
let tmp = tempJitterArr[i]
let jitter = parseInt(tmp) / 1e6
if (jitter > 100) {
globalThis.jitterTrace = true
return
}
}
}
}
break;
case "UdpStatus":
let isSocketConnect = Number(arr[1]).valueOf()
if (isSocketConnect > 0) {
globalThis.useDaemon = true
} else {
globalThis.useDaemon = false
}
default:
break;
static socketHandler(result) {
let arr = result.data.split('$');
switch (arr[0]) {
case 'RAM':
globalThis.ramArr.push(arr[1]);
break;
case 'FPS':
globalThis.fpsArr.push(arr[1]);
globalThis.fpsJitterArr.push(arr[2]);
globalThis.timerFps = arr[1];
if (
globalThis.catchTraceState == CatchTraceStatus.catch_trace_start ||
globalThis.catchTraceState == CatchTraceStatus.catch_trace_finish ||
globalThis.catchTraceState ==
CatchTraceStatus.catch_trace_first_running
) {
if (
globalThis.fpsJitterArr != undefined &&
globalThis.fpsJitterArr != null &&
globalThis.fpsJitterArr != ''
) {
let tempQueue: Array<String> = globalThis.fpsJitterArr;
let curJitter = tempQueue.pop();
let tempJitterArr = curJitter.split('==');
for (var i = 0; i < tempJitterArr.length; i++) {
let tmp = tempJitterArr[i];
let jitter = parseInt(tmp) / 1e6;
if (jitter > 100) {
globalThis.jitterTrace = true;
return;
}
}
}
}
break;
case 'UdpStatus':
let isSocketConnect = Number(arr[1]).valueOf();
if (isSocketConnect > 0) {
globalThis.useDaemon = true;
} else {
globalThis.useDaemon = false;
}
default:
break;
}
}
}
}

View File

@ -13,10 +13,10 @@
* limitations under the License.
*/
import { GPData } from '../../entity/DatabaseEntity';
import { CollectorType } from './ProfilerConstant'
import { CollectorType } from './ProfilerConstant';
export abstract class BaseProfiler {
abstract init(): CollectorType
abstract isSupport(): Boolean
abstract readData(): GPData
}
abstract init(): CollectorType;
abstract isSupport(): Boolean;
abstract readData(): GPData;
}

View File

@ -17,28 +17,27 @@ import util from '@ohos.util';
import { GPData } from '../../entity/DatabaseEntity';
import SPLogger from '../../utils/SPLogger';
const BUFF_SIZE = 1024
const TAG="BaseProfilerUtils"
const BUFF_SIZE = 1024;
const TAG = 'BaseProfilerUtils';
/**
* 构造GPData
*/
export function createGPData(moduleType: string, values: Map<String, String>): GPData {
var now = new Date();
return new GPData(moduleType, now.getTime(), values)
return new GPData(moduleType, now.getTime(), values);
}
export function isAccess(path: string):boolean{
SPLogger.DEBUG("BaseProfilerUtils","ets check path is start..."+ "path:" + path);
var isAccess = false
export function isAccess(path: string): boolean {
SPLogger.DEBUG('BaseProfilerUtils', 'ets check path is start...' + 'path:' + path);
var isAccess = false;
try {
fileio.accessSync(path);
isAccess = true
SPLogger.DEBUG("BaseProfilerUtils","ets check path is finish..."+ "path:" + path);
} catch(err) {
SPLogger.DEBUG(TAG,"accessSync failed with error:"+ err + "path:" + path);
isAccess = true;
SPLogger.DEBUG('BaseProfilerUtils', 'ets check path is finish...' + 'path:' + path);
} catch (err) {
SPLogger.DEBUG(TAG, 'accessSync failed with error:' + err + 'path:' + path);
}
return isAccess
return isAccess;
}
/**
@ -46,29 +45,28 @@ export function isAccess(path: string):boolean{
* @param path
*/
export function fileOpen(path: string): String {
if (!isAccess(path)) {
return "null"
return 'null';
}
try {
var fd = -1
fd = fileio.openSync(path, 0o0)
var fd = -1;
fd = fileio.openSync(path, 0o0);
let buf = new ArrayBuffer(BUFF_SIZE);
fileio.readSync(fd, buf);
var result: String = String.fromCharCode.apply(null, new Uint8Array(buf))
SPLogger.DEBUG(TAG,"fileOpen path data:"+result);
return util.printf("%s", result.substring(0, lastIndex(result))).toString()
var result: String = String.fromCharCode.apply(null, new Uint8Array(buf));
SPLogger.DEBUG(TAG, 'fileOpen path data:' + result);
return util.printf('%s', result.substring(0, lastIndex(result))).toString();
} catch (err) {
SPLogger.ERROR(TAG,"fileOpen path:" + path + " error:" + err);
let errStr:String = err
if(errStr.indexOf("denied")>0){
return "null"
SPLogger.ERROR(TAG, 'fileOpen path:' + path + ' error:' + err);
let errStr: String = err;
if (errStr.indexOf('denied') > 0) {
return 'null';
}
} finally {
fileio.closeSync(fd)
fileio.closeSync(fd);
}
return "null"
return 'null';
}
/**
@ -77,40 +75,38 @@ export function fileOpen(path: string): String {
* @param regexp
*/
export function travelFile(path: string, regexp: string): Array<String> {
let dir
let fileNames = []
let dir;
let fileNames = [];
if (!isAccess(path)) {
return []
return [];
}
try {
dir = fileio.opendirSync(path);
do {
var dirent = dir.readSync()
var dirent = dir.readSync();
if (dirent == null) {
break
break;
}
let name: String = dirent.name
let name: String = dirent.name;
if (name.match(regexp)) {
SPLogger.DEBUG(TAG, "travelFile get name:" + dirent.name)
fileNames.push(name)
SPLogger.DEBUG(TAG, 'travelFile get name:' + dirent.name);
fileNames.push(name);
}
if (regexp == "") {
fileNames.push(name)
if (regexp == '') {
fileNames.push(name);
}
} while (dirent != null)
} while (dirent != null);
} catch (err) {
SPLogger.ERROR(TAG, "travelFile get err:" + err);
SPLogger.ERROR(TAG, "travelFile err path:" + path);
SPLogger.ERROR(TAG, 'travelFile get err:' + err);
SPLogger.ERROR(TAG, 'travelFile err path:' + path);
} finally {
dir.closeSync();
}
return fileNames
return fileNames;
}
/**
* 返回字符结尾符坐标
* @param str
@ -135,20 +131,19 @@ export function sleep(numberMillis) {
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
if (now.getTime() > exitTime) return;
}
}
/**
* 提取字符串数字
*/
export function extractNumber(originStr) {
let result = ""
let result = '';
for (var index = 0; index < originStr.length; index++) {
const element: string = originStr[index];
if (element.match("^[0-9]*$")) {
result += element
if (element.match('^[0-9]*$')) {
result += element;
}
}
return result
}
return result;
}

View File

@ -23,7 +23,7 @@ export enum CatchTraceStatus {
// trace采集运行中
catch_trace_running = 4,
// trace 采集 停止后间隔60次
catch_trace_times = 60
catch_trace_times = 60,
}
//采集状态
@ -35,22 +35,19 @@ export enum TaskStatus {
//采集暂停
task_pause = 3,
//采集结束
task_stop = 4
task_stop = 4,
}
//采集项
export enum CollectorType {
TYPE_CPU = "CPU",
TYPE_GPU = "GPU",
TYPE_DDR = "DDR",
TYPE_FPS = "FPS",
TYPE_HW_COUNTER = "HW_COUNTER",
TYPE_POWER = "POWER",
TYPE_TEMPERATURE = "TEMP",
TYPE_RAM = "RAM",
TYPE_NET = "NETWORK",
TYPE_UNKNOWN = "UNKNOWN"
};
TYPE_CPU = 'CPU',
TYPE_GPU = 'GPU',
TYPE_DDR = 'DDR',
TYPE_FPS = 'FPS',
TYPE_HW_COUNTER = 'HW_COUNTER',
TYPE_POWER = 'POWER',
TYPE_TEMPERATURE = 'TEMP',
TYPE_RAM = 'RAM',
TYPE_NET = 'NETWORK',
TYPE_UNKNOWN = 'UNKNOWN',
}

View File

@ -12,45 +12,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CPU } from '../item/CPU'
import { GPU } from '../item/GPU'
import { FPS } from '../item/FPS'
import { Power } from '../item/Power'
import { RAM } from '../item/RAM'
import { Thermal } from '../item/Thermal'
import { DDR } from '../item/DDR'
import { CPU } from '../item/CPU';
import { GPU } from '../item/GPU';
import { FPS } from '../item/FPS';
import { Power } from '../item/Power';
import { RAM } from '../item/RAM';
import { Thermal } from '../item/Thermal';
import { DDR } from '../item/DDR';
import { NetWork } from '../item/NetWork';
import { CollectorType } from './ProfilerConstant'
import { BaseProfiler } from './BaseProfiler'
import SPLogger from '../../../common/utils/SPLogger'
import { CollectorType } from './ProfilerConstant';
import { BaseProfiler } from './BaseProfiler';
import SPLogger from '../../../common/utils/SPLogger';
export class ProfilerFactory {
static getProfilerByConfig(moduleName: string): BaseProfiler{
static getProfilerByConfig(moduleName: string): BaseProfiler {
if (moduleName == CollectorType.TYPE_FPS) {
return FPS.getInstance()
return FPS.getInstance();
} else if (moduleName == CollectorType.TYPE_CPU) {
return CPU.getInstance()
return CPU.getInstance();
} else if (moduleName == CollectorType.TYPE_GPU) {
return GPU.getInstance()
return GPU.getInstance();
} else if (moduleName == CollectorType.TYPE_POWER) {
return Power.getInstance()
return Power.getInstance();
} else if (moduleName == CollectorType.TYPE_RAM) {
return RAM.getInstance()
return RAM.getInstance();
} else if (moduleName == CollectorType.TYPE_TEMPERATURE) {
return Thermal.getInstance()
return Thermal.getInstance();
} else if (moduleName == CollectorType.TYPE_DDR) {
return DDR.getInstance()
}else if (moduleName == CollectorType.TYPE_NET) {
return NetWork.getInstance()
return DDR.getInstance();
} else if (moduleName == CollectorType.TYPE_NET) {
return NetWork.getInstance();
}
return null
return null;
}
}
}

View File

@ -12,6 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface SocketProfiler{
readMessageQueue():void
export interface SocketProfiler {
readMessageQueue(): void
}

View File

@ -13,112 +13,109 @@
* limitations under the License.
*/
import fileio from '@ohos.fileio';
import { fileOpen, travelFile, createGPData, isAccess} from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler'
import { CollectorType } from '../base/ProfilerConstant'
import { GPData } from '../../entity/DatabaseEntity'
import SPLogger from '../../utils/SPLogger'
import { fileOpen, travelFile, createGPData, isAccess } from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler';
import { CollectorType } from '../base/ProfilerConstant';
import { GPData } from '../../entity/DatabaseEntity';
import SPLogger from '../../utils/SPLogger';
enum CPU_CONFIG {
CPU_BASE = "/sys/devices/system/cpu",
CPU_CUR_FREQ = "/cpufreq/scaling_cur_freq",
CPU_LOAD = "/proc/stat"
CPU_BASE = '/sys/devices/system/cpu',
CPU_CUR_FREQ = '/cpufreq/scaling_cur_freq',
CPU_LOAD = '/proc/stat',
}
export class CPU extends BaseProfiler {
private cpuMap: Map<String, String> = new Map
private cpuCoreNum: number
private prebufferArr = ["", "", "", "", "", "", "", "", ""]
private cpuMap: Map<String, String> = new Map();
private cpuCoreNum: number;
private prebufferArr = ['', '', '', '', '', '', '', '', ''];
public static instance: CPU = null
public static instance: CPU = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new CPU()
this.instance = new CPU();
}
return this.instance
return this.instance;
}
init() {
//初始化CPU 核心数 节点路径
this.cpuCoreNum = travelFile(CPU_CONFIG.CPU_BASE,"cpu[0-9]").length
return CollectorType.TYPE_CPU
this.cpuCoreNum = travelFile(CPU_CONFIG.CPU_BASE, 'cpu[0-9]').length;
return CollectorType.TYPE_CPU;
}
isSupport(){
isSupport() {
if (globalThis.useDaemon) {
return true
return true;
}
return false
return false;
}
readData() {
for (var i = 0;i < this.cpuCoreNum; i++) {
const path = CPU_CONFIG.CPU_BASE + "/cpu" + i + CPU_CONFIG.CPU_CUR_FREQ
var cpu = fileOpen(path)
this.cpuMap.set("cpu" + i + "Freq", cpu)
for (var i = 0; i < this.cpuCoreNum; i++) {
const path = CPU_CONFIG.CPU_BASE + '/cpu' + i + CPU_CONFIG.CPU_CUR_FREQ;
var cpu = fileOpen(path);
this.cpuMap.set('cpu' + i + 'Freq', cpu);
}
return createGPData("CPU", this.cpuMap)
return createGPData('CPU', this.cpuMap);
}
readCPULoad(): GPData {
const path = CPU_CONFIG.CPU_LOAD
var workLoadArr = []
const path = CPU_CONFIG.CPU_LOAD;
var workLoadArr = [];
try {
var fd = -1
fd = fileio.openSync(path, 0o0)
SPLogger.DEBUG(CPU.name,"readCPULoad fd:" + fd);
var fd = -1;
fd = fileio.openSync(path, 0o0);
SPLogger.DEBUG(CPU.name, 'readCPULoad fd:' + fd);
let buf = new ArrayBuffer(2048);
fileio.readSync(fd, buf);
let cpuStr: String = String.fromCharCode.apply(null, new Uint8Array(buf))
SPLogger.DEBUG(CPU.name,"readCPULoad cpuStr:" + cpuStr);
let cpuStrArr = []
cpuStr = cpuStr.substring(0, cpuStr.indexOf("intr"))
let cpuStr: String = String.fromCharCode.apply(null, new Uint8Array(buf));
SPLogger.DEBUG(CPU.name, 'readCPULoad cpuStr:' + cpuStr);
let cpuStrArr = [];
cpuStr = cpuStr.substring(0, cpuStr.indexOf('intr'));
let nextj = 0;
let j
for (var i = 1;i < cpuStr.length; i++) {
let j;
for (var i = 1; i < cpuStr.length; i++) {
if (cpuStr.charAt(i) == 'c') {
j = nextj
nextj = i
cpuStrArr.push(cpuStr.substring(j, nextj))
j = nextj;
nextj = i;
cpuStrArr.push(cpuStr.substring(j, nextj));
}
}
cpuStrArr.push(cpuStr.substring(nextj, nextj + 50))
let buffer = ""
for (let index = 1;index < cpuStrArr.length; index++) {
buffer = cpuStrArr[index]
let load = this.calCPULoad(buffer, this.prebufferArr[index])
workLoadArr.push(load)
this.prebufferArr[index] = buffer
cpuStrArr.push(cpuStr.substring(nextj, nextj + 50));
let buffer = '';
for (let index = 1; index < cpuStrArr.length; index++) {
buffer = cpuStrArr[index];
let load = this.calCPULoad(buffer, this.prebufferArr[index]);
workLoadArr.push(load);
this.prebufferArr[index] = buffer;
}
} catch (err) {
} finally {
fileio.closeSync(fd)
fileio.closeSync(fd);
}
let map = new Map
let map = new Map();
for (let index = 0; index < workLoadArr.length; index++) {
const element = workLoadArr[index];
map.set("cpu" + index + "Load", element)
map.set('cpu' + index + 'Load', element);
}
return createGPData("CPULoad", map)
return createGPData('CPULoad', map);
}
calCPULoad(buffer: string, pre_buffer: string): number {
if (pre_buffer.length == 0) {
return -1
return -1;
}
let timeArr: string[] = buffer.split(" ");
let pre_timeArr: string[] = pre_buffer.split(" ");
let timeArr: string[] = buffer.split(' ');
let pre_timeArr: string[] = pre_buffer.split(' ');
timeArr.reverse().pop()
pre_timeArr.reverse().pop()
timeArr.reverse()
pre_timeArr.reverse()
timeArr.reverse().pop();
pre_timeArr.reverse().pop();
timeArr.reverse();
pre_timeArr.reverse();
let time = this.ArrStr2Number(timeArr)
let pre_time = this.ArrStr2Number(pre_timeArr)
let time = this.ArrStr2Number(timeArr);
let pre_time = this.ArrStr2Number(pre_timeArr);
let user = time[0] + time[1] - pre_time[0] - pre_time[1];
let sys = time[2] - pre_time[2];
@ -129,20 +126,20 @@ export class CPU extends BaseProfiler {
if (user < 0 || sys < 0 || idle < 0 || iowait < 0 || irq < 0) {
return 0;
}
let per_user = user * 100.0 / total;
let per_sys = sys * 100.0 / total;
let per_iowait = iowait * 100.0 / total;
let per_irq = irq * 100.0 / total;
let per_user = (user * 100.0) / total;
let per_sys = (sys * 100.0) / total;
let per_iowait = (iowait * 100.0) / total;
let per_irq = (irq * 100.0) / total;
let workload = per_user + per_sys + per_iowait + per_irq;
return Number(workload.toFixed(2)).valueOf()
return Number(workload.toFixed(2)).valueOf();
}
ArrStr2Number(arr: Array<String>): Array<number> {
let result = new Array<number>()
let result = new Array<number>();
for (var index = 0; index < arr.length; index++) {
const element = arr[index].replace("\n", "");
result.push(new Number(element).valueOf())
const element = arr[index].replace('\n', '');
result.push(new Number(element).valueOf());
}
return result
return result;
}
}

View File

@ -12,43 +12,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { fileOpen, createGPData, isAccess} from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler'
import { CollectorType } from '../base/ProfilerConstant'
import SPLogger from '../../../common/utils/SPLogger'
import { fileOpen, createGPData, isAccess } from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler';
import { CollectorType } from '../base/ProfilerConstant';
import SPLogger from '../../../common/utils/SPLogger';
enum DDR_CONFIG {
DDR_BASE = "/sys/class/devfreq/ddrfreq/cur_freq"
DDR_BASE = '/sys/class/devfreq/ddrfreq/cur_freq',
}
export class DDR extends BaseProfiler {
private ddrMap: Map<String, String> = new Map
private ddrMap: Map<String, String> = new Map();
public static instance: DDR = null
public static instance: DDR = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new DDR()
this.instance = new DDR();
}
return this.instance
return this.instance;
}
init() {
//初始化DDR 节点
return CollectorType.TYPE_DDR
return CollectorType.TYPE_DDR;
}
isSupport(){
if(isAccess(DDR_CONFIG.DDR_BASE)){
return true
isSupport() {
if (isAccess(DDR_CONFIG.DDR_BASE)) {
return true;
}
return false
return false;
}
readData() {
const path = DDR_CONFIG.DDR_BASE
let ddr = fileOpen(path)
this.ddrMap.set("ddrFreq", ddr)
SPLogger.DEBUG(DDR.name, "profile_readDDR" + ddr);
return createGPData("DDR", this.ddrMap)
const path = DDR_CONFIG.DDR_BASE;
let ddr = fileOpen(path);
this.ddrMap.set('ddrFreq', ddr);
SPLogger.DEBUG(DDR.name, 'profile_readDDR' + ddr);
return createGPData('DDR', this.ddrMap);
}
}

View File

@ -13,61 +13,61 @@
* limitations under the License.
*/
import { createGPData, extractNumber } from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler'
import { CollectorType } from '../base/ProfilerConstant'
import { SocketProfiler } from '../base/SocketProfiler'
import SPLogger from '../../../common/utils/SPLogger'
import { BaseProfiler } from '../base/BaseProfiler';
import { CollectorType } from '../base/ProfilerConstant';
import { SocketProfiler } from '../base/SocketProfiler';
import SPLogger from '../../../common/utils/SPLogger';
import worker from '@ohos.worker';
import worker from '@ohos.worker';
import WorkerHandler from '../WorkerHandler';
let MainWorker = globalThis.MainWorker
let MainWorker = globalThis.MainWorker;
MainWorker.onmessage = function (result) {
WorkerHandler.socketHandler(result)
}
WorkerHandler.socketHandler(result);
};
export class FPS extends BaseProfiler implements SocketProfiler {
private fpsMap: Map<String, String> = new Map
private fpsMap: Map<String, String> = new Map;
public static instance: FPS = null
public static instance: FPS = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new FPS()
this.instance = new FPS();
}
return this.instance
return this.instance;
}
init() {
//初始化FPS
return CollectorType.TYPE_FPS
return CollectorType.TYPE_FPS;
}
isSupport(){
isSupport() {
if (globalThis.useDaemon) {
return true
return true;
}
return false
return false;
}
readData() {
if (globalThis.useDaemon) {
this.readMessageQueue()
this.readMessageQueue();
}
return createGPData("FPS", this.fpsMap)
return createGPData('FPS', this.fpsMap);
}
readMessageQueue() {
MainWorker.postMessage({ "fps": true, "pkg": globalThis.collectPkg })
SPLogger.DEBUG(FPS.name, "messageQueue for fps" + globalThis.fpsArr.length)
MainWorker.postMessage({ fps: true, pkg: globalThis.collectPkg });
SPLogger.DEBUG(FPS.name, 'messageQueue for fps' + globalThis.fpsArr.length);
if (globalThis.fpsArr.length > 0) {
let fpsQueue: Array<String> = globalThis.fpsArr
let fpsJitterQueue: Array<String> = globalThis.fpsJitterArr
let curFPS = fpsQueue.pop()
globalThis.timerFps = curFPS
let curFPSJitter = fpsJitterQueue.pop()
let fpsJitters = "\"" + curFPSJitter.split("==").join(",") + "\""
this.fpsMap.set("fpsJitters", fpsJitters)
this.fpsMap.set("fps", extractNumber(curFPS))
let fpsQueue: Array<String> = globalThis.fpsArr;
let fpsJitterQueue: Array<String> = globalThis.fpsJitterArr;
let curFPS = fpsQueue.pop();
globalThis.timerFps = curFPS;
let curFPSJitter = fpsJitterQueue.pop();
let fpsJitters = '"' + curFPSJitter.split('==').join(',') + '"';
this.fpsMap.set('fpsJitters', fpsJitters);
this.fpsMap.set('fps', extractNumber(curFPS));
}
}
}

View File

@ -13,76 +13,76 @@
* limitations under the License.
*/
import { fileOpen, createGPData, isAccess } from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler'
import { CollectorType } from '../base/ProfilerConstant'
import { BaseProfiler } from '../base/BaseProfiler';
import { CollectorType } from '../base/ProfilerConstant';
let GPU_CONFIG = {
GPU_FREQ_PATH: [
"/sys/class/devfreq/fde60000.gpu/cur_freq", //RK
"/sys/class/devfreq/gpufreq/cur_freq"
'/sys/class/devfreq/fde60000.gpu/cur_freq', //RK
'/sys/class/devfreq/gpufreq/cur_freq',
],
GPU_LOAD_PATH: [
"/sys/class/devfreq/fde60000.gpu/load", //RK
"/sys/class/devfreq/gpufreq/gpu_scene_aware/utilisation"
]
}
'/sys/class/devfreq/fde60000.gpu/load', //RK
'/sys/class/devfreq/gpufreq/gpu_scene_aware/utilisation',
],
};
export class GPU extends BaseProfiler {
private gpuMap: Map<String, String> = new Map
public static instance: GPU = null
private gpuMap: Map<String, String> = new Map();
public static instance: GPU = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new GPU()
this.instance = new GPU();
}
return this.instance
return this.instance;
}
init() {
//初始化GPU
return CollectorType.TYPE_GPU
return CollectorType.TYPE_GPU;
}
isSupport() {
let curFreqPath = undefined
let curLoadPath = undefined
GPU_CONFIG.GPU_FREQ_PATH.forEach(path => {
let curFreqPath = undefined;
let curLoadPath = undefined;
GPU_CONFIG.GPU_FREQ_PATH.forEach((path) => {
if (isAccess(path)) {
curFreqPath = path
curFreqPath = path;
}
})
GPU_CONFIG.GPU_LOAD_PATH.forEach(path => {
});
GPU_CONFIG.GPU_LOAD_PATH.forEach((path) => {
if (isAccess(path)) {
curLoadPath = path
curLoadPath = path;
}
})
});
if (curFreqPath != undefined && curLoadPath != undefined) {
return true
return true;
}
return false
return false;
}
readData() {
let gpuFreq:String = ""
let gpuLoad:String = ""
GPU_CONFIG.GPU_FREQ_PATH.forEach(path => {
let gpuFreq: String = '';
let gpuLoad: String = '';
GPU_CONFIG.GPU_FREQ_PATH.forEach((path) => {
if (isAccess(path)) {
gpuFreq = fileOpen(path)
gpuFreq = fileOpen(path);
}
})
GPU_CONFIG.GPU_LOAD_PATH.forEach(path => {
});
GPU_CONFIG.GPU_LOAD_PATH.forEach((path) => {
if (isAccess(path)) {
gpuLoad = fileOpen(path)
gpuLoad = fileOpen(path);
}
})
let loadStr: string[] = gpuLoad.split("@")
let load = "-1"
});
let loadStr: string[] = gpuLoad.split('@');
let load = '-1';
if (loadStr.length > 0) {
load = loadStr[0].toString()
load = loadStr[0].toString();
} else {
load = gpuLoad.toString()
load = gpuLoad.toString();
}
this.gpuMap.set("gpuFreq", gpuFreq)
this.gpuMap.set("gpuLoad", load)
return createGPData("GPU", this.gpuMap)
this.gpuMap.set('gpuFreq', gpuFreq);
this.gpuMap.set('gpuLoad', load);
return createGPData('GPU', this.gpuMap);
}
}

View File

@ -13,59 +13,58 @@
* limitations under the License.
*/
import { createGPData } from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler'
import { CollectorType } from '../base/ProfilerConstant'
import connection from '@ohos.net.connection'
import SPLogger from '../../../common/utils/SPLogger'
import { BaseProfiler } from '../base/BaseProfiler';
import { CollectorType } from '../base/ProfilerConstant';
import connection from '@ohos.net.connection';
import SPLogger from '../../../common/utils/SPLogger';
export class NetWork extends BaseProfiler{
private netMap: Map<String, String> = new Map
private catchNetUp = "-1"
private catchNetDown = "-1"
public static instance: NetWork = null
export class NetWork extends BaseProfiler {
private netMap: Map<String, String> = new Map();
private catchNetUp = '-1';
private catchNetDown = '-1';
public static instance: NetWork = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new NetWork()
this.instance = new NetWork();
}
return this.instance
return this.instance;
}
init() {
//初始化NET
connection.getDefaultNet().then(function (netHandle) {
connection.getNetCapabilities(netHandle).then(function (info) {
if(info != undefined){
globalThis.isNetAlive = true
}else{
globalThis.isNetAlive = false
if (info != undefined) {
globalThis.isNetAlive = true;
} else {
globalThis.isNetAlive = false;
}
})
})
return CollectorType.TYPE_NET
});
});
return CollectorType.TYPE_NET;
}
isSupport() {
SPLogger.DEBUG(NetWork.name, "networkInfo support:" + globalThis.isNetAlive)
return globalThis.isNetAlive
SPLogger.DEBUG(NetWork.name, 'networkInfo support:' + globalThis.isNetAlive);
return globalThis.isNetAlive;
}
readData() {
this.handleMessage()
this.netMap.set("netSpeedUp",this.catchNetUp)
this.netMap.set("netSpeedDown",this.catchNetDown)
return createGPData("NetWork", this.netMap)
this.handleMessage();
this.netMap.set('netSpeedUp', this.catchNetUp);
this.netMap.set('netSpeedDown', this.catchNetDown);
return createGPData('NetWork', this.netMap);
}
handleMessage(){
var that = this
handleMessage() {
var that = this;
connection.getDefaultNet().then(function (netHandle) {
connection.getNetCapabilities(netHandle).then(function (info) {
SPLogger.DEBUG(NetWork.name,"networkInfo up:" + info["linkUpBandwidthKbps"] )
SPLogger.DEBUG(NetWork.name,"networkInfo down:" + info["linkDownBandwidthKbps"])
that.catchNetDown = info["linkDownBandwidthKbps"].toString()
that.catchNetUp = info["linkUpBandwidthKbps"].toString()
})
})
SPLogger.DEBUG(NetWork.name, 'networkInfo up:' + info['linkUpBandwidthKbps']);
SPLogger.DEBUG(NetWork.name, 'networkInfo down:' + info['linkDownBandwidthKbps']);
that.catchNetDown = info['linkDownBandwidthKbps'].toString();
that.catchNetUp = info['linkUpBandwidthKbps'].toString();
});
});
}
}

View File

@ -12,109 +12,112 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { fileOpen, travelFile, createGPData, isAccess} from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler'
import StringUtils from '../../utils/StringUtils'
import { CollectorType } from '../base/ProfilerConstant'
import SPLogger from '../../../common/utils/SPLogger'
import { fileOpen, travelFile, createGPData, isAccess } from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler';
import StringUtils from '../../utils/StringUtils';
import { CollectorType } from '../base/ProfilerConstant';
import SPLogger from '../../../common/utils/SPLogger';
enum POWER_CONFIG {
//设备电源驱动默认节点
POWER_PATH = "/sys/class/power_supply/Battery"
POWER_PATH = '/sys/class/power_supply/Battery',
}
export class Power extends BaseProfiler {
private powerMap: Map<String, String> = new Map
private enableSupportItem = ["current_now", "voltage_now", "charge_now", "temp", "status"]
private supportItemKey = []
private powerMap: Map<String, String> = new Map();
private enableSupportItem = ['current_now', 'voltage_now', 'charge_now', 'temp', 'status'];
private supportItemKey = [];
public static instance: Power = null
public static instance: Power = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new Power()
this.instance = new Power();
}
return this.instance
return this.instance;
}
init() {
//初始化Power节点
let pathNodes = travelFile(POWER_CONFIG.POWER_PATH,"")
pathNodes.forEach(path=>{
this.enableSupportItem.forEach(item=>{
if(path == item ){
this.supportItemKey.push(item)
let pathNodes = travelFile(POWER_CONFIG.POWER_PATH, '');
pathNodes.forEach((path) => {
this.enableSupportItem.forEach((item) => {
if (path == item) {
this.supportItemKey.push(item);
}
})
})
SPLogger.DEBUG(Power.name,"pathNodes init length:"+ pathNodes.length + "support items:" + JSON.stringify(this.supportItemKey))
return CollectorType.TYPE_POWER
});
});
SPLogger.DEBUG(
Power.name,
'pathNodes init length:' + pathNodes.length + 'support items:' + JSON.stringify(this.supportItemKey)
);
return CollectorType.TYPE_POWER;
}
isSupport(){
if(isAccess(POWER_CONFIG.POWER_PATH)){
return true
isSupport() {
if (isAccess(POWER_CONFIG.POWER_PATH)) {
return true;
}
return false
return false;
}
readData() {
if (this.supportItemKey.length > 0) {
for (let powerKey of Array.from(new Set(this.supportItemKey))) {
if (powerKey == "current_now") {
let powerValue = this.readCurrentNow()
this.powerMap.set(powerKey, powerValue)
} else if(powerKey == "voltage_now") {
let powerValue = this.readVoltageNow()
this.powerMap.set(powerKey, powerValue)
} else {
let powerValue = fileOpen(POWER_CONFIG.POWER_PATH + "/" + powerKey)
this.powerMap.set(powerKey, powerValue)
if (powerKey == 'current_now') {
let powerValue = this.readCurrentNow();
this.powerMap.set(powerKey, powerValue);
} else if (powerKey == 'voltage_now') {
let powerValue = this.readVoltageNow();
this.powerMap.set(powerKey, powerValue);
} else {
let powerValue = fileOpen(POWER_CONFIG.POWER_PATH + '/' + powerKey);
this.powerMap.set(powerKey, powerValue);
}
}
}
return createGPData("Power", this.powerMap)
return createGPData('Power', this.powerMap);
}
readFourTimesData() {
if (this.supportItemKey.length > 0) {
for (let powerKey of Array.from(new Set(this.supportItemKey))) {
if (powerKey == "current_now") {
let powerValue = fileOpen(POWER_CONFIG.POWER_PATH + "/" + powerKey)
globalThis.powerCurArr.push(powerValue)
console.error("last CurrentNow-->push" + powerValue)
if (powerKey == 'current_now') {
let powerValue = fileOpen(POWER_CONFIG.POWER_PATH + '/' + powerKey);
globalThis.powerCurArr.push(powerValue);
console.error('last CurrentNow-->push' + powerValue);
}
if (powerKey == "voltage_now") {
let powerValue = fileOpen(POWER_CONFIG.POWER_PATH + "/" + powerKey)
globalThis.powerVoltArr.push(powerValue)
console.error("last VoltageNow-->push" + powerValue)
if (powerKey == 'voltage_now') {
let powerValue = fileOpen(POWER_CONFIG.POWER_PATH + '/' + powerKey);
globalThis.powerVoltArr.push(powerValue);
console.error('last VoltageNow-->push' + powerValue);
}
}
}
}
//TODO 电流是否取绝对值累加
readCurrentNow():string {
let powerQueue : Array<String> = globalThis.powerCurArr
let lastValue = 0
readCurrentNow(): string {
let powerQueue: Array<String> = globalThis.powerCurArr;
let lastValue = 0;
while (powerQueue.length >= 4) {
lastValue += StringUtils.s2L(powerQueue.pop().toString())
console.error("last CurrentNow-->pop" + lastValue)
lastValue += StringUtils.s2L(powerQueue.pop().toString());
console.error('last CurrentNow-->pop' + lastValue);
}
let avgCurrentNum = (lastValue / 4).toString()
console.error("last CurrentNowAVG-->" + avgCurrentNum)
return avgCurrentNum
let avgCurrentNum = (lastValue / 4).toString();
console.error('last CurrentNowAVG-->' + avgCurrentNum);
return avgCurrentNum;
}
//TODO 电流是否取绝对值累加
readVoltageNow():string {
let powerQueue : Array<String> = globalThis.powerVoltArr
let lastValue = 0
readVoltageNow(): string {
let powerQueue: Array<String> = globalThis.powerVoltArr;
let lastValue = 0;
while (powerQueue.length >= 4) {
lastValue += StringUtils.s2L(powerQueue.pop().toString())
console.error("last VoltageNow-->pop" + lastValue)
lastValue += StringUtils.s2L(powerQueue.pop().toString());
console.error('last VoltageNow-->pop' + lastValue);
}
let avgCurrentNum = (lastValue / 4).toString()
console.error("last VoltageNowAVG-->" + avgCurrentNum)
return avgCurrentNum
let avgCurrentNum = (lastValue / 4).toString();
console.error('last VoltageNowAVG-->' + avgCurrentNum);
return avgCurrentNum;
}
}

View File

@ -13,50 +13,50 @@
* limitations under the License.
*/
import { createGPData, extractNumber } from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler'
import { CollectorType } from '../base/ProfilerConstant'
import { SocketProfiler} from '../base/SocketProfiler'
import { BaseProfiler } from '../base/BaseProfiler';
import { CollectorType } from '../base/ProfilerConstant';
import { SocketProfiler } from '../base/SocketProfiler';
import WorkerHandler from '../WorkerHandler';
let MainWorker = globalThis.MainWorker
let MainWorker = globalThis.MainWorker;
MainWorker.onmessage = function (result) {
WorkerHandler.socketHandler(result)
}
WorkerHandler.socketHandler(result);
};
export class RAM extends BaseProfiler implements SocketProfiler{
private ramMap: Map<String, String> = new Map
public static instance: RAM = null
export class RAM extends BaseProfiler implements SocketProfiler {
private ramMap: Map<String, String> = new Map();
public static instance: RAM = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new RAM()
this.instance = new RAM();
}
return this.instance
return this.instance;
}
init() {
//初始化RAM节点
return CollectorType.TYPE_RAM
return CollectorType.TYPE_RAM;
}
isSupport(){
isSupport() {
if (globalThis.useDaemon) {
return true
return true;
}
return false
return false;
}
readData() {
if (globalThis.useDaemon) {
this.readMessageQueue()
this.readMessageQueue();
}
return createGPData("RAM", this.ramMap)
return createGPData('RAM', this.ramMap);
}
readMessageQueue(){
MainWorker.postMessage({ "ram": true, "pkg": globalThis.collectPkg })
readMessageQueue() {
MainWorker.postMessage({ ram: true, pkg: globalThis.collectPkg });
if (globalThis.ramArr.length > 0) {
let ramQueue: Array<String> = globalThis.ramArr
let curRAM = ramQueue.pop()
this.ramMap.set("pss", extractNumber(curRAM))
let ramQueue: Array<String> = globalThis.ramArr;
let curRAM = ramQueue.pop();
this.ramMap.set('pss', extractNumber(curRAM));
}
}
}

View File

@ -13,78 +13,69 @@
* limitations under the License.
*/
import fileio from '@ohos.fileio';
import { fileOpen, createGPData, isAccess} from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler'
import { CollectorType } from '../base/ProfilerConstant'
import SPLogger from '../../../common/utils/SPLogger'
enum THERMAL_CONFIG{
THERMAL_BASE = "/sys/devices/virtual/thermal"
import { fileOpen, createGPData, isAccess } from '../base/BaseProfilerUtils';
import { BaseProfiler } from '../base/BaseProfiler';
import { CollectorType } from '../base/ProfilerConstant';
import SPLogger from '../../../common/utils/SPLogger';
enum THERMAL_CONFIG {
THERMAL_BASE = '/sys/devices/virtual/thermal',
}
export class Thermal extends BaseProfiler {
private thermalMap: Map<String, String> = new Map
private enableSupportItem = [
"gpu-thermal",
"soc-thermal",
"shell_back",
"shell_front",
"shell_frame",
]
private supportItemMap = new Map
private thermalMap: Map<String, String> = new Map();
private enableSupportItem = ['gpu-thermal', 'soc-thermal', 'shell_back', 'shell_front', 'shell_frame'];
private supportItemMap = new Map();
public static instance: Thermal = null
public static instance: Thermal = null;
public static getInstance() {
if (this.instance == null) {
this.instance = new Thermal()
this.instance = new Thermal();
}
return this.instance
return this.instance;
}
init() {
//初始化Thermal node
var dir
var dir;
dir = fileio.opendirSync(THERMAL_CONFIG.THERMAL_BASE);
do {
var dirent = dir.readSync()
if (dirent == null ) {
break
var dirent = dir.readSync();
if (dirent == null) {
break;
}
let name: String = dirent.name
SPLogger.DEBUG(Thermal.name,"thermal_zone name:" + name)
if (name.match("thermal_zone") && name.match("thermal_zone1") == null) {
let typeName = fileOpen(THERMAL_CONFIG.THERMAL_BASE + "/" + dirent.name + "/type")
if (this.enableSupportItem.length > 0) {
this.enableSupportItem.find((item: String) => {
if (typeName.match(item.toString())) {
SPLogger.DEBUG(Thermal.name,"thermal_zone match name:" + typeName)
this.supportItemMap.set(name, item)
SPLogger.DEBUG(Thermal.name,"thermal_zone match name this.supportItemMap:" + this.supportItemMap.size)
}
})
}
let name: String = dirent.name;
SPLogger.DEBUG(Thermal.name, 'thermal_zone name:' + name);
if (name.match('thermal_zone') && name.match('thermal_zone1') == null) {
let typeName = fileOpen(THERMAL_CONFIG.THERMAL_BASE + '/' + dirent.name + '/type');
if (this.enableSupportItem.length > 0) {
this.enableSupportItem.find((item: String) => {
if (typeName.match(item.toString())) {
SPLogger.DEBUG(Thermal.name, 'thermal_zone match name:' + typeName);
this.supportItemMap.set(name, item);
SPLogger.DEBUG(Thermal.name, 'thermal_zone match name this.supportItemMap:' + this.supportItemMap.size);
}
});
}
}
} while (dirent != null)
return CollectorType.TYPE_TEMPERATURE
} while (dirent != null);
return CollectorType.TYPE_TEMPERATURE;
}
isSupport(){
if(isAccess(THERMAL_CONFIG.THERMAL_BASE)){
return true
isSupport() {
if (isAccess(THERMAL_CONFIG.THERMAL_BASE)) {
return true;
}
return false
return false;
}
readData() {
if (this.supportItemMap.size > 0) {
let timeZones = this.supportItemMap.keys()
let timeZones = this.supportItemMap.keys();
for (let timeZone of timeZones) {
let tempValue = fileOpen(THERMAL_CONFIG.THERMAL_BASE + "/" + timeZone + "/temp")
this.thermalMap.set(this.supportItemMap.get(timeZone),tempValue)
let tempValue = fileOpen(THERMAL_CONFIG.THERMAL_BASE + '/' + timeZone + '/temp');
this.thermalMap.set(this.supportItemMap.get(timeZone), tempValue);
}
}
return createGPData("Temp", this.thermalMap)
return createGPData('Temp', this.thermalMap);
}
}

View File

@ -571,12 +571,12 @@ export struct Load {
}
/**
* 初始化数据 cpu0Load、cpu1Load、cpu2Load、cpu3Load
* @param count 曲线图点的个数
* @param range y轴范围
*/
* 初始化数据 cpu0Load、cpu1Load、cpu2Load、cpu3Load
* @param count 曲线图点的个数
* @param range y轴范围
*/
private initCpuLoad0to3Data(): LineData {
let dataSet = new JArrayList<ILineDataSet>();
let values = new JArrayList<EntryOhos>();
@ -1037,52 +1037,52 @@ export struct Load {
Stack({ alignContent: Alignment.TopStart }) {
Scroll() {
Column({ space: 20 }) {
LineChart({lineChartModel: this.lineChartModel})
Row({ space: 20 }) {
Text("cpu0Load(%),") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Blue).fontSize('15fp').textAlign(TextAlign.Center)
Text('cpu1Load(%),').fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
Text('cpu2Load(%),').fontWeight(FontWeight.Bold).fontColor(Color.Red).fontSize('15fp').textAlign(TextAlign.Center)
Text('cpu3Load(%)').fontWeight(FontWeight.Bold).fontColor(Color.Orange).fontSize('15fp').textAlign(TextAlign.Center)
}
LineChart({lineChartModel: this.lineChartModel1})
Text("cpu0Frequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Red).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel2})
Row({ space: 20 }) {
Text('cpu4Load(%),').fontWeight(FontWeight.Bold).fontColor(Color.Red).fontSize('15fp').textAlign(TextAlign.Center)
Text("cpu5Load(%),") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Blue).fontSize('15fp').textAlign(TextAlign.Center)
Text('cpu6Load(%),').fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
}
LineChart({lineChartModel: this.lineChartModel3})
Text("cpu4Frequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel4})
Text("cpu7Load(%)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel5})
Text("cpu7Frequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel6})
Text("GPULoad(%)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel7})
Text("GPUFrequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
Stack() {
Column() {
LineChart({lineChartModel: this.lineChartModel8})
Text("DDR Frequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center).margin({ top: "50%" })
}
LineChart({lineChartModel: this.lineChartModel})
Row({ space: 20 }) {
Text("cpu0Load(%),") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Blue).fontSize('15fp').textAlign(TextAlign.Center)
Text('cpu1Load(%),').fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
Text('cpu2Load(%),').fontWeight(FontWeight.Bold).fontColor(Color.Red).fontSize('15fp').textAlign(TextAlign.Center)
Text('cpu3Load(%)').fontWeight(FontWeight.Bold).fontColor(Color.Orange).fontSize('15fp').textAlign(TextAlign.Center)
}
LineChart({lineChartModel: this.lineChartModel1})
Text("cpu0Frequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Red).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel2})
Row({ space: 20 }) {
Text('cpu4Load(%),').fontWeight(FontWeight.Bold).fontColor(Color.Red).fontSize('15fp').textAlign(TextAlign.Center)
Text("cpu5Load(%),") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Blue).fontSize('15fp').textAlign(TextAlign.Center)
Text('cpu6Load(%),').fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
}
LineChart({lineChartModel: this.lineChartModel3})
Text("cpu4Frequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel4})
Text("cpu7Load(%)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel5})
Text("cpu7Frequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel6})
Text("GPULoad(%)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel7})
Text("GPUFrequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center)
Stack() {
Column() {
LineChart({lineChartModel: this.lineChartModel8})
Text("DDR Frequency(MHZ)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Green).fontSize('15fp').textAlign(TextAlign.Center).margin({ top: "50%" })
}
}
}.width('100%').alignItems(HorizontalAlign.Center)
}.width('100%')
}.width('100%').height('100%')

View File

@ -60,7 +60,7 @@ export struct Performance {
this.topAxis.setPosition(XAxisPosition.TOP);
this.topAxis.setAxisMinimum(0);
this.topAxis.setAxisMaximum(this.gpData.length - 1);
this.topAxis.setDrawAxisLine(false)
this.topAxis.setDrawAxisLine(false)
if (this.gpData.length < 10) {
this.bottomAxis.setLabelCount(this.gpData.length, false);
} else {
@ -137,8 +137,8 @@ export struct Performance {
}
/**
* 获取百分比
*/
* 获取百分比
*/
private getPercent(value: number, total: number): String {
SPLogger.DEBUG(TAG, "value end : " + value + "total: " + total);
if (isNaN(value) || isNaN(total)) {
@ -153,10 +153,10 @@ export struct Performance {
}
/**
* 初始化数据
* @param count 曲线图点的个数
* @param range y轴范围
*/
* 初始化数据
* @param count 曲线图点的个数
* @param range y轴范围
*/
private initCurveData(): LineData {
let values = new JArrayList<EntryOhos>();

View File

@ -60,23 +60,23 @@ export struct Power {
console.log('globalThis.TIndexInfo--length: ' + this.gpData.length);
const gpDataCur = this.gpData[index];
let currentNow = Number(gpDataCur.currentNow).valueOf()
curVoltage = Number(gpDataCur.voltageNow).valueOf() / 1e6
curVoltage = Number(gpDataCur.voltageNow).valueOf() / 1e6
let batteryTemp = Number(gpDataCur.batteryTemp).valueOf()/10;
avgBatteryTemp+=batteryTemp
batteryTemp>maxBatteryTemp?maxBatteryTemp=batteryTemp:null
batteryTemp>maxBatteryTemp?maxBatteryTemp=batteryTemp:null
normalCurrentNow += Math.abs(currentNow) * Math.abs(curVoltage) / 3.8; //机测电压 原型机3.8 wgr4.0
(0-currentNow )> maxCurrentNow ? maxCurrentNow = (0-currentNow ) : null
(0-currentNow )> maxCurrentNow ? maxCurrentNow = (0-currentNow ) : null
}
this.summaryItems.push(
new SummaryItem($r("app.media.icon_normalized_current"), "归一化电流", (normalCurrentNow / this.gpData.length).toFixed(0) + "mA", "#fff8f8"),
new SummaryItem($r("app.media.icon_normalized_current"), "最大电流", maxCurrentNow.toFixed(0) + "mA", "#fff8f8"),
new SummaryItem($r("app.media.icon_normalized_current"), "电压", (curVoltage *1000 / (this.gpData.length+1)).toFixed(0)+ "mV", "#fff8f8"),
new SummaryItem($r("app.media.icon_max_temperature"), "平均温度", (avgBatteryTemp/ (this.gpData.length+1)).toFixed(0) + "℃", "#fff8f8"),
new SummaryItem($r("app.media.icon_max_temperature"), "最大温度", (maxBatteryTemp ).toFixed(0) + "℃", "#fff8f8"),
new SummaryItem($r("app.media.icon_normalized_current"), "归一耗电", (normalCurrentNow*parseInt(this.testDuration)/3600/ (this.gpData.length-1)).toFixed(5) + "mAH", "#fff8f8"),
)
this.summaryItems.push(
new SummaryItem($r("app.media.icon_normalized_current"), "归一化电流", (normalCurrentNow / this.gpData.length).toFixed(0) + "mA", "#fff8f8"),
new SummaryItem($r("app.media.icon_normalized_current"), "最大电流", maxCurrentNow.toFixed(0) + "mA", "#fff8f8"),
new SummaryItem($r("app.media.icon_normalized_current"), "电压", (curVoltage *1000 / (this.gpData.length+1)).toFixed(0)+ "mV", "#fff8f8"),
new SummaryItem($r("app.media.icon_max_temperature"), "平均温度", (avgBatteryTemp/ (this.gpData.length+1)).toFixed(0) + "℃", "#fff8f8"),
new SummaryItem($r("app.media.icon_max_temperature"), "最大温度", (maxBatteryTemp ).toFixed(0) + "℃", "#fff8f8"),
new SummaryItem($r("app.media.icon_normalized_current"), "归一耗电", (normalCurrentNow*parseInt(this.testDuration)/3600/ (this.gpData.length-1)).toFixed(5) + "mAH", "#fff8f8"),
)
this.lineData = this.initCurveData();
@ -181,10 +181,10 @@ export struct Power {
}
/**
* 初始化数据
* @param count 曲线图点的个数
* @param range y轴范围
*/
* 初始化数据
* @param count 曲线图点的个数
* @param range y轴范围
*/
private initCurveData(): LineData {
let values = new JArrayList<EntryOhos>();

View File

@ -29,10 +29,10 @@ export struct PowerDubai {
for (var i = 0; i <this.tPowerSensorList.length ; i++) {
if(this.tPowerSensorList[i].power==""||this.tPowerSensorList[i].power==null){
this.tPowerSensorList[i].setPower("0")
this.tPowerSensorList[i].setCurrent("0")
this.tPowerSensorList[i].setPerenct("0.00%")
}else{
this.tPowerSensorList[i].setPower("0")
this.tPowerSensorList[i].setCurrent("0")
this.tPowerSensorList[i].setPerenct("0.00%")
}else{
sumPower+=Number(this.tPowerSensorList[i].power.toString())
sumCurrent+=Number(this.tPowerSensorList[i].current.toString())
}
@ -53,108 +53,108 @@ export struct PowerDubai {
build() {
Scroll(){
Column(){
Column() {
Column(){
Column() {
Text("功耗拆解知识参考项,测试应用功耗请使用归一化电流/整机电流(报告概览页)") {
}.fontWeight(FontWeight.Bold).fontColor($r("app.color.color_333")).fontSize('12fp').textAlign(TextAlign.Center)
Text("功耗拆解知识参考项,测试应用功耗请使用归一化电流/整机电流(报告概览页)") {
}.fontWeight(FontWeight.Bold).fontColor($r("app.color.color_333")).fontSize('12fp').textAlign(TextAlign.Center)
List() {
ForEach(this.tPowerSensorList, (powerSensor) => {
ListItem() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(powerSensor.sensor)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor( powerSensor.color)
.textAlign(TextAlign.Center)
List() {
ForEach(this.tPowerSensorList, (powerSensor) => {
ListItem() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(powerSensor.sensor)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor( powerSensor.color)
.textAlign(TextAlign.Center)
// Text(powerSensor.power)
// .fontSize('12fp')
// .fontColor($r("app.color.color_333"))
// .height('30vp')
// .width('20%')
// .border({ width: '1vp', color: $r("app.color.color_999") })
// .backgroundColor(powerSensor.color)
// .textAlign(TextAlign.Center)
// Text(powerSensor.power)
// .fontSize('12fp')
// .fontColor($r("app.color.color_333"))
// .height('30vp')
// .width('20%')
// .border({ width: '1vp', color: $r("app.color.color_999") })
// .backgroundColor(powerSensor.color)
// .textAlign(TextAlign.Center)
Text(powerSensor.current)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerSensor.color)
.textAlign(TextAlign.Center)
Text(powerSensor.percent)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerSensor.color)
.textAlign(TextAlign.Center)
}.width('100%')
}
}, powerSensor => powerSensor.sensor)
}.width('100%')
}.alignItems(HorizontalAlign.Center)
Text(powerSensor.current)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerSensor.color)
.textAlign(TextAlign.Center)
Text(powerSensor.percent)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerSensor.color)
.textAlign(TextAlign.Center)
}.width('100%')
}
}, powerSensor => powerSensor.sensor)
}.width('100%')
}.alignItems(HorizontalAlign.Center)
Column() {
Text("Top20进程功耗") {
}.fontWeight(FontWeight.Bold).fontColor($r("app.color.color_333")).fontSize('12fp').textAlign(TextAlign.Center)
Column() {
Text("Top20进程功耗") {
}.fontWeight(FontWeight.Bold).fontColor($r("app.color.color_333")).fontSize('12fp').textAlign(TextAlign.Center)
List() {
ForEach(this.TPowerAppInfoList, (powerApp) => {
ListItem() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(powerApp.application)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerApp.color)
.textAlign(TextAlign.Center)
List() {
ForEach(this.TPowerAppInfoList, (powerApp) => {
ListItem() {
Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text(powerApp.application)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerApp.color)
.textAlign(TextAlign.Center)
// Text(powerApp.power)
// .fontSize('12fp')
// .fontColor($r("app.color.color_333"))
// .height('30vp')
// .width('20%')
// .border({ width: '1vp', color: $r("app.color.color_999") })
// .backgroundColor(powerApp.color)
// .textAlign(TextAlign.Center)
// Text(powerApp.power)
// .fontSize('12fp')
// .fontColor($r("app.color.color_333"))
// .height('30vp')
// .width('20%')
// .border({ width: '1vp', color: $r("app.color.color_999") })
// .backgroundColor(powerApp.color)
// .textAlign(TextAlign.Center)
Text(powerApp.current)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerApp.color)
.textAlign(TextAlign.Center)
Text(powerApp.current)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerApp.color)
.textAlign(TextAlign.Center)
Text(powerApp.percent)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerApp.color)
.textAlign(TextAlign.Center)
Text(powerApp.percent)
.fontSize('12fp')
.fontColor($r("app.color.color_333"))
.height('30vp')
.width('20%')
.border({ width: '1vp', color: $r("app.color.color_999") })
.backgroundColor(powerApp.color)
.textAlign(TextAlign.Center)
}.width('100%')
}
}, powerApp => powerApp.application)
}.width('100%')
}.width('100%')
}
}, powerApp => powerApp.application)
}.width('100%')
}.alignItems(HorizontalAlign.Center)
}
}.alignItems(HorizontalAlign.Center)
}
}.scrollable(ScrollDirection.Vertical).scrollBar(BarState.Auto).height("60%")

View File

@ -430,10 +430,10 @@ export struct Temperature {
}
/**
* 初始化数据
* @param count 曲线图点的个数
* @param range y轴范围
*/
* 初始化数据
* @param count 曲线图点的个数
* @param range y轴范围
*/
private initCurveData(): LineData {
let values = new JArrayList<EntryOhos>();
@ -692,9 +692,9 @@ export struct Temperature {
Scroll() {
Column({ space: 20 }) {
LineChart({lineChartModel: this.lineChartModel5})
Text("ShellBackTemp(℃)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Blue).fontSize('15fp').textAlign(TextAlign.Center)
LineChart({lineChartModel: this.lineChartModel5})
Text("ShellBackTemp(℃)") {
}.fontWeight(FontWeight.Bold).fontColor(Color.Blue).fontSize('15fp').textAlign(TextAlign.Center)
}.width('100%').alignItems(HorizontalAlign.Center)
}.width('100%')

View File

@ -97,10 +97,10 @@ export struct Current {
}
/**
* 初始化数据
* @param count 曲线图点的个数
* @param range y轴范围
*/
* 初始化数据
* @param count 曲线图点的个数
* @param range y轴范围
*/
private initCurveData(): LineData {
let values = new JArrayList<EntryOhos>();

View File

@ -15,34 +15,31 @@
*/
export default class ChartAnimator {
/** object that is updated upon animation update */
// private AnimatorUpdateListener mListener;
/** The phase of drawn values on the y-axis. 0 - 1 */
protected mPhaseY:number = 1;
protected mPhaseY: number = 1;
/** The phase of drawn values on the x-axis. 0 - 1 */
protected mPhaseX:number = 1;
protected mPhaseX: number = 1;
constructor() { }
constructor() {}
// constructor(listener:AnimatorUpdateListener) {
// this.mListener = listener;
// }
private xAnimator(duration:number, easing:EasingFunction):ObjectAnimator {
let animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0, 1);
private xAnimator(duration: number, easing: EasingFunction): ObjectAnimator {
let animatorX = ObjectAnimator.ofFloat(this, 'phaseX', 0, 1);
animatorX.setInterpolator(easing);
animatorX.setDuration(duration);
return animatorX;
}
private yAnimator(duration:number, easing:EasingFunction):ObjectAnimator {
let animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0, 1);
private yAnimator(duration: number, easing: EasingFunction): ObjectAnimator {
let animatorY = ObjectAnimator.ofFloat(this, 'phaseY', 0, 1);
animatorY.setInterpolator(easing);
animatorY.setDuration(duration);
@ -50,49 +47,47 @@ export default class ChartAnimator {
}
/**
* Animates values along the X axis, in a linear fashion.
*
* @param durationMillis animation duration
*/
public animateX(durationMillis:number) {
* Animates values along the X axis, in a linear fashion.
*
* @param durationMillis animation duration
*/
public animateX(durationMillis: number) {
animateX(durationMillis, Easing.Linear);
}
/**
* Animates values along the X axis.
*
* @param durationMillis animation duration
* @param easing EasingFunction
*/
public animateX(durationMillis:number, easing:EasingFunction) {
* Animates values along the X axis.
*
* @param durationMillis animation duration
* @param easing EasingFunction
*/
public animateX(durationMillis: number, easing: EasingFunction) {
let animatorX = this.xAnimator(durationMillis, easing);
animatorX.addUpdateListener(mListener);
animatorX.start();
}
/**
* Animates values along both the X and Y axes, in a linear fashion.
*
* @param durationMillisX animation duration along the X axis
* @param durationMillisY animation duration along the Y axis
*/
* Animates values along both the X and Y axes, in a linear fashion.
*
* @param durationMillisX animation duration along the X axis
* @param durationMillisY animation duration along the Y axis
*/
public animateXY(durationMillisX:number,durationMillisY:number) {
public animateXY(durationMillisX: number, durationMillisY: number) {
animateXY(durationMillisX, durationMillisY, Easing.Linear, Easing.Linear);
}
/**
* Animates values along both the X and Y axes.
*
* @param durationMillisX animation duration along the X axis
* @param durationMillisY animation duration along the Y axis
* @param easing EasingFunction for both axes
*/
public animateXY(durationMillisX:number, durationMillisY:number, easing:EasingFunction) {
* Animates values along both the X and Y axes.
*
* @param durationMillisX animation duration along the X axis
* @param durationMillisY animation duration along the Y axis
* @param easing EasingFunction for both axes
*/
public animateXY(durationMillisX: number, durationMillisY: number, easing: EasingFunction) {
let xAnimator = xAnimator(durationMillisX, easing);
let yAnimator = yAnimator(durationMillisY, easing);
@ -107,17 +102,15 @@ export default class ChartAnimator {
}
/**
* Animates values along both the X and Y axes.
*
* @param durationMillisX animation duration along the X axis
* @param durationMillisY animation duration along the Y axis
* @param easingX EasingFunction for the X axis
* @param easingY EasingFunction for the Y axis
*/
public animateXY(durationMillisX:number, durationMillisY:number, easingX:EasingFunction,
easingY:EasingFunction) {
* Animates values along both the X and Y axes.
*
* @param durationMillisX animation duration along the X axis
* @param durationMillisY animation duration along the Y axis
* @param easingX EasingFunction for the X axis
* @param easingY EasingFunction for the Y axis
*/
public animateXY(durationMillisX: number, durationMillisY: number, easingX: EasingFunction, easingY: EasingFunction) {
let xAnimator = xAnimator(durationMillisX, easingX);
let yAnimator = yAnimator(durationMillisY, easingY);
@ -132,44 +125,43 @@ export default class ChartAnimator {
}
/**
* Animates values along the Y axis, in a linear fashion.
*
* @param durationMillis animation duration
*/
* Animates values along the Y axis, in a linear fashion.
*
* @param durationMillis animation duration
*/
public animateY(durationMillis:number) {
public animateY(durationMillis: number) {
this.animateY(durationMillis, Easing.Linear);
}
/**
* Animates values along the Y axis.
*
* @param durationMillis animation duration
* @param easing EasingFunction
*/
* Animates values along the Y axis.
*
* @param durationMillis animation duration
* @param easing EasingFunction
*/
public animateY(durationMillis:number, easing:EasingFunction) {
let animatorY:ObjectAnimator = yAnimator(durationMillis, easing);
animatorY.addUpdateListener(mListener);
animatorY.start();
}
public animateY(durationMillis: number, easing: EasingFunction) {
let animatorY: ObjectAnimator = yAnimator(durationMillis, easing);
animatorY.addUpdateListener(mListener);
animatorY.start();
}
/**
* Gets the Y axis phase of the animation.
*
* @return float value of {@link #mPhaseY}
*/
public getPhaseY():number {
* Gets the Y axis phase of the animation.
*
* @return float value of {@link #mPhaseY}
*/
public getPhaseY(): number {
return this.mPhaseY;
}
/**
* Sets the Y axis phase of the animation.
*
* @param phase float value between 0 - 1
*/
public setPhaseY(phase:number) {
* Sets the Y axis phase of the animation.
*
* @param phase float value between 0 - 1
*/
public setPhaseY(phase: number) {
if (phase > 1) {
phase = 1;
} else if (phase < 0) {
@ -179,20 +171,20 @@ export default class ChartAnimator {
}
/**
* Gets the X axis phase of the animation.
*
* @return float value of {@link #mPhaseX}
*/
public getPhaseX():number {
* Gets the X axis phase of the animation.
*
* @return float value of {@link #mPhaseX}
*/
public getPhaseX(): number {
return this.mPhaseX;
}
/**
* Sets the X axis phase of the animation.
*
* @param phase float value between 0 - 1
*/
public setPhaseX(phase:number) {
* Sets the X axis phase of the animation.
*
* @param phase float value between 0 - 1
*/
public setPhaseX(phase: number) {
if (phase > 1) {
phase = 1;
} else if (phase < 0) {

View File

@ -91,12 +91,12 @@ export default struct LineChart {
for(let i=0; i<this.lineChartModel.lineData.getDataSets().size(); i++) {
let dataSet = this.lineChartModel.lineData.getDataSetByIndex(i)
let entry = new LegendEntry(
dataSet.getLabel(), // 设置图例的字符串,mLabel
dataSet.getForm(), // 设置图例的形状,mShape,默认值LegendForm.SQUARE
dataSet.getFormSize(), // 图例大小,mFormSize,默认值8
dataSet.getFormLineWidth(), // 图例线宽,mFormLineWidth,默认值3
dataSet.getLabel(), // 设置图例的字符串,mLabel
dataSet.getForm(), // 设置图例的形状,mShape,默认值LegendForm.SQUARE
dataSet.getFormSize(), // 图例大小,mFormSize,默认值8
dataSet.getFormLineWidth(), // 图例线宽,mFormLineWidth,默认值3
null, // 设置虚线,dataSet.getFormLineDashEffect()
dataSet.getColor() // 设置图例图形的颜色,
dataSet.getColor() // 设置图例图形的颜色,
)
entries.add(entry)
}

View File

@ -15,7 +15,7 @@
import { DashPathEffect } from '../data/Paint';
import Utils from '../utils/Utils';
import {JArrayList} from '../utils/JArrayList';
import { JArrayList } from '../utils/JArrayList';
import DefaultAxisValueFormatter from '../formatter/DefaultAxisValueFormatter';
import IAxisValueFormatter from '../formatter/IAxisValueFormatter';
import ComponentBase from './ComponentBase';
@ -25,170 +25,165 @@ import LimitLine from './LimitLine';
* Base-class of all axes (previously called labels).
*/
export default abstract class AxisBase extends ComponentBase {
/**
/**
* custom formatter that is used instead of the auto-formatter if set
*/
protected mAxisValueFormatter: IAxisValueFormatter;
private mGridColor: number= Color.Gray;
private mGridColor: number = Color.Gray;
private mGridLineWidth: number = 1;
private mAxisLineColor: number = Color.Gray;
private mAxisLineWidth: number= 1;
private mAxisLineWidth: number = 1;
/**
/**
* the actual array of entries
*/
public mEntries: number[] = [];
/**
/**
* axis label entries only used for centered labels
*/
public mCenteredEntries: number[] = [];
/**
/**
* the number of entries the legend contains
*/
public mEntryCount: number;
/**
/**
* the number of decimal digits to use
*/
public mDecimals: number;
/**
/**
* the number of label entries the axis should have, default 6
*/
private mLabelCount: number= 6;
private mLabelCount: number = 6;
/**
/**
* the minimum interval between axis values
*/
protected mGranularity: number= 1.0;
protected mGranularity: number = 1.0;
/**
/**
* When true, axis labels are controlled by the `granularity` property.
* When false, axis values could possibly be repeated.
* This could happen if two adjacent axis values are rounded to same value.
* If using granularity this could be avoided by having fewer axis values visible.
*/
protected mGranularityEnabled: boolean= false;
protected mGranularityEnabled: boolean = false;
/**
/**
* if true, the set number of y-labels will be forced
*/
protected mForceLabels: boolean= false;
protected mForceLabels: boolean = false;
/**
/**
* flag indicating if the grid lines for this axis should be drawn
*/
protected mDrawGridLines: boolean= true;
protected mDrawGridLines: boolean = true;
/**
/**
* flag that indicates if the line alongside the axis is drawn or not
*/
protected mDrawAxisLine: boolean = true;
/**
/**
* flag that indicates of the labels of this axis should be drawn or not
*/
protected mDrawLabels: boolean = true;
protected mCenterAxisLabels: boolean = false;
/**
/**
* the path effect of the axis line that makes dashed lines possible
*/
private mAxisLineDashPathEffect: DashPathEffect
= null;
private mAxisLineDashPathEffect: DashPathEffect = null;
/**
/**
* the path effect of the grid lines that makes dashed lines possible
*/
private mGridDashPathEffect: DashPathEffect
= null;
private mGridDashPathEffect: DashPathEffect = null;
/**
/**
* array of limit lines that can be set for the axis
*/
protected mLimitLines: JArrayList<LimitLine>;
/**
/**
* flag indicating the limit lines layer depth
*/
protected mDrawLimitLineBehindData: boolean = false;
/**
/**
* flag indicating the grid lines layer depth
*/
protected mDrawGridLinesBehindData: boolean = true;
/**
/**
* Extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum`
*/
protected mSpaceMin: number= 0;
protected mSpaceMin: number = 0;
/**
/**
* Extra spacing for `axisMaximum` to be added to automatically calculated `axisMaximum`
*/
protected mSpaceMax: number= 0;
protected mSpaceMax: number = 0;
/**
/**
* flag indicating that the axis-min value has been customized
*/
protected mCustomAxisMin: boolean= false;
protected mCustomAxisMin: boolean = false;
/**
/**
* flag indicating that the axis-max value has been customized
*/
protected mCustomAxisMax: boolean = false;
/**
/**
* don't touch this direclty, use setter
*/
public mAxisMaximum: number= 0;
public mAxisMaximum: number = 0;
/**
/**
* don't touch this directly, use setter
*/
public mAxisMinimum: number = 0;
/**
/**
* the total range of values this axis covers
*/
public mAxisRange: number = 0;
private mAxisMinLabels: number = 2;
private mAxisMaxLabels: number = 25;
/**
/**
* The minumum number of labels on the axis
*/
public getAxisMinLabels(): number{
public getAxisMinLabels(): number {
return this.mAxisMinLabels;
}
/**
/**
* The minumum number of labels on the axis
*/
public setAxisMinLabels(labels: number): void {
if (labels > 0)
this.mAxisMinLabels = labels;
if (labels > 0) this.mAxisMinLabels = labels;
}
/**
/**
* The maximum number of labels on the axis
*/
public getAxisMaxLabels(): number {
return this.mAxisMaxLabels;
}
/**
/**
* The maximum number of labels on the axis
*/
public setAxisMaxLabels(labels: number): void {
if (labels > 0)
this.mAxisMaxLabels = labels;
if (labels > 0) this.mAxisMaxLabels = labels;
}
/**
/**
* default constructor
*/
constructor() {
@ -199,7 +194,7 @@ export default abstract class AxisBase extends ComponentBase {
this.mLimitLines = new JArrayList<LimitLine>();
}
/**
/**
* Set this to true to enable drawing the grid lines for this axis.
*
* @param enabled
@ -208,7 +203,7 @@ export default abstract class AxisBase extends ComponentBase {
this.mDrawGridLines = enabled;
}
/**
/**
* Returns true if drawing grid lines is enabled for this axis.
*
* @return
@ -217,7 +212,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mDrawGridLines;
}
/**
/**
* Set this to true if the line alongside the axis should be drawn or not.
*
* @param enabled
@ -226,16 +221,16 @@ export default abstract class AxisBase extends ComponentBase {
this.mDrawAxisLine = enabled;
}
/**
/**
* Returns true if the line alongside the axis should be drawn.
*
* @return
*/
public isDrawAxisLineEnabled(): boolean{
public isDrawAxisLineEnabled(): boolean {
return this.mDrawAxisLine;
}
/**
/**
* Centers the axis labels instead of drawing them at their original position.
* This is useful especially for grouped BarChart.
*
@ -249,7 +244,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mCenterAxisLabels && this.mEntryCount > 0;
}
/**
/**
* Sets the color of the grid lines for this axis (the horizontal lines
* coming from each label).
*
@ -259,7 +254,7 @@ export default abstract class AxisBase extends ComponentBase {
this.mGridColor = color;
}
/**
/**
* Returns the color of the grid lines for this axis (the horizontal lines
* coming from each label).
*
@ -269,7 +264,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mGridColor;
}
/**
/**
* Sets the width of the border surrounding the chart in dp.
*
* @param width
@ -278,16 +273,16 @@ export default abstract class AxisBase extends ComponentBase {
this.mAxisLineWidth = Utils.convertDpToPixel(width);
}
/**
/**
* Returns the width of the axis line (line alongside the axis).
*
* @return
*/
public getAxisLineWidth(): number{
public getAxisLineWidth(): number {
return this.mAxisLineWidth;
}
/**
/**
* Sets the width of the grid lines that are drawn away from each axis
* label.
*
@ -297,7 +292,7 @@ export default abstract class AxisBase extends ComponentBase {
this.mGridLineWidth = Utils.convertDpToPixel(width);
}
/**
/**
* Returns the width of the grid lines that are drawn away from each axis
* label.
*
@ -307,7 +302,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mGridLineWidth;
}
/**
/**
* Sets the color of the border surrounding the chart.
*
* @param color
@ -316,7 +311,7 @@ export default abstract class AxisBase extends ComponentBase {
this.mAxisLineColor = color;
}
/**
/**
* Returns the color of the axis line (line alongside the axis).
*
* @return
@ -325,7 +320,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mAxisLineColor;
}
/**
/**
* Set this to true to enable drawing the labels of this axis (this will not
* affect drawing the grid lines or axis lines).
*
@ -335,16 +330,16 @@ export default abstract class AxisBase extends ComponentBase {
this.mDrawLabels = enabled;
}
/**
/**
* Returns true if drawing the labels is enabled for this axis.
*
* @return
*/
public isDrawLabelsEnabled(): boolean{
public isDrawLabelsEnabled(): boolean {
return this.mDrawLabels;
}
/**
/**
* sets the number of label entries for the y-axis max = 25, min = 2, default: 6, be aware
* that this number is not
* fixed (if force == false) and can only be approximated.
@ -356,10 +351,8 @@ export default abstract class AxisBase extends ComponentBase {
* to have uneven values
*/
public setLabelCount(count: number, force?: boolean): void {
if (count > this.getAxisMaxLabels())
count = this.getAxisMaxLabels();
if (count < this.getAxisMinLabels())
count = this.getAxisMinLabels();
if (count > this.getAxisMaxLabels()) count = this.getAxisMaxLabels();
if (count < this.getAxisMinLabels()) count = this.getAxisMinLabels();
this.mLabelCount = count;
this.mForceLabels = false;
if (force != null || force != undefined) {
@ -367,7 +360,7 @@ export default abstract class AxisBase extends ComponentBase {
}
}
/**
/**
* Returns true if focing the y-label count is enabled. Default: false
*
* @return
@ -376,7 +369,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mForceLabels;
}
/**
/**
* Returns the number of label entries the y-axis should have
*
* @return
@ -385,14 +378,14 @@ export default abstract class AxisBase extends ComponentBase {
return this.mLabelCount;
}
/**
/**
* @return true if granularity is enabled
*/
public isGranularityEnabled(): boolean {
return this.mGranularityEnabled;
}
/**
/**
* Enabled/disable granularity control on axis value intervals. If enabled, the axis
* interval is not allowed to go below a certain granularity. Default: false
*
@ -402,26 +395,26 @@ export default abstract class AxisBase extends ComponentBase {
this.mGranularityEnabled = enabled;
}
/**
/**
* @return the minimum interval between axis values
*/
public getGranularity(): number{
public getGranularity(): number {
return this.mGranularity;
}
/**
/**
* Set a minimum interval for the axis when zooming in. The axis is not allowed to go below
* that limit. This can be used to avoid label duplicating when zooming in.
*
* @param granularity
*/
public setGranularity(granularity: number): void{
public setGranularity(granularity: number): void {
this.mGranularity = granularity;
// set this to true if it was disabled, as it makes no sense to call this method with granularity disabled
this.mGranularityEnabled = true;
}
/**
/**
* Adds a new LimitLine to this axis.
*
* @param l
@ -430,13 +423,14 @@ export default abstract class AxisBase extends ComponentBase {
this.mLimitLines.add(l);
if (this.mLimitLines.size() > 6) {
console.log("MPAndroiChart",
"Warning! You have more than 6 LimitLines on your axis, do you really want " +
"that?");
console.log(
'MPAndroiChart',
'Warning! You have more than 6 LimitLines on your axis, do you really want ' + 'that?'
);
}
}
/**
/**
* Removes the specified LimitLine from the axis.
*
* @param l
@ -445,14 +439,14 @@ export default abstract class AxisBase extends ComponentBase {
this.mLimitLines.remove(l);
}
/**
/**
* Removes all LimitLines from the axis.
*/
public removeAllLimitLines(): void {
this.mLimitLines.clear();
}
/**
/**
* Returns the LimitLines of this axis.
*
* @return
@ -461,13 +455,13 @@ export default abstract class AxisBase extends ComponentBase {
return this.mLimitLines;
}
/**
/**
* If this is set to true, the LimitLines are drawn behind the actual data,
* otherwise on top. Default: false
*
* @param enabled
*/
public setDrawLimitLinesBehindData(enabled: boolean): void{
public setDrawLimitLinesBehindData(enabled: boolean): void {
this.mDrawLimitLineBehindData = enabled;
}
@ -475,7 +469,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mDrawLimitLineBehindData;
}
/**
/**
* If this is set to false, the grid lines are draw on top of the actual data,
* otherwise behind. Default: true
*
@ -489,32 +483,28 @@ export default abstract class AxisBase extends ComponentBase {
return this.mDrawGridLinesBehindData;
}
/**
/**
* Returns the longest formatted label (in terms of characters), this axis
* contains.
*
* @return
*/
public getLongestLabel(): string {
var longest: string = "";
var longest: string = '';
for (var i = 0; i < this.mEntries.length; i++) {
var text: string = this.getFormattedLabel(i);
if (text && text != null && longest.length < text.length)
longest = text;
if (text && text != null && longest.length < text.length) longest = text;
}
return longest;
}
public getFormattedLabel(index: number): string{
if (index < 0 || index >= this.mEntries.length)
return "";
else
return this.getValueFormatter().getFormattedValue(this.mEntries[index], this);
public getFormattedLabel(index: number): string {
if (index < 0 || index >= this.mEntries.length) return '';
else return this.getValueFormatter().getFormattedValue(this.mEntries[index], this);
}
/**
/**
* Sets the formatter to be used for formatting the axis labels. If no formatter is set, the
* chart will
* automatically determine a reasonable formatting (concerning decimals) for all the values
@ -524,29 +514,28 @@ export default abstract class AxisBase extends ComponentBase {
* @param f
*/
public setValueFormatter(f: IAxisValueFormatter): void {
if (!f || f == null)
this.mAxisValueFormatter = new DefaultAxisValueFormatter(this.mDecimals);
else
this.mAxisValueFormatter = f;
if (!f || f == null) this.mAxisValueFormatter = new DefaultAxisValueFormatter(this.mDecimals);
else this.mAxisValueFormatter = f;
}
/**
/**
* Returns the formatter used for formatting the axis labels.
*
* @return
*/
public getValueFormatter(): IAxisValueFormatter {
if (!this.mAxisValueFormatter || this.mAxisValueFormatter == null ||
if (
!this.mAxisValueFormatter ||
this.mAxisValueFormatter == null ||
(this.mAxisValueFormatter instanceof DefaultAxisValueFormatter &&
(this.mAxisValueFormatter as DefaultAxisValueFormatter).getDecimalDigits() != this.mDecimals))
this.mAxisValueFormatter = new DefaultAxisValueFormatter(this.mDecimals);
(this.mAxisValueFormatter as DefaultAxisValueFormatter).getDecimalDigits() != this.mDecimals)
)
this.mAxisValueFormatter = new DefaultAxisValueFormatter(this.mDecimals);
return this.mAxisValueFormatter;
}
/**
/**
* Enables the grid line to be drawn in dashed mode, e.g. like this
* "- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.
* Keep in mind that hardware acceleration boosts performance.
@ -559,26 +548,25 @@ export default abstract class AxisBase extends ComponentBase {
this.mGridDashPathEffect = new DashPathEffect([lineLength, spaceLength], phase);
}
/**
/**
* Enables the grid line to be drawn in dashed mode, e.g. like this
* "- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.
* Keep in mind that hardware acceleration boosts performance.
*
* @param effect the DashPathEffect
*/
public setGridDashedLine(effect: DashPathEffect
): void{
public setGridDashedLine(effect: DashPathEffect): void {
this.mGridDashPathEffect = effect;
}
/**
/**
* Disables the grid line to be drawn in dashed mode.
*/
public disableGridDashedLine(): void {
this.mGridDashPathEffect = null;
}
/**
/**
* Returns true if the grid dashed-line effect is enabled, false if not.
*
* @return
@ -587,18 +575,16 @@ export default abstract class AxisBase extends ComponentBase {
return this.mGridDashPathEffect == null ? false : true;
}
/**
/**
* returns the DashPathEffect that is set for grid line
*
* @return
*/
public getGridDashPathEffect(): DashPathEffect
{
public getGridDashPathEffect(): DashPathEffect {
return this.mGridDashPathEffect;
}
/**
/**
* Enables the axis line to be drawn in dashed mode, e.g. like this
* "- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.
* Keep in mind that hardware acceleration boosts performance.
@ -608,49 +594,48 @@ export default abstract class AxisBase extends ComponentBase {
* @param phase offset, in degrees (normally, use 0)
*/
public enableAxisLineDashedLine(lineLength: number, spaceLength: number, phase: number): void {
this.mAxisLineDashPathEffect = new DashPathEffect([lineLength, spaceLength],phase);
this.mAxisLineDashPathEffect = new DashPathEffect([lineLength, spaceLength], phase);
}
/**
/**
* Enables the axis line to be drawn in dashed mode, e.g. like this
* "- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF.
* Keep in mind that hardware acceleration boosts performance.
*
* @param effect the DashPathEffect
*/
public setAxisLineDashedLine(effect: DashPathEffect ): void{
public setAxisLineDashedLine(effect: DashPathEffect): void {
this.mAxisLineDashPathEffect = effect;
}
/**
/**
* Disables the axis line to be drawn in dashed mode.
*/
public disableAxisLineDashedLine(): void {
this.mAxisLineDashPathEffect = null;
}
/**
/**
* Returns true if the axis dashed-line effect is enabled, false if not.
*
* @return
*/
public isAxisLineDashedLineEnabled(): boolean{
public isAxisLineDashedLineEnabled(): boolean {
return this.mAxisLineDashPathEffect == null ? false : true;
}
/**
/**
* returns the DashPathEffect that is set for axis line
*
* @return
*/
public getAxisLineDashPathEffect(): DashPathEffect
{
public getAxisLineDashPathEffect(): DashPathEffect {
return this.mAxisLineDashPathEffect;
}
/**
* ###### BELOW CODE RELATED TO CUSTOM AXIS VALUES ######
*/
/**
* ###### BELOW CODE RELATED TO CUSTOM AXIS VALUES ######
*/
public getAxisMaximum(): number {
return this.mAxisMaximum;
@ -660,7 +645,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mAxisMinimum;
}
/**
/**
* By calling this method, any custom maximum value that has been previously set is reseted,
* and the calculation is
* done automatically.
@ -669,7 +654,7 @@ export default abstract class AxisBase extends ComponentBase {
this.mCustomAxisMax = false;
}
/**
/**
* Returns true if the axis max value has been customized (and is not calculated automatically)
*
* @return
@ -678,7 +663,7 @@ export default abstract class AxisBase extends ComponentBase {
return this.mCustomAxisMax;
}
/**
/**
* By calling this method, any custom minimum value that has been previously set is reseted,
* and the calculation is
* done automatically.
@ -687,16 +672,16 @@ export default abstract class AxisBase extends ComponentBase {
this.mCustomAxisMin = false;
}
/**
/**
* Returns true if the axis min value has been customized (and is not calculated automatically)
*
* @return
*/
public isAxisMinCustom(): boolean{
public isAxisMinCustom(): boolean {
return this.mCustomAxisMin;
}
/**
/**
* Set a custom minimum value for this axis. If set, this value will not be calculated
* automatically depending on
* the provided data. Use resetAxisMinValue() to undo this. Do not forget to call
@ -711,7 +696,7 @@ export default abstract class AxisBase extends ComponentBase {
this.mAxisRange = Math.abs(this.mAxisMaximum - min);
}
/**
/**
* Use setAxisMinimum(...) instead.
*
* @param min
@ -720,20 +705,20 @@ export default abstract class AxisBase extends ComponentBase {
this.setAxisMinimum(min);
}
/**
/**
* Set a custom maximum value for this axis. If set, this value will not be calculated
* automatically depending on
* the provided data. Use resetAxisMaxValue() to undo this.
*
* @param max
*/
public setAxisMaximum(max: number): void{
public setAxisMaximum(max: number): void {
this.mCustomAxisMax = true;
this.mAxisMaximum = max;
this.mAxisRange = Math.abs(max - this.mAxisMinimum);
}
/**
/**
* Use setAxisMaximum(...) instead.
*
* @param max
@ -742,7 +727,7 @@ export default abstract class AxisBase extends ComponentBase {
this.setAxisMaximum(max);
}
/**
/**
* Calculates the minimum / maximum and range values of the axis with the given
* minimum and maximum values from the chart data.
*
@ -750,10 +735,9 @@ export default abstract class AxisBase extends ComponentBase {
* @param dataMax the max value according to chart data
*/
public calculate(dataMin: number, dataMax: number): void {
// if custom, use value as is, else use data value
var min: number = this.mCustomAxisMin ? this.mAxisMinimum : (dataMin - this.mSpaceMin);
var max: number = this.mCustomAxisMax ? this.mAxisMaximum : (dataMax + this.mSpaceMax);
var min: number = this.mCustomAxisMin ? this.mAxisMinimum : dataMin - this.mSpaceMin;
var max: number = this.mCustomAxisMax ? this.mAxisMaximum : dataMax + this.mSpaceMax;
// temporary range (before calculations)
var range: number = Math.abs(max - min);
@ -771,28 +755,28 @@ export default abstract class AxisBase extends ComponentBase {
this.mAxisRange = Math.abs(max - min);
}
/**
/**
* Gets extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum`
*/
public getSpaceMin(): number{
public getSpaceMin(): number {
return this.mSpaceMin;
}
/**
/**
* Sets extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum`
*/
public setSpaceMin(mSpaceMin: number): void{
public setSpaceMin(mSpaceMin: number): void {
this.mSpaceMin = mSpaceMin;
}
/**
/**
* Gets extra spacing for `axisMaximum` to be added to automatically calculated `axisMaximum`
*/
public getSpaceMax(): number{
public getSpaceMax(): number {
return this.mSpaceMax;
}
/**
/**
* Sets extra spacing for `axisMaximum` to be added to automatically calculated `axisMaximum`
*/
public setSpaceMax(mSpaceMax: number): void {

View File

@ -23,37 +23,34 @@ export default abstract class ComponentBase {
/**
* flag that indicates if this axis / legend is enabled or not
*/
protected mEnabled:boolean = true;
protected mEnabled: boolean = true;
/**
* the offset in pixels this component has on the x-axis
*/
protected mXOffset:number = 5;
protected mXOffset: number = 5;
/**
* the offset in pixels this component has on the Y-axis
*/
protected mYOffset:number = 5;
protected mYOffset: number = 5;
/**
* the typeface used for the labels
*/
protected mTypeface:FontWeight/*Typeface*/ = FontWeight.Normal;
protected mTypeface: FontWeight /*Typeface*/ = FontWeight.Normal;
/**
* the text size of the labels
*/
protected mTextSize:number = 10;
protected mTextSize: number = 10;
/**
* the text color to use for the labels
*/
protected mTextColor:number = Color.Black;
protected mTextColor: number = Color.Black;
constructor(){
}
constructor() {}
/**
* Returns the used offset on the x-axis for drawing the axis or legend
@ -61,7 +58,7 @@ export default abstract class ComponentBase {
*
* @return
*/
public getXOffset():number{
public getXOffset(): number {
return this.mXOffset;
}
@ -70,7 +67,7 @@ export default abstract class ComponentBase {
*
* @param xOffset
*/
public setXOffset(xOffset:number):void{
public setXOffset(xOffset: number): void {
this.mXOffset = Utils.convertDpToPixel(xOffset);
}
@ -80,7 +77,7 @@ export default abstract class ComponentBase {
*
* @return
*/
public getYOffset():number {
public getYOffset(): number {
return this.mYOffset;
}
@ -91,7 +88,7 @@ export default abstract class ComponentBase {
*
* @param yOffset
*/
public setYOffset(yOffset:number):void {
public setYOffset(yOffset: number): void {
this.mYOffset = Utils.convertDpToPixel(yOffset);
}
@ -100,7 +97,7 @@ export default abstract class ComponentBase {
*
* @return
*/
public getTypeface():FontWeight/*Typeface*/ {
public getTypeface(): FontWeight /*Typeface*/ {
return this.mTypeface;
}
@ -109,7 +106,7 @@ export default abstract class ComponentBase {
*
* @param tf
*/
public setTypeface( tf:FontWeight/*Typeface*/):void{
public setTypeface(tf: FontWeight /*Typeface*/): void {
this.mTypeface = tf;
}
@ -119,12 +116,9 @@ export default abstract class ComponentBase {
*
* @param size the text size, in DP
*/
public setTextSize(size:number):void {
if (size > 24)
size = 24;
if (size < 6)
size = 6;
public setTextSize(size: number): void {
if (size > 24) size = 24;
if (size < 6) size = 6;
this.mTextSize = size;
}
@ -134,18 +128,17 @@ export default abstract class ComponentBase {
*
* @return
*/
public getTextSize():number {
public getTextSize(): number {
return this.mTextSize;
}
/**
* Sets the text color to use for the labels. Make sure to use
* getResources().getColor(...) when using a color from the resources.
*
* @param color
*/
public setTextColor(color:number):void {
public setTextColor(color: number): void {
this.mTextColor = color;
}
@ -154,7 +147,7 @@ export default abstract class ComponentBase {
*
* @return
*/
public getTextColor():Color|string|number|Resource {
public getTextColor(): Color | string | number | Resource {
return this.mTextColor;
}
@ -165,7 +158,7 @@ export default abstract class ComponentBase {
*
* @param enabled
*/
public setEnabled(enabled:boolean):void {
public setEnabled(enabled: boolean): void {
this.mEnabled = enabled;
}
@ -174,7 +167,7 @@ export default abstract class ComponentBase {
*
* @return
*/
public isEnabled():boolean {
public isEnabled(): boolean {
return this.mEnabled;
}
}

View File

@ -18,53 +18,52 @@ import Utils from '../utils/Utils';
import ComponentBase from './ComponentBase';
export default class Description extends ComponentBase {
/**
* the text used in the description
*/
private text: string = 'Description Label';
/**
* the text used in the description
*/
private text:string = "Description Label";
* the custom position of the description text
*/
private mPosition: MPPointF;
/**
* the custom position of the description text
*/
private mPosition:MPPointF;
* the alignment of the description text
*/
private mTextAlign: TextAlign = TextAlign.End;
/**
* the alignment of the description text
*/
private mTextAlign:TextAlign = TextAlign.End
constructor(){
constructor() {
super();
// default size
this.mTextSize = Utils.convertDpToPixel(8);
}
/**
* Sets the text to be shown as the description.
*
* @param text
*/
public setText( text:string):void {
* Sets the text to be shown as the description.
*
* @param text
*/
public setText(text: string): void {
this.text = text;
}
/**
* Returns the description text.
*
* @return
*/
public getText():string{
* Returns the description text.
*
* @return
*/
public getText(): string {
return this.text;
}
/**
* Sets a custom position for the description text in pixels on the screen.
*
* @param x - xcoordinate
* @param y - ycoordinate
*/
public setPosition(x:number, y:number):void {
* Sets a custom position for the description text in pixels on the screen.
*
* @param x - xcoordinate
* @param y - ycoordinate
*/
public setPosition(x: number, y: number): void {
if (this.mPosition == null) {
this.mPosition = MPPointF.getInstance(x, y);
} else {
@ -74,29 +73,29 @@ export default class Description extends ComponentBase {
}
/**
* Returns the customized position of the description, or null if none set.
*
* @return
*/
public getPosition():MPPointF {
* Returns the customized position of the description, or null if none set.
*
* @return
*/
public getPosition(): MPPointF {
return this.mPosition;
}
/**
* Sets the text alignment of the description text. Default RIGHT.
*
* @param align
*/
public setTextAlign(align:TextAlign) {
* Sets the text alignment of the description text. Default RIGHT.
*
* @param align
*/
public setTextAlign(align: TextAlign) {
this.mTextAlign = align;
}
/**
* Returns the text alignment of the description.
*
* @return
*/
public getTextAlign():TextAlign {
* Returns the text alignment of the description.
*
* @return
*/
public getTextAlign(): TextAlign {
return this.mTextAlign;
}
}

View File

@ -19,41 +19,40 @@ import Highlight from '../highlight/Highlight';
import MPPointF from '../utils/MPPointF';
export default interface IMarker {
/**
* @return The desired (general) offset you wish the IMarker to have on the x- and y-axis.
* By returning x: -(width / 2) you will center the IMarker horizontally.
* By returning y: -(height / 2) you will center the IMarker vertically.
*/
getOffset(): MPPointF;
/**
* @return The desired (general) offset you wish the IMarker to have on the x- and y-axis.
* By returning x: -(width / 2) you will center the IMarker horizontally.
* By returning y: -(height / 2) you will center the IMarker vertically.
*/
getOffset():MPPointF;
* @return The offset for drawing at the specific `point`. This allows conditional adjusting of the Marker position.
* If you have no adjustments to make, return getOffset().
*
* @param posX This is the X position at which the marker wants to be drawn.
* You can adjust the offset conditionally based on this argument.
* @param posY This is the X position at which the marker wants to be drawn.
* You can adjust the offset conditionally based on this argument.
*/
getOffsetForDrawingAtPoint(posX: number, posY: number): MPPointF;
/**
* @return The offset for drawing at the specific `point`. This allows conditional adjusting of the Marker position.
* If you have no adjustments to make, return getOffset().
*
* @param posX This is the X position at which the marker wants to be drawn.
* You can adjust the offset conditionally based on this argument.
* @param posY This is the X position at which the marker wants to be drawn.
* You can adjust the offset conditionally based on this argument.
*/
getOffsetForDrawingAtPoint(posX:number, posY:number):MPPointF;
* This method enables a specified custom IMarker to update it's content every time the IMarker is redrawn.
*
* @param e The Entry the IMarker belongs to. This can also be any subclass of Entry, like BarEntry or
* CandleEntry, simply cast it at runtime.
* @param highlight The highlight object contains information about the highlighted value such as it's dataset-index, the
* selected range or stack-index (only stacked bar entries).
*/
refreshContent(e: EntryOhos, highlight: Highlight): void;
/**
* This method enables a specified custom IMarker to update it's content every time the IMarker is redrawn.
*
* @param e The Entry the IMarker belongs to. This can also be any subclass of Entry, like BarEntry or
* CandleEntry, simply cast it at runtime.
* @param highlight The highlight object contains information about the highlighted value such as it's dataset-index, the
* selected range or stack-index (only stacked bar entries).
*/
refreshContent(e:EntryOhos, highlight:Highlight):void;
/**
* Draws the IMarker on the given position on the screen with the given Canvas object.
*
* @param canvas
* @param posX
* @param posY
*/
draw(posX:number, posY:number);
* Draws the IMarker on the given position on the screen with the given Canvas object.
*
* @param canvas
* @param posX
* @param posY
*/
draw(posX: number, posY: number);
}

View File

@ -14,20 +14,26 @@
*/
import ColorTemplate from '../utils/ColorTemplate';
import {LegendForm} from './Legend';
import { LegendForm } from './Legend';
export default class LegendEntry {
/**
*
* @param label The legend entry text. A `null` label will start a group.
* @param form The form to draw for this entry.
* @param formSize Set to NaN to use the legend's default.
* @param formLineWidth Set to NaN to use the legend's default.
* @param formLineDashEffect Set to nil to use the legend's default.
* @param formColor The color for drawing the form.
*/
constructor(label ?: string, form ?: LegendForm, formSize ?: number, formLineWidth ?: number,
formLineDashEffect ?: Object/*DashPathEffect*/, formColor ?: number|Color) {
*
* @param label The legend entry text. A `null` label will start a group.
* @param form The form to draw for this entry.
* @param formSize Set to NaN to use the legend's default.
* @param formLineWidth Set to NaN to use the legend's default.
* @param formLineDashEffect Set to nil to use the legend's default.
* @param formColor The color for drawing the form.
*/
constructor(
label?: string,
form?: LegendForm,
formSize?: number,
formLineWidth?: number,
formLineDashEffect?: Object /*DashPathEffect*/,
formColor?: number | Color
) {
this.label = label;
this.form = form;
this.formSize = formSize;
@ -37,52 +43,52 @@ export default class LegendEntry {
}
/**
* The legend entry text.
* A `null` label will start a group.
*/
public label:string;
* The legend entry text.
* A `null` label will start a group.
*/
public label: string;
/**
* The form to draw for this entry.
*
* `NONE` will avoid drawing a form, and any related space.
* `EMPTY` will avoid drawing a form, but keep its space.
* `DEFAULT` will use the Legend's default.
*/
public form:LegendForm = LegendForm.DEFAULT;
* The form to draw for this entry.
*
* `NONE` will avoid drawing a form, and any related space.
* `EMPTY` will avoid drawing a form, but keep its space.
* `DEFAULT` will use the Legend's default.
*/
public form: LegendForm = LegendForm.DEFAULT;
/**
* Form size will be considered except for when .None is used
*
* Set as NaN to use the legend's default
*/
public formSize:number = Number.NaN;
* Form size will be considered except for when .None is used
*
* Set as NaN to use the legend's default
*/
public formSize: number = Number.NaN;
/**
* Line width used for shapes that consist of lines.
*
* Set as NaN to use the legend's default
*/
public formLineWidth:number = Number.NaN;
* Line width used for shapes that consist of lines.
*
* Set as NaN to use the legend's default
*/
public formLineWidth: number = Number.NaN;
/**
* Line dash path effect used for shapes that consist of lines.
*
* Set to null to use the legend's default
*/
public formLineDashEffect:Object/*DashPathEffect*/ = null;
* Line dash path effect used for shapes that consist of lines.
*
* Set to null to use the legend's default
*/
public formLineDashEffect: Object /*DashPathEffect*/ = null;
/**
* The color for drawing the form
*/
public formColor:number|Color// = ColorTemplate.COLOR_NONE;
* The color for drawing the form
*/
public formColor: number | Color; // = ColorTemplate.COLOR_NONE;
public colorArr:Number[]=[]
public colorItemSpace:number=3
public colorLabelSpace:number=4
public colorWidth:number=10
public colorHeight:number=10
public labelColor:number=Color.Black
public labelTextSize:number=10
public islableNeedNewLine:boolean=false
}
public colorArr: Number[] = [];
public colorItemSpace: number = 3;
public colorLabelSpace: number = 4;
public colorWidth: number = 10;
public colorHeight: number = 10;
public labelColor: number = Color.Black;
public labelTextSize: number = 10;
public islableNeedNewLine: boolean = false;
}

View File

@ -13,18 +13,17 @@
* limitations under the License.
*/
import Paint, {Style, DashPathEffect} from '../data/Paint'
import Utils from '../utils/Utils'
import ComponentBase from '../components/ComponentBase'
import Paint, { Style, DashPathEffect } from '../data/Paint';
import Utils from '../utils/Utils';
import ComponentBase from '../components/ComponentBase';
/**
* The limit line is an additional feature for all Line-, Bar- and
* ScatterCharts. It allows the displaying of an additional line in the chart
* that marks a certain maximum / limit on the specified axis (x- or y-axis).
*
*
*/
export default class LimitLine extends ComponentBase {
/** limit / maximum (the y-value or xIndex) */
private mLimit: number = 0;
@ -32,13 +31,13 @@ export default class LimitLine extends ComponentBase {
private mLineWidth: number = 2;
/** the color of the limit line */
private mLineColor: number | string = "#ED5B5B";
private mLineColor: number | string = '#ED5B5B';
/** the style of the label text */
private mTextStyle: Style = Style.FILL_AND_STROKE;
/** label string that is drawn next to the limit line */
private mLabel: string = "";
private mLabel: string = '';
/** the path effect of this LimitLine that makes dashed lines possible */
private mDashPathEffect: DashPathEffect = null;
@ -47,7 +46,7 @@ export default class LimitLine extends ComponentBase {
private mLabelPosition: LimitLabelPosition = LimitLabelPosition.RIGHT_TOP;
constructor(limit: number, label?: string) {
super()
super();
this.mLimit = limit;
this.mLabel = label;
}
@ -68,10 +67,8 @@ export default class LimitLine extends ComponentBase {
* @param width
*/
public setLineWidth(width: number) {
if (width < 0.2)
width = 0.2;
if (width > 12.0)
width = 12.0;
if (width < 0.2) width = 0.2;
if (width > 12.0) width = 12.0;
this.mLineWidth = width;
}
@ -111,7 +108,7 @@ export default class LimitLine extends ComponentBase {
* @param phase offset, in degrees (normally, use 0)
*/
public enableDashedLine(lineLength: number, spaceLength: number, phase: number) {
this.mDashPathEffect = new DashPathEffect([lineLength, spaceLength],phase);
this.mDashPathEffect = new DashPathEffect([lineLength, spaceLength], phase);
}
/**
@ -132,10 +129,10 @@ export default class LimitLine extends ComponentBase {
}
/**
* returns the DashPathEffect that is set for this LimitLine
*
* @return
*/
* returns the DashPathEffect that is set for this LimitLine
*
* @return
*/
public getDashPathEffect(): DashPathEffect {
return this.mDashPathEffect;
}
@ -151,48 +148,48 @@ export default class LimitLine extends ComponentBase {
}
/**
* Returns the color of the value-text that is drawn next to the LimitLine.
*
* @return
*/
* Returns the color of the value-text that is drawn next to the LimitLine.
*
* @return
*/
public getTextStyle(): Style {
return this.mTextStyle;
}
/**
* Sets the position of the LimitLine value label (either on the right or on
* the left edge of the chart). Not supported for RadarChart.
*
* @param pos
*/
* Sets the position of the LimitLine value label (either on the right or on
* the left edge of the chart). Not supported for RadarChart.
*
* @param pos
*/
public setLabelPosition(pos: LimitLabelPosition) {
this.mLabelPosition = pos;
}
/**
* Returns the position of the LimitLine label (value).
*
* @return
*/
* Returns the position of the LimitLine label (value).
*
* @return
*/
public getLabelPosition(): LimitLabelPosition {
return this.mLabelPosition;
}
/**
* Sets the label that is drawn next to the limit line. Provide "" if no
* label is required.
*
* @param label
*/
* Sets the label that is drawn next to the limit line. Provide "" if no
* label is required.
*
* @param label
*/
public setLabel(label: string) {
this.mLabel = label;
}
/**
* Returns the label that is drawn next to the limit line.
*
* @return
*/
* Returns the label that is drawn next to the limit line.
*
* @return
*/
public getLabel(): string {
return this.mLabel;
}
@ -200,5 +197,8 @@ export default class LimitLine extends ComponentBase {
/** enum that indicates the position of the LimitLine label */
export enum LimitLabelPosition {
LEFT_TOP, LEFT_BOTTOM, RIGHT_TOP, RIGHT_BOTTOM
LEFT_TOP,
LEFT_BOTTOM,
RIGHT_TOP,
RIGHT_BOTTOM,
}

View File

@ -93,12 +93,12 @@ export default struct PathView {
.position({ x: 0, y: 0 })
.visibility(this.model.isShowHeightlight ? Visibility.Visible : Visibility.None)
} else if (item instanceof ImagePaint){
// Image($r('app.media.marker2'))
// .width(item.width)
// .height(item.height)
// .objectFit(ImageFit.Fill)
// .position({ x:item.x,y:item.y })
// .visibility(this.model.isShowClickValue ? Visibility.Visible : Visibility.None)
// Image($r('app.media.marker2'))
// .width(item.width)
// .height(item.height)
// .objectFit(ImageFit.Fill)
// .position({ x:item.x,y:item.y })
// .visibility(this.model.isShowClickValue ? Visibility.Visible : Visibility.None)
} else if (item instanceof TextPaint){
Text(item.text)
.position({ x: item.x, y: item.y })
@ -155,7 +155,7 @@ export class PathViewModel extends ScaleMode{
lineChartModel: LineChartModel=null;
public setYLeftAxis(yleftAxis: YAxis): void{
this.yleftAxis = yleftAxis;
this.yleftAxis = yleftAxis;
}
public setYRightAxis(yRightAxis: YAxis): void{

View File

@ -24,58 +24,57 @@ import AxisBase from './AxisBase';
* @author Philipp Jahoda
*/
export class XAxis extends AxisBase {
/**
* width of the x-axis labels in pixels - this is automatically
* calculated by the computeSize() methods in the renderers
*/
public mLabelWidth : number = 1;
public mLabelWidth: number = 1;
/**
* height of the x-axis labels in pixels - this is automatically
* calculated by the computeSize() methods in the renderers
*/
public mLabelHeight : number = 1;
public mLabelHeight: number = 1;
/**
* width of the (rotated) x-axis labels in pixels - this is automatically
* calculated by the computeSize() methods in the renderers
*/
public mLabelRotatedWidth : number = 1;
public mLabelRotatedWidth: number = 1;
/**
* height of the (rotated) x-axis labels in pixels - this is automatically
* calculated by the computeSize() methods in the renderers
*/
public mLabelRotatedHeight : number = 1;
public mLabelRotatedHeight: number = 1;
/**
* This is the angle for drawing the X axis labels (in degrees)
*/
protected mLabelRotationAngle : number = 0;
protected mLabelRotationAngle: number = 0;
/**
* if set to true, the chart will avoid that the first and last label entry
* in the chart "clip" off the edge of the chart
*/
private mAvoidFirstLastClipping : boolean = false;
private mAvoidFirstLastClipping: boolean = false;
/**
* the position of the x-labels relative to the chart
*/
private mPosition : XAxisPosition = XAxisPosition.TOP;
private mPosition: XAxisPosition = XAxisPosition.TOP;
public longest:string;
public longest: string;
constructor() {
super();
this.mYOffset = 4/*Utils.convertDpToPixel(4)*/; // -3
this.mYOffset = 4 /*Utils.convertDpToPixel(4)*/; // -3
}
/**
* returns the position of the x-labels
*/
public getPosition() : XAxisPosition {
public getPosition(): XAxisPosition {
return this.mPosition;
}
@ -84,14 +83,14 @@ export class XAxis extends AxisBase {
*
* @param pos
*/
public setPosition(pos : XAxisPosition) : void {
public setPosition(pos: XAxisPosition): void {
this.mPosition = pos;
}
/**
* returns the angle for drawing the X axis labels (in degrees)
*/
public getLabelRotationAngle() : number{
public getLabelRotationAngle(): number {
return this.mLabelRotationAngle;
}
@ -100,7 +99,7 @@ export class XAxis extends AxisBase {
*
* @param angle the angle in degrees
*/
public setLabelRotationAngle(angle : XAxisPosition) : void {
public setLabelRotationAngle(angle: XAxisPosition): void {
this.mLabelRotationAngle = angle;
}
@ -110,7 +109,7 @@ export class XAxis extends AxisBase {
*
* @param enabled
*/
public setAvoidFirstLastClipping(enabled : boolean) : void {
public setAvoidFirstLastClipping(enabled: boolean): void {
this.mAvoidFirstLastClipping = enabled;
}
@ -119,14 +118,18 @@ export class XAxis extends AxisBase {
*
* @return
*/
public isAvoidFirstLastClippingEnabled() : boolean {
public isAvoidFirstLastClippingEnabled(): boolean {
return this.mAvoidFirstLastClipping;
}
}
/**
* enum for the position of the x-labels relative to the chart
*/
* enum for the position of the x-labels relative to the chart
*/
export enum XAxisPosition {
TOP, BOTTOM, BOTH_SIDED, TOP_INSIDE, BOTTOM_INSIDE
TOP,
BOTTOM,
BOTH_SIDED,
TOP_INSIDE,
BOTTOM_INSIDE,
}

View File

@ -16,7 +16,7 @@
import router from '../utils/Utils';
import AxisBase from './AxisBase';
import Utils from '../utils/Utils';
import Paint from '../data/Paint'
import Paint from '../data/Paint';
/**
* Class representing the y-axis labels settings and its entries. Only use the setter methods to
@ -31,95 +31,96 @@ import Paint from '../data/Paint'
*/
export enum AxisDependency {
LEFT, RIGHT
LEFT,
RIGHT,
}
export enum YAxisLabelPosition {
OUTSIDE_CHART, INSIDE_CHART
OUTSIDE_CHART,
INSIDE_CHART,
}
export default class YAxis extends AxisBase {
/**
* indicates if the bottom y-label entry is drawn or not
*/
private mDrawBottomYLabelEntry: boolean = true;
/**
* indicates if the bottom y-label entry is drawn or not
*/
private mDrawBottomYLabelEntry : boolean = true;
* indicates if the top y-label entry is drawn or not
*/
private mDrawTopYLabelEntry: boolean = true;
/**
* indicates if the top y-label entry is drawn or not
*/
private mDrawTopYLabelEntry : boolean = true;
* flag that indicates if the axis is inverted or not
*/
protected mInverted: boolean = false;
/**
* flag that indicates if the axis is inverted or not
*/
protected mInverted : boolean = false;
* flag that indicates if the zero-line should be drawn regardless of other grid lines
*/
protected mDrawZeroLine: boolean = false;
/**
* flag that indicates if the zero-line should be drawn regardless of other grid lines
*/
protected mDrawZeroLine : boolean = false;
* flag indicating that auto scale min restriction should be used
*/
private mUseAutoScaleRestrictionMin: boolean = false;
/**
* flag indicating that auto scale min restriction should be used
*/
private mUseAutoScaleRestrictionMin : boolean = false;
* flag indicating that auto scale max restriction should be used
*/
private mUseAutoScaleRestrictionMax: boolean = false;
/**
* flag indicating that auto scale max restriction should be used
*/
private mUseAutoScaleRestrictionMax : boolean = false;
* Color of the zero line
*/
protected mZeroLineColor: number = Color.Gray;
/**
* Color of the zero line
*/
protected mZeroLineColor : number = Color.Gray;
* Width of the zero line in pixels
*/
protected mZeroLineWidth: number = 1;
/**
* Width of the zero line in pixels
*/
protected mZeroLineWidth : number = 1;
* axis space from the largest value to the top in percent of the total axis range
*/
protected mSpacePercentTop: number = 10;
/**
* axis space from the largest value to the top in percent of the total axis range
*/
protected mSpacePercentTop : number = 10;
* axis space from the smallest value to the bottom in percent of the total axis range
*/
protected mSpacePercentBottom: number = 10;
/**
* axis space from the smallest value to the bottom in percent of the total axis range
*/
protected mSpacePercentBottom : number = 10;
* the position of the y-labels relative to the chart
*/
private mPosition: YAxisLabelPosition = YAxisLabelPosition.OUTSIDE_CHART;
/**
* the position of the y-labels relative to the chart
*/
private mPosition : YAxisLabelPosition = YAxisLabelPosition.OUTSIDE_CHART;
* the horizontal offset of the y-label
*/
private mXLabelOffset: number = 0.0;
/**
* the horizontal offset of the y-label
*/
private mXLabelOffset : number = 0.0;
* the side this axis object represents
*/
private mAxisDependency: AxisDependency;
/**
* the side this axis object represents
*/
private mAxisDependency : AxisDependency;
* the minimum width that the axis should take (in dp).
* <p/>
* default: 0.0
*/
protected mMinWidth: number = 0;
/**
* the minimum width that the axis should take (in dp).
* <p/>
* default: 0.0
*/
protected mMinWidth : number = 0;
* the maximum width that the axis can take (in dp).
* use Inifinity for disabling the maximum
* default: Float.POSITIVE_INFINITY (no maximum specified)
*/
protected mMaxWidth: number = Number.POSITIVE_INFINITY;
/**
* the maximum width that the axis can take (in dp).
* use Inifinity for disabling the maximum
* default: Float.POSITIVE_INFINITY (no maximum specified)
*/
protected mMaxWidth : number = Number.POSITIVE_INFINITY;
constructor(position ?: AxisDependency) {
constructor(position?: AxisDependency) {
super();
// default left
@ -131,234 +132,229 @@ export default class YAxis extends AxisBase {
this.mYOffset = 0;
}
public getAxisDependency() : AxisDependency {
public getAxisDependency(): AxisDependency {
return this.mAxisDependency;
}
/**
* @return the minimum width that the axis should take (in dp).
*/
public getMinWidth() : number {
* @return the minimum width that the axis should take (in dp).
*/
public getMinWidth(): number {
return this.mMinWidth;
}
/**
* Sets the minimum width that the axis should take (in dp).
*
* @param minWidth
*/
public setMinWidth(minWidth : number) : void {
* Sets the minimum width that the axis should take (in dp).
*
* @param minWidth
*/
public setMinWidth(minWidth: number): void {
this.mMinWidth = minWidth;
}
/**
* @return the maximum width that the axis can take (in dp).
*/
public getMaxWidth() : number {
* @return the maximum width that the axis can take (in dp).
*/
public getMaxWidth(): number {
return this.mMaxWidth;
}
/**
* Sets the maximum width that the axis can take (in dp).
*
* @param maxWidth
*/
public setMaxWidth(maxWidth : number) : void {
* Sets the maximum width that the axis can take (in dp).
*
* @param maxWidth
*/
public setMaxWidth(maxWidth: number): void {
this.mMaxWidth = maxWidth;
}
/**
* returns the position of the y-labels
*/
public getLabelPosition() : YAxisLabelPosition {
* returns the position of the y-labels
*/
public getLabelPosition(): YAxisLabelPosition {
return this.mPosition;
}
/**
* sets the position of the y-labels
*
* @param pos
*/
public setPosition(pos : YAxisLabelPosition) : void {
* sets the position of the y-labels
*
* @param pos
*/
public setPosition(pos: YAxisLabelPosition): void {
this.mPosition = pos;
}
/**
* returns the horizontal offset of the y-label
*/
public getLabelXOffset() : number {
* returns the horizontal offset of the y-label
*/
public getLabelXOffset(): number {
return this.mXLabelOffset;
}
/**
* sets the horizontal offset of the y-label
*
* @param xOffset
*/
public setLabelXOffset(xOffset : number) : void {
* sets the horizontal offset of the y-label
*
* @param xOffset
*/
public setLabelXOffset(xOffset: number): void {
this.mXLabelOffset = xOffset;
}
/**
* returns true if drawing the top y-axis label entry is enabled
*
* @return
*/
public isDrawTopYLabelEntryEnabled() : boolean {
* returns true if drawing the top y-axis label entry is enabled
*
* @return
*/
public isDrawTopYLabelEntryEnabled(): boolean {
return this.mDrawTopYLabelEntry;
}
/**
* returns true if drawing the bottom y-axis label entry is enabled
*
* @return
*/
public isDrawBottomYLabelEntryEnabled() : boolean {
* returns true if drawing the bottom y-axis label entry is enabled
*
* @return
*/
public isDrawBottomYLabelEntryEnabled(): boolean {
return this.mDrawBottomYLabelEntry;
}
/**
* set this to true to enable drawing the top y-label entry. Disabling this can be helpful
* when the top y-label and
* left x-label interfere with each other. default: true
*
* @param enabled
*/
public setDrawTopYLabelEntry(enabled : boolean) : void {
* set this to true to enable drawing the top y-label entry. Disabling this can be helpful
* when the top y-label and
* left x-label interfere with each other. default: true
*
* @param enabled
*/
public setDrawTopYLabelEntry(enabled: boolean): void {
this.mDrawTopYLabelEntry = enabled;
}
/**
* If this is set to true, the y-axis is inverted which means that low values are on top of
* the chart, high values
* on bottom.
*
* @param enabled
*/
public setInverted(enabled : boolean) : void {
* If this is set to true, the y-axis is inverted which means that low values are on top of
* the chart, high values
* on bottom.
*
* @param enabled
*/
public setInverted(enabled: boolean): void {
this.mInverted = enabled;
}
/**
* If this returns true, the y-axis is inverted.
*
* @return
*/
public isInverted() : boolean {
* If this returns true, the y-axis is inverted.
*
* @return
*/
public isInverted(): boolean {
return this.mInverted;
}
/**
* This method is deprecated.
* Use setAxisMinimum(...) / setAxisMaximum(...) instead.
*
* @param startAtZero
*/
// @Deprecated
public setStartAtZero(startAtZero : boolean) : void {
if (startAtZero)
super.setAxisMinimum(0);
else
super.resetAxisMinimum();
* This method is deprecated.
* Use setAxisMinimum(...) / setAxisMaximum(...) instead.
*
* @param startAtZero
*/
// @Deprecated
public setStartAtZero(startAtZero: boolean): void {
if (startAtZero) super.setAxisMinimum(0);
else super.resetAxisMinimum();
}
/**
* Sets the top axis space in percent of the full range. Default 10f
*
* @param percent
*/
public setSpaceTop(percent : number) : void {
* Sets the top axis space in percent of the full range. Default 10f
*
* @param percent
*/
public setSpaceTop(percent: number): void {
this.mSpacePercentTop = percent;
}
/**
* Returns the top axis space in percent of the full range. Default 10f
*
* @return
*/
public getSpaceTop() : number {
* Returns the top axis space in percent of the full range. Default 10f
*
* @return
*/
public getSpaceTop(): number {
return this.mSpacePercentTop;
}
/**
* Sets the bottom axis space in percent of the full range. Default 10f
*
* @param percent
*/
public setSpaceBottom(percent : number) : void {
* Sets the bottom axis space in percent of the full range. Default 10f
*
* @param percent
*/
public setSpaceBottom(percent: number): void {
this.mSpacePercentBottom = percent;
}
/**
* Returns the bottom axis space in percent of the full range. Default 10f
*
* @return
*/
public getSpaceBottom() : number {
* Returns the bottom axis space in percent of the full range. Default 10f
*
* @return
*/
public getSpaceBottom(): number {
return this.mSpacePercentBottom;
}
public isDrawZeroLineEnabled() : boolean {
public isDrawZeroLineEnabled(): boolean {
return this.mDrawZeroLine;
}
/**
* Set this to true to draw the zero-line regardless of weather other
* grid-lines are enabled or not. Default: false
*
* @param mDrawZeroLine
*/
public setDrawZeroLine(mDrawZeroLine : boolean) : void {
* Set this to true to draw the zero-line regardless of weather other
* grid-lines are enabled or not. Default: false
*
* @param mDrawZeroLine
*/
public setDrawZeroLine(mDrawZeroLine: boolean): void {
this.mDrawZeroLine = mDrawZeroLine;
}
public getZeroLineColor() : number {
public getZeroLineColor(): number {
return this.mZeroLineColor;
}
/**
* Sets the color of the zero line
*
* @param color
*/
public setZeroLineColor(color : number) : void {
* Sets the color of the zero line
*
* @param color
*/
public setZeroLineColor(color: number): void {
this.mZeroLineColor = color;
}
public getZeroLineWidth() : number {
public getZeroLineWidth(): number {
return this.mZeroLineWidth;
}
/**
* Sets the width of the zero line in dp
*
* @param width
*/
public setZeroLineWidth(width : number) : void {
* Sets the width of the zero line in dp
*
* @param width
*/
public setZeroLineWidth(width: number): void {
this.mZeroLineWidth = Utils.convertDpToPixel(width);
}
/**
* This is for normal (not horizontal) charts horizontal spacing.
*
* @param p
* @return
*/
public getRequiredWidthSpace(p : Paint) : number {
* This is for normal (not horizontal) charts horizontal spacing.
*
* @param p
* @return
*/
public getRequiredWidthSpace(p: Paint): number {
p.setTextSize(this.mTextSize);
var label : string = super.getLongestLabel();
var width : number = Utils.calcTextWidth(p, label) + super.getXOffset() * 2;
var label: string = super.getLongestLabel();
var width: number = Utils.calcTextWidth(p, label) + super.getXOffset() * 2;
var minWidth : number = this.getMinWidth();
var maxWidth : number = this.getMaxWidth();
var minWidth: number = this.getMinWidth();
var maxWidth: number = this.getMaxWidth();
if (minWidth > 0)
minWidth = Utils.convertDpToPixel(minWidth);
if (minWidth > 0) minWidth = Utils.convertDpToPixel(minWidth);
if (maxWidth > 0 && maxWidth != Number.POSITIVE_INFINITY)
maxWidth = Utils.convertDpToPixel(maxWidth);
if (maxWidth > 0 && maxWidth != Number.POSITIVE_INFINITY) maxWidth = Utils.convertDpToPixel(maxWidth);
width = Math.max(minWidth, Math.min(width, maxWidth > 0.0 ? maxWidth : width));
@ -366,92 +362,81 @@ export default class YAxis extends AxisBase {
}
/**
* This is for HorizontalBarChart vertical spacing.
*
* @param p
* @return
*/
public getRequiredHeightSpace(p : Paint) : number {
* This is for HorizontalBarChart vertical spacing.
*
* @param p
* @return
*/
public getRequiredHeightSpace(p: Paint): number {
p.setTextSize(this.mTextSize);
var label : string = super.getLongestLabel();
var label: string = super.getLongestLabel();
return Utils.calcTextHeight(p, label) + super.getYOffset() * 2;
}
/**
* Returns true if this axis needs horizontal offset, false if no offset is needed.
*
* @return
*/
public needsOffset() : boolean {
if (super.isEnabled() && super.isDrawLabelsEnabled() && this.getLabelPosition() == YAxisLabelPosition
.OUTSIDE_CHART)
return true;
else
return false;
* Returns true if this axis needs horizontal offset, false if no offset is needed.
*
* @return
*/
public needsOffset(): boolean {
if (super.isEnabled() && super.isDrawLabelsEnabled() && this.getLabelPosition() == YAxisLabelPosition.OUTSIDE_CHART)
return true;
else return false;
}
/**
* Returns true if autoscale restriction for axis min value is enabled
*/
// @Deprecated
public isUseAutoScaleMinRestriction( ) : boolean {
* Returns true if autoscale restriction for axis min value is enabled
*/
// @Deprecated
public isUseAutoScaleMinRestriction(): boolean {
return this.mUseAutoScaleRestrictionMin;
}
/**
* Sets autoscale restriction for axis min value as enabled/disabled
*/
// @Deprecated
public setUseAutoScaleMinRestriction(isEnabled : boolean) : void {
* Sets autoscale restriction for axis min value as enabled/disabled
*/
// @Deprecated
public setUseAutoScaleMinRestriction(isEnabled: boolean): void {
this.mUseAutoScaleRestrictionMin = isEnabled;
}
/**
* Returns true if autoscale restriction for axis max value is enabled
*/
// @Deprecated
public isUseAutoScaleMaxRestriction() : boolean {
* Returns true if autoscale restriction for axis max value is enabled
*/
// @Deprecated
public isUseAutoScaleMaxRestriction(): boolean {
return this.mUseAutoScaleRestrictionMax;
}
/**
* Sets autoscale restriction for axis max value as enabled/disabled
*/
// @Deprecated
public setUseAutoScaleMaxRestriction(isEnabled : boolean) : void {
* Sets autoscale restriction for axis max value as enabled/disabled
*/
// @Deprecated
public setUseAutoScaleMaxRestriction(isEnabled: boolean): void {
this.mUseAutoScaleRestrictionMax = isEnabled;
}
// @Override
public calculate(dataMin : number, dataMax : number) : void {
var min : number = dataMin;
var max : number = dataMax;
// @Override
public calculate(dataMin: number, dataMax: number): void {
var min: number = dataMin;
var max: number = dataMax;
// Make sure max is greater than min
// Discussion: https://github.com/danielgindi/Charts/pull/3650#discussion_r221409991
if (min > max)
{
if (this.mCustomAxisMax && this.mCustomAxisMin)
{
var t : number = min;
if (min > max) {
if (this.mCustomAxisMax && this.mCustomAxisMin) {
var t: number = min;
min = max;
max = t;
}
else if (this.mCustomAxisMax)
{
} else if (this.mCustomAxisMax) {
min = max < 0 ? max * 1.5 : max * 0.5;
}
else if (this.mCustomAxisMin)
{
} else if (this.mCustomAxisMin) {
max = min < 0 ? min * 0.5 : min * 1.5;
}
}
var range : number = Math.abs(max - min);
var range: number = Math.abs(max - min);
// in case all values are equal
if (range == 0) {

View File

@ -14,19 +14,18 @@
*/
import IBarLineScatterCandleBubbleDataSet from '../interfaces/datasets/IBarLineScatterCandleBubbleDataSet';
import {JArrayList} from '../utils/JArrayList';
import { JArrayList } from '../utils/JArrayList';
import ChartData from './ChartData';
import EntryOhos from './EntryOhos';
/**
* Baseclass for all Line, Bar, Scatter, Candle and Bubble data.
*
*
*/
export default abstract class BarLineScatterCandleBubbleData<T extends IBarLineScatterCandleBubbleDataSet</*T extends */EntryOhos>>
extends ChartData<T> {
constructor(sets ?: JArrayList<T>) {
export default abstract class BarLineScatterCandleBubbleData<
T extends IBarLineScatterCandleBubbleDataSet</*T extends */ EntryOhos>
> extends ChartData<T> {
constructor(sets?: JArrayList<T>) {
super(sets);
}
}

View File

@ -13,21 +13,23 @@
* limitations under the License.
*/
import EntryOhos from './EntryOhos'
import {DataSet, Rounding} from './DataSet'
import IBarLineScatterCandleBubbleDataSet from '../interfaces/datasets/IBarLineScatterCandleBubbleDataSet'
import {JArrayList} from '../utils/JArrayList'
import EntryOhos from './EntryOhos';
import { DataSet, Rounding } from './DataSet';
import IBarLineScatterCandleBubbleDataSet from '../interfaces/datasets/IBarLineScatterCandleBubbleDataSet';
import { JArrayList } from '../utils/JArrayList';
/**
* Baseclass of all DataSets for Bar-, Line-, Scatter- and CandleStickChart.
*
*/
export default abstract class BarLineScatterCandleBubbleDataSet <T extends EntryOhos> extends DataSet<T> implements IBarLineScatterCandleBubbleDataSet<T> {
export default abstract class BarLineScatterCandleBubbleDataSet<T extends EntryOhos>
extends DataSet<T>
implements IBarLineScatterCandleBubbleDataSet<T>
{
/**
* default highlight color
*/
protected mHighLightColor: number =0xffbb73;
protected mHighLightColor: number = 0xffbb73;
constructor(yVals: JArrayList<T>, label: string) {
super(yVals, label);
@ -48,9 +50,8 @@ export default abstract class BarLineScatterCandleBubbleDataSet <T extends Entry
return this.mHighLightColor;
}
protected copyTo(barLineScatterCandleBubbleDataSet: BarLineScatterCandleBubbleDataSet<T>):void {
protected copyTo(barLineScatterCandleBubbleDataSet: BarLineScatterCandleBubbleDataSet<T>): void {
super.copyTo(barLineScatterCandleBubbleDataSet);
barLineScatterCandleBubbleDataSet.mHighLightColor = this.mHighLightColor;
}
}

View File

@ -14,24 +14,23 @@
*/
import { DashPathEffect } from './Paint';
import EntryOhos from './EntryOhos'
import IDataSet from '../interfaces/datasets/IDataSet'
import {JArrayList} from '../utils/JArrayList'
import {AxisDependency} from '../components/YAxis'
import IValueFormatter from '../formatter/IValueFormatter'
import {LegendForm} from '../components/Legend'
import MPPointF from '../utils/MPPointF'
import Color from '../utils/ColorTemplate'
import ColorTemplate from '../utils/ColorTemplate'
import Utils from '../utils/Utils'
import {Rounding} from './DataSet'
import EntryOhos from './EntryOhos';
import IDataSet from '../interfaces/datasets/IDataSet';
import { JArrayList } from '../utils/JArrayList';
import { AxisDependency } from '../components/YAxis';
import IValueFormatter from '../formatter/IValueFormatter';
import { LegendForm } from '../components/Legend';
import MPPointF from '../utils/MPPointF';
import Color from '../utils/ColorTemplate';
import ColorTemplate from '../utils/ColorTemplate';
import Utils from '../utils/Utils';
import { Rounding } from './DataSet';
/**
* This is the base dataset of all DataSets. It's purpose is to implement critical methods
* provided by the IDataSet interface.
*/
export default abstract class BaseDataSet <T extends EntryOhos> implements IDataSet<T> {
export default abstract class BaseDataSet<T extends EntryOhos> implements IDataSet<T> {
/**
* List representing all colors that are used for this DataSet
*/
@ -45,12 +44,12 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
/**
* label that describes the DataSet or the data the DataSet represents
*/
private mLabel: string = "DataSet";
private mLabel: string = 'DataSet';
/**
* this specifies which axis this DataSet should be plotted against
*/
protected mAxisDependency: AxisDependency = AxisDependency.LEFT;
protected mAxisDependency: AxisDependency = AxisDependency.LEFT;
/**
* if true, value highlightning is enabled
@ -65,7 +64,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
/**
* the typeface used for the value text
*/
protected mValueTypeface: FontWeight /*Typeface*/
protected mValueTypeface: FontWeight; /*Typeface*/
private mForm: LegendForm = LegendForm.DEFAULT;
private mFormSize: number = Number.NaN;
private mFormLineWidth: number = Number.NaN;
@ -111,15 +110,14 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
/**
* Use this method to tell the data set that the underlying data has changed.
*/
public notifyDataSetChanged(): void {
public notifyDataSetChanged(): void {
this.calcMinMax();
}
/**
* ###### ###### COLOR GETTING RELATED METHODS ##### ######
*/
public getColors(): JArrayList<Number> {
public getColors(): JArrayList<Number> {
return this.mColors;
}
@ -128,13 +126,12 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
}
public getColor(index?: number): number {
if(!index||index==null||index==undefined){
index=0;
if (!index || index == null || index == undefined) {
index = 0;
}
return this.mColors.get(index % this.mColors.size()).valueOf();
}
/**
* ###### ###### COLOR SETTING RELATED METHODS ##### ######
*/
@ -148,7 +145,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
*
* @param colors
*/
public setColorsByList(colors: JArrayList<Number>): void {
public setColorsByList(colors: JArrayList<Number>): void {
this.mColors = colors;
}
@ -176,9 +173,8 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
* @param colors
*/
public setColorsByArr(colors: number[]): void {
if (this.mColors == null) {
this.mColors = new JArrayList <Number>();
this.mColors = new JArrayList<Number>();
}
this.mColors.clear();
for (let color of colors) {
@ -191,7 +187,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
*
* @param color
*/
public addColor(color: number): void {
public addColor(color: number): void {
if (this.mColors == null) {
this.mColors = new JArrayList<Number>();
}
@ -204,7 +200,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
*
* @param color
*/
public setColorByColor(color: Number): void {
public setColorByColor(color: Number): void {
this.resetColors();
this.mColors.add(color);
}
@ -215,9 +211,14 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
* @param color
* @param alpha from 0-255
*/
public setColorByAlpha(color: number, alpha: number): void {
var mColor:number = ColorTemplate.argb(alpha, ColorTemplate.red(color), ColorTemplate.green(color), ColorTemplate.blue(color));
this.setColorsByVariable([mColor])
public setColorByAlpha(color: number, alpha: number): void {
var mColor: number = ColorTemplate.argb(
alpha,
ColorTemplate.red(color),
ColorTemplate.green(color),
ColorTemplate.blue(color)
);
this.setColorsByVariable([mColor]);
}
/**
@ -226,10 +227,12 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
* @param colors
* @param alpha
*/
public setColorsByArrAndAlpha(colors: number[], alpha: number): void {
public setColorsByArrAndAlpha(colors: number[], alpha: number): void {
this.resetColors();
for (let color of colors) {
this.addColor(ColorTemplate.argb(alpha, ColorTemplate.red(color), ColorTemplate.green(color), ColorTemplate.blue(color)));
this.addColor(
ColorTemplate.argb(alpha, ColorTemplate.red(color), ColorTemplate.green(color), ColorTemplate.blue(color))
);
}
}
@ -254,7 +257,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
return this.mLabel;
}
public setHighlightEnabled(enabled: boolean): void {
public setHighlightEnabled(enabled: boolean): void {
this.mHighlightEnabled = enabled;
}
@ -262,17 +265,13 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
return this.mHighlightEnabled;
}
public setValueFormatter(f: IValueFormatter): void {
if (f == null)
return;
else
this.mValueFormatter = f;
public setValueFormatter(f: IValueFormatter): void {
if (f == null) return;
else this.mValueFormatter = f;
}
public getValueFormatter(): IValueFormatter {
if (this.needsFormatter())
return Utils.getDefaultValueFormatter();
if (this.needsFormatter()) return Utils.getDefaultValueFormatter();
return this.mValueFormatter;
}
@ -280,7 +279,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
return this.mValueFormatter == null;
}
public setValueTextColor(color: number): void {
public setValueTextColor(color: number): void {
this.mValueColors.clear();
this.mValueColors.add(color);
}
@ -289,24 +288,22 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
this.mValueColors = colors;
}
public setValueTypeface(tf: FontWeight /*Typeface*/
): void {
public setValueTypeface(tf: FontWeight /*Typeface*/): void {
this.mValueTypeface = tf;
}
public setValueTextSize(size: number): void {
public setValueTextSize(size: number): void {
this.mValueTextSize = size;
}
public getValueTextColor(index?: number): number {
if (!index) {
index = 0
index = 0;
}
return this.mValueColors.get(index % this.mValueColors.size()).valueOf();
}
public getValueTypeface(): FontWeight /*Typeface*/
{
public getValueTypeface(): FontWeight /*Typeface*/ {
return this.mValueTypeface;
}
@ -322,7 +319,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
return this.mForm;
}
public setFormSize(formSize: number): void {
public setFormSize(formSize: number): void {
this.mFormSize = formSize;
}
@ -338,17 +335,15 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
return this.mFormLineWidth;
}
public setFormLineDashEffect(dashPathEffect: DashPathEffect
): void {
public setFormLineDashEffect(dashPathEffect: DashPathEffect): void {
this.mFormLineDashEffect = dashPathEffect;
}
public getFormLineDashEffect(): DashPathEffect
{
public getFormLineDashEffect(): DashPathEffect {
return this.mFormLineDashEffect;
}
public setDrawValues(enabled: boolean): void {
public setDrawValues(enabled: boolean): void {
this.mDrawValues = enabled;
}
@ -356,16 +351,15 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
return this.mDrawValues;
}
public setDrawIcons(enabled: boolean): void {
public setDrawIcons(enabled: boolean): void {
this.mDrawIcons = enabled;
}
public isDrawIconsEnabled(): boolean {
public isDrawIconsEnabled(): boolean {
return this.mDrawIcons;
}
public setIconsOffset(offsetDp: MPPointF): void {
public setIconsOffset(offsetDp: MPPointF): void {
this.mIconsOffset.x = offsetDp.x;
this.mIconsOffset.y = offsetDp.y;
}
@ -382,20 +376,19 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
return this.mVisible;
}
public getAxisDependency(): AxisDependency{
public getAxisDependency(): AxisDependency {
return this.mAxisDependency;
}
public setAxisDependency(dependency: AxisDependency): void {
public setAxisDependency(dependency: AxisDependency): void {
this.mAxisDependency = dependency;
}
/**
* ###### ###### DATA RELATED METHODS ###### ######
*/
public getIndexInEntries(xIndex: number): number {
for (let i = 0;i < this.getEntryCount(); i++) {
for (let i = 0; i < this.getEntryCount(); i++) {
if (xIndex == this.getEntryForIndex(i).getX()) {
return i;
}
@ -403,7 +396,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
return -1;
}
public removeFirst(): boolean {
public removeFirst(): boolean {
if (this.getEntryCount() > 0) {
var entry: T = this.getEntryForIndex(0);
return this.removeEntry(entry);
@ -416,8 +409,7 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
if (this.getEntryCount() > 0) {
var e: T = this.getEntryForIndex(this.getEntryCount() - 1);
return this.removeEntry(e);
} else
return false;
} else return false;
}
public removeEntryByXValue(xValue: number): boolean {
@ -432,12 +424,11 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
public contains(e: T): boolean {
for (let i = 0; i < this.getEntryCount(); i++) {
if (this.getEntryForIndex(i) == e)
return true;
if (this.getEntryForIndex(i) == e) return true;
}
return false;
}
protected copyTo(baseDataSet: BaseDataSet<T>): void {
protected copyTo(baseDataSet: BaseDataSet<T>): void {
baseDataSet.mAxisDependency = this.mAxisDependency;
baseDataSet.mColors = this.mColors;
baseDataSet.mDrawIcons = this.mDrawIcons;
@ -455,8 +446,8 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
baseDataSet.mVisible = this.mVisible;
}
getYMin(): number{
return 0
getYMin(): number {
return 0;
}
/**
@ -464,8 +455,8 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
*
* @return
*/
getYMax(): number{
return 0
getYMax(): number {
return 0;
}
/**
@ -473,8 +464,8 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
*
* @return
*/
getXMin(): number{
return 0
getXMin(): number {
return 0;
}
/**
@ -482,51 +473,47 @@ export default abstract class BaseDataSet <T extends EntryOhos> implements IData
*
* @return
*/
getXMax(): number{
return 0
}
getEntryCount(): number{
getXMax(): number {
return 0;
}
calcMinMax(e?: T): void{
getEntryCount(): number {
return 0;
}
calcMinMaxY(fromX: number, toX: number): void{
calcMinMax(e?: T): void {}
calcMinMaxY(fromX: number, toX: number): void {}
getEntryForXValue(xValue: number, closestToY: number, rounding?: Rounding): T {
return null;
}
getEntryForXValue(xValue: number, closestToY: number, rounding?: Rounding): T{
return null
getEntriesForXValue(xValue: number): JArrayList<T> {
return null;
}
getEntriesForXValue(xValue: number): JArrayList<T>{
return null
getEntryForIndex(index: number): T {
return null;
}
getEntryForIndex(index: number): T{
return null
getEntryIndex(xValue: number, closestToY: number, rounding: Rounding): number {
return 0;
}
getEntryIndex(xValue: number, closestToY: number, rounding: Rounding): number{
return 0
getEntryIndexByEntry(e: T): number {
return 0;
}
getEntryIndexByEntry(e: T): number{
return 0
addEntry(e: T): boolean {
return false;
}
addEntry(e : T) : boolean{
return false
addEntryOrdered(e: T): void {}
removeEntry(e: T): boolean {
return false;
}
addEntryOrdered(e : T) : void{
}
removeEntry(e : T) : boolean{
return false
}
clear() : void{
}
clear(): void {}
}

View File

@ -15,23 +15,23 @@
import { ImagePaint } from './Paint';
export default abstract class BaseEntry{
export default abstract class BaseEntry {
/** the y value */
private y:number= 0;
private y: number = 0;
/** optional spot for additional data this Entry represents */
private mData:Object = null;
private mData: Object = null;
/** optional icon image */
private mIcon:ImagePaint = null;
private mIcon: ImagePaint = null;
constructor(y?:number,icon?:ImagePaint,data?:Object) {
if(y != undefined){
this.y=y;
constructor(y?: number, icon?: ImagePaint, data?: Object) {
if (y != undefined) {
this.y = y;
}
if(icon != undefined){
this.mIcon = icon;
if (icon != undefined) {
this.mIcon = icon;
}
if(data != undefined){
this.mData = data;
if (data != undefined) {
this.mData = data;
}
}
/**
@ -39,7 +39,7 @@ export default abstract class BaseEntry{
*
* @return
*/
public getY():number {
public getY(): number {
return this.y;
}
@ -48,7 +48,7 @@ export default abstract class BaseEntry{
*
* @param icon
*/
public setIcon(icon:ImagePaint):void {
public setIcon(icon: ImagePaint): void {
this.mIcon = icon;
}
@ -57,7 +57,7 @@ export default abstract class BaseEntry{
*
* @return
*/
public getIcon():ImagePaint{
public getIcon(): ImagePaint {
return this.mIcon;
}
@ -66,7 +66,7 @@ export default abstract class BaseEntry{
*
* @param y
*/
public setY( y:number):void {
public setY(y: number): void {
this.y = y;
}
@ -76,7 +76,7 @@ export default abstract class BaseEntry{
*
* @return
*/
public getData():Object {
public getData(): Object {
return this.mData;
}
@ -85,7 +85,7 @@ export default abstract class BaseEntry{
*
* @param data
*/
public setData( data:Object):void {
public setData(data: Object): void {
this.mData = data;
}
}

View File

@ -13,21 +13,20 @@
* limitations under the License.
*/
import {DataSet} from './DataSet';
import { DataSet } from './DataSet';
import LineScatterCandleRadarDataSet from './LineScatterCandleRadarDataSet';
import ColorTemplate from '../utils/ColorTemplate';
import {JArrayList} from '../utils/JArrayList';
import { JArrayList } from '../utils/JArrayList';
import CandleEntry from './CandleEntry';
import Utils from '../utils/Utils';
import ICandleDataSet from '../interfaces/datasets/ICandleDataSet';
import Paint, {Style} from '../data/paint';
import Paint, { Style } from '../data/paint';
/**
* DataSet for the CandleStickChart.
*
*/
export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleEntry> implements ICandleDataSet {
/**
* the width of the shadow of the candle
*/
@ -55,7 +54,7 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
* paint style when open < close
* increasing candlesticks are traditionally hollow
*/
protected mIncreasingPaintStyle: Style= Style.STROKE;
protected mIncreasingPaintStyle: Style = Style.STROKE;
/**
* paint style when open > close
* descreasing candlesticks are traditionally filled
@ -111,30 +110,22 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
candleDataSet.mShadowColor = this.mShadowColor;
}
public myCalcMinMax(e: CandleEntry): void {
public myCalcMinMax(e: CandleEntry): void {
if (e.getLow() < this.mYMin) this.mYMin = e.getLow();
if (e.getLow() < this.mYMin)
this.mYMin = e.getLow();
if (e.getHigh() > this.mYMax)
this.mYMax = e.getHigh();
if (e.getHigh() > this.mYMax) this.mYMax = e.getHigh();
this.calcMinMaxX(e);
}
protected myCalcMinMaxY(e: CandleEntry): void {
if (e.getHigh() < this.mYMin) this.mYMin = e.getHigh();
if (e.getHigh() < this.mYMin)
this.mYMin = e.getHigh();
if (e.getHigh() > this.mYMax) this.mYMax = e.getHigh();
if (e.getHigh() > this.mYMax)
this.mYMax = e.getHigh();
if (e.getLow() < this.mYMin) this.mYMin = e.getLow();
if (e.getLow() < this.mYMin)
this.mYMin = e.getLow();
if (e.getLow() > this.mYMax)
this.mYMax = e.getLow();
if (e.getLow() > this.mYMax) this.mYMax = e.getLow();
}
/**
@ -143,12 +134,9 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
*
* @param space
*/
public setBarSpace(space: number): void {
if (space < 0)
space = 0;
if (space > 0.45)
space = 0.45;
public setBarSpace(space: number): void {
if (space < 0) space = 0;
if (space > 0.45) space = 0.45;
this.mBarSpace = space;
}
@ -162,7 +150,7 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
*
* @param width
*/
public setShadowWidth(width: number): void {
public setShadowWidth(width: number): void {
this.mShadowWidth = Utils.convertDpToPixel(width);
}
@ -175,7 +163,7 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
*
* @param showCandleBar
*/
public setShowCandleBar(showCandleBar: boolean): void {
public setShowCandleBar(showCandleBar: boolean): void {
this.mShowCandleBar = showCandleBar;
}
@ -201,7 +189,7 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
*
* @param color
*/
public setNeutralColor(color: number): void {
public setNeutralColor(color: number): void {
this.mNeutralColor = color;
}
@ -215,7 +203,7 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
*
* @param color
*/
public setIncreasingColor(color: number): void {
public setIncreasingColor(color: number): void {
this.mIncreasingColor = color;
}
@ -229,7 +217,7 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
*
* @param color
*/
public setDecreasingColor(color: number): void {
public setDecreasingColor(color: number): void {
this.mDecreasingColor = color;
}
@ -259,7 +247,7 @@ export default class CandleDataSet extends LineScatterCandleRadarDataSet<CandleE
*
* @param decreasingPaintStyle
*/
public setDecreasingPaintStyle(decreasingPaintStyle: Style): void {
public setDecreasingPaintStyle(decreasingPaintStyle: Style): void {
this.mDecreasingPaintStyle = decreasingPaintStyle;
}

View File

@ -20,20 +20,26 @@ import EntryOhos from './EntryOhos';
* Subclass of Entry that holds all values for one entry in a CandleStickChart.
*/
export default class CandleEntry extends EntryOhos {
/** shadow-high value */
private mShadowHigh:number = 0;
private mShadowHigh: number = 0;
/** shadow-low value */
private mShadowLow:number= 0;
private mShadowLow: number = 0;
/** close value */
private mClose:number = 0;
private mClose: number = 0;
/** open value */
private mOpen:number = 0;
constructor(x:number, shadowH?:number, shadowL?:number, open?:number, close?:number,
icon?:ImagePaint, data?:Object) {
private mOpen: number = 0;
constructor(
x: number,
shadowH?: number,
shadowL?: number,
open?: number,
close?: number,
icon?: ImagePaint,
data?: Object
) {
super(x, (shadowH + shadowL) / 2, icon, data);
this.mShadowHigh = shadowH;
this.mShadowLow = shadowL;
@ -43,19 +49,19 @@ export default class CandleEntry extends EntryOhos {
/**
* Returns the overall range (difference) between shadow-high and
* shadow-low.
*
*
* @return
*/
public getShadowRange():number {
public getShadowRange(): number {
return Math.abs(this.mShadowHigh - this.mShadowLow);
}
/**
* Returns the body size (difference between open and close).
*
*
* @return
*/
public getBodyRange():number {
public getBodyRange(): number {
return Math.abs(this.mOpen - this.mClose);
}
@ -63,67 +69,73 @@ export default class CandleEntry extends EntryOhos {
* Returns the center value of the candle. (Middle value between high and
* low)
*/
public getY():number {
public getY(): number {
return super.getY();
}
public copy():CandleEntry{
var c:CandleEntry = new CandleEntry(this.getX(), this.mShadowHigh, this.mShadowLow, this.mOpen,
this.mClose,null, this.getData());
public copy(): CandleEntry {
var c: CandleEntry = new CandleEntry(
this.getX(),
this.mShadowHigh,
this.mShadowLow,
this.mOpen,
this.mClose,
null,
this.getData()
);
return c;
}
/**
* Returns the upper shadows highest value.
*
*
* @return
*/
public getHigh():number {
public getHigh(): number {
return this.mShadowHigh;
}
public setHigh(mShadowHigh:number):void {
public setHigh(mShadowHigh: number): void {
this.mShadowHigh = mShadowHigh;
}
/**
* Returns the lower shadows lowest value.
*
*
* @return
*/
public getLow():number {
public getLow(): number {
return this.mShadowLow;
}
public setLow(mShadowLow:number):void {
public setLow(mShadowLow: number): void {
this.mShadowLow = mShadowLow;
}
/**
* Returns the bodys close value.
*
*
* @return
*/
public getClose():number {
public getClose(): number {
return this.mClose;
}
public setClose(mClose:number) :void{
public setClose(mClose: number): void {
this.mClose = mClose;
}
/**
* Returns the bodys open value.
*
*
* @return
*/
public getOpen():number {
public getOpen(): number {
return this.mOpen;
}
public setOpen( mOpen:number):void{
public setOpen(mOpen: number): void {
this.mOpen = mOpen;
}
}

View File

@ -13,11 +13,11 @@
* limitations under the License.
*/
import {AxisDependency} from '../components/YAxis';
import { AxisDependency } from '../components/YAxis';
import IValueFormatter from '../formatter/IValueFormatter';
import Highlight from '../highlight/Highlight';
import IDataSet from '../interfaces/datasets/IDataSet';
import {JArrayList} from '../utils/JArrayList';
import { JArrayList } from '../utils/JArrayList';
import MyRect from './Rect';
import EntryOhos from './EntryOhos';
@ -26,46 +26,45 @@ import EntryOhos from './EntryOhos';
* at least one (or more) DataSets, and an array of x-values.
*/
export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
/**
* maximum y-value in the value array across all axes
*/
protected mYMax : number = -Number.MAX_VALUE;
protected mYMax: number = -Number.MAX_VALUE;
/**
* the minimum y-value in the value array across all axes
*/
protected mYMin : number = Number.MAX_VALUE;
protected mYMin: number = Number.MAX_VALUE;
/**
* maximum x-value in the value array
*/
protected mXMax : number = -Number.MAX_VALUE;
protected mXMax: number = -Number.MAX_VALUE;
/**
* minimum x-value in the value array
*/
protected mXMin : number = Number.MAX_VALUE;
protected mXMin: number = Number.MAX_VALUE;
protected mLeftAxisMax : number = -Number.MAX_VALUE;
protected mLeftAxisMax: number = -Number.MAX_VALUE;
protected mLeftAxisMin : number = Number.MAX_VALUE;
protected mLeftAxisMin: number = Number.MAX_VALUE;
protected mRightAxisMax = -Number.MAX_VALUE;
protected mRightAxisMin : number = Number.MAX_VALUE;
protected mRightAxisMin: number = Number.MAX_VALUE;
public mDisplayRect: MyRect = new MyRect();
/**
* array that holds all DataSets the ChartData object represents
*/
protected mDataSets : JArrayList<T>;
protected mDataSets: JArrayList<T>;
/**
* Default constructor.
*/
constructor(dataSets ?: JArrayList<T>) {
constructor(dataSets?: JArrayList<T>) {
if (!dataSets) {
this.mDataSets = new JArrayList<T>();
} else {
@ -81,12 +80,11 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param array
* @return
*/
private arrayToList(array : T[]) : JArrayList<T> {
private arrayToList(array: T[]): JArrayList<T> {
let list = new JArrayList<T>();
for (let i = 0; i < array.length; i++) {
let data : T = array[i];
let data: T = array[i];
list.add(data);
}
@ -98,7 +96,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* changed. Calling this performs all necessary recalculations needed when
* the contained data has changed.
*/
public notifyDataChanged() : void {
public notifyDataChanged(): void {
this.calcMinMax();
}
@ -109,10 +107,9 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param fromX the x-value to start the calculation from
* @param toX the x-value to which the calculation should be performed
*/
public calcMinMaxY(fromX : number, toX : number) : void {
public calcMinMaxY(fromX: number, toX: number): void {
for (let i = 0; i < this.mDataSets.listSize; i++) {
let data : T = this.mDataSets.at(i);
let data: T = this.mDataSets.at(i);
data.calcMinMaxY(fromX, toX);
}
// apply the new data
@ -123,9 +120,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* Calc minimum and maximum values (both x and y) over all DataSets.
*/
public calcMinMax() {
if (this.mDataSets == null)
return;
if (this.mDataSets == null) return;
this.mYMax = -Number.MAX_VALUE;
this.mYMin = Number.MAX_VALUE;
@ -142,39 +137,33 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
this.mRightAxisMin = Number.MAX_VALUE;
// left axis
let firstLeft : T = this.getFirstLeft(this.mDataSets);
let firstLeft: T = this.getFirstLeft(this.mDataSets);
if (firstLeft) {
this.mLeftAxisMax = firstLeft.getYMax();
this.mLeftAxisMin = firstLeft.getYMin();
for (let dataSet of this.mDataSets.dataSouce) {
if (dataSet.getAxisDependency() == AxisDependency.LEFT) {
if (dataSet.getYMin() < this.mLeftAxisMin)
this. mLeftAxisMin = dataSet.getYMin();
if (dataSet.getYMin() < this.mLeftAxisMin) this.mLeftAxisMin = dataSet.getYMin();
if (dataSet.getYMax() > this.mLeftAxisMax)
this. mLeftAxisMax = dataSet.getYMax();
if (dataSet.getYMax() > this.mLeftAxisMax) this.mLeftAxisMax = dataSet.getYMax();
}
}
}
// right axis
let firstRight : T = this.getFirstRight(this.mDataSets);
let firstRight: T = this.getFirstRight(this.mDataSets);
if (firstRight) {
this.mRightAxisMax = firstRight.getYMax();
this.mRightAxisMin = firstRight.getYMin();
for (let dataSet of this.mDataSets.dataSouce) {
if (dataSet.getAxisDependency() == AxisDependency.RIGHT) {
if (dataSet.getYMin() < this.mRightAxisMin)
this.mRightAxisMin = dataSet.getYMin();
if (dataSet.getYMin() < this.mRightAxisMin) this.mRightAxisMin = dataSet.getYMin();
if (dataSet.getYMax() > this.mRightAxisMax)
this.mRightAxisMax = dataSet.getYMax();
if (dataSet.getYMax() > this.mRightAxisMax) this.mRightAxisMax = dataSet.getYMax();
}
}
}
@ -187,7 +176,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getDataSetCount() : number {
public getDataSetCount(): number {
if (this.mDataSets == null) {
return 0;
}
@ -201,21 +190,18 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param axis
* @return
*/
public getYMin(axis ?: AxisDependency) : number{
public getYMin(axis?: AxisDependency): number {
if (axis == null) {
return this.mYMin;
}
if (axis == AxisDependency.LEFT) {
if (this.mLeftAxisMin == Number.MAX_VALUE) {
return this.mRightAxisMin;
} else
return this.mLeftAxisMin;
} else return this.mLeftAxisMin;
} else {
if (this.mRightAxisMin == Number.MAX_VALUE) {
return this.mLeftAxisMin;
} else
return this.mRightAxisMin;
} else return this.mRightAxisMin;
}
}
@ -225,21 +211,18 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param axis
* @return
*/
public getYMax(axis ?: AxisDependency) : number {
public getYMax(axis?: AxisDependency): number {
if (axis == null) {
return this.mYMax;
}
if (axis == AxisDependency.LEFT) {
if (this.mLeftAxisMax == -Number.MAX_VALUE) {
return this.mRightAxisMax;
} else
return this.mLeftAxisMax;
} else return this.mLeftAxisMax;
} else {
if (this.mRightAxisMax == -Number.MAX_VALUE) {
return this.mLeftAxisMax;
} else
return this.mRightAxisMax;
} else return this.mRightAxisMax;
}
}
@ -248,7 +231,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getXMin() : number {
public getXMin(): number {
return this.mXMin;
}
@ -257,7 +240,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getXMax() : number {
public getXMax(): number {
return this.mXMax;
}
@ -266,7 +249,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getDataSets() : JArrayList<T> {
public getDataSets(): JArrayList<T> {
return this.mDataSets;
}
@ -281,17 +264,12 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param ignorecase if true, the search is not case-sensitive
* @return
*/
protected getDataSetIndexByLabel(dataSets : JArrayList<T> , label : string,
ignorecase : boolean) : number {
protected getDataSetIndexByLabel(dataSets: JArrayList<T>, label: string, ignorecase: boolean): number {
if (ignorecase) {
for (let i : number = 0; i < dataSets.size(); i++)
if (label.toLowerCase() == dataSets.get(i).getLabel().toLowerCase())
return i;
for (let i: number = 0; i < dataSets.size(); i++)
if (label.toLowerCase() == dataSets.get(i).getLabel().toLowerCase()) return i;
} else {
for (let i : number = 0; i < dataSets.size(); i++)
if (label == dataSets.get(i).getLabel())
return i;
for (let i: number = 0; i < dataSets.size(); i++) if (label == dataSets.get(i).getLabel()) return i;
}
return -1;
@ -302,11 +280,10 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getDataSetLabels() : string[] {
public getDataSetLabels(): string[] {
let types: string[] = new Array(this.mDataSets.listSize);
let types : string[] = new Array(this.mDataSets.listSize);
for (let i : number = 0; i < this.mDataSets.listSize; i++) {
for (let i: number = 0; i < this.mDataSets.listSize; i++) {
types[i] = this.mDataSets.get(i).getLabel();
}
@ -319,9 +296,8 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param highlight
* @return the entry that is highlighted
*/
public getEntryForHighlight(highlight : Highlight) : EntryOhos {
if (highlight.getDataSetIndex() >= this.mDataSets.size())
return null;
public getEntryForHighlight(highlight: Highlight): EntryOhos {
if (highlight.getDataSetIndex() >= this.mDataSets.size()) return null;
else {
return this.mDataSets.get(highlight.getDataSetIndex()).getEntryForXValue(highlight.getX(), highlight.getY());
}
@ -336,20 +312,15 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param ignorecase
* @return
*/
public getDataSetByLabel(label : string, ignorecase : boolean) : T {
public getDataSetByLabel(label: string, ignorecase: boolean): T {
let index: number = this.getDataSetIndexByLabel(this.mDataSets, label, ignorecase);
let index : number = this.getDataSetIndexByLabel(this.mDataSets, label, ignorecase);
if (index < 0 || index >= this.mDataSets.size())
return null;
else
return this.mDataSets.get(index);
if (index < 0 || index >= this.mDataSets.size()) return null;
else return this.mDataSets.get(index);
}
public getDataSetByIndex(index : number) : T {
if (this.mDataSets == null || index < 0 || index >= this.mDataSets.size())
return null;
public getDataSetByIndex(index: number): T {
if (this.mDataSets == null || index < 0 || index >= this.mDataSets.size()) return null;
return this.mDataSets.get(index);
}
@ -359,10 +330,8 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param d
*/
public addDataSet(d : T) : void {
if (d == null)
return;
public addDataSet(d: T): void {
if (d == null) return;
this.calcMinMax1(d);
@ -376,12 +345,10 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param d
*/
public removeDataSet(d : T) : boolean{
public removeDataSet(d: T): boolean {
if (d == null) return false;
if (d == null)
return false;
let removed : boolean = this.mDataSets.remove(d);
let removed: boolean = this.mDataSets.remove(d);
// if a DataSet was removed
if (removed) {
@ -398,12 +365,10 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param index
*/
public removeDataSetUnused(index : number) : boolean {
public removeDataSetUnused(index: number): boolean {
if (index >= this.mDataSets.size() || index < 0) return false;
if (index >= this.mDataSets.size() || index < 0)
return false;
let data : T = this.mDataSets.get(index);
let data: T = this.mDataSets.get(index);
return this.removeDataSet(data);
}
@ -414,19 +379,15 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param e
* @param dataSetIndex
*/
public addEntry(e : EntryOhos, dataSetIndex : number) : void {
public addEntry(e: EntryOhos, dataSetIndex: number): void {
if (this.mDataSets.size() > dataSetIndex && dataSetIndex >= 0) {
let data : IDataSet<EntryOhos> = this.mDataSets.get(dataSetIndex);
let data: IDataSet<EntryOhos> = this.mDataSets.get(dataSetIndex);
// add the entry to the dataset
if (!data.addEntry(e))
return;
if (!data.addEntry(e)) return;
this.calcMinMax2(e, data.getAxisDependency());
} else {
console.log("addEntry", "Cannot add Entry because dataSetIndex too high or too low.");
console.log('addEntry', 'Cannot add Entry because dataSetIndex too high or too low.');
}
}
@ -436,29 +397,19 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param e
* @param axis
*/
protected calcMinMax2(e : EntryOhos, axis : AxisDependency) : void {
protected calcMinMax2(e: EntryOhos, axis: AxisDependency): void {
if (this.mYMax < e.getY()) this.mYMax = e.getY();
if (this.mYMin > e.getY()) this.mYMin = e.getY();
if (this.mYMax < e.getY())
this.mYMax = e.getY();
if (this.mYMin > e.getY())
this.mYMin = e.getY();
if (this.mXMax < e.getX())
this.mXMax = e.getX();
if (this.mXMin > e.getX())
this.mXMin = e.getX();
if (this.mXMax < e.getX()) this.mXMax = e.getX();
if (this.mXMin > e.getX()) this.mXMin = e.getX();
if (axis == AxisDependency.LEFT) {
if (this.mLeftAxisMax < e.getY())
this.mLeftAxisMax = e.getY();
if (this.mLeftAxisMin > e.getY())
this.mLeftAxisMin = e.getY();
if (this.mLeftAxisMax < e.getY()) this.mLeftAxisMax = e.getY();
if (this.mLeftAxisMin > e.getY()) this.mLeftAxisMin = e.getY();
} else {
if (this.mRightAxisMax < e.getY())
this.mRightAxisMax = e.getY();
if (this.mRightAxisMin > e.getY())
this.mRightAxisMin = e.getY();
if (this.mRightAxisMax < e.getY()) this.mRightAxisMax = e.getY();
if (this.mRightAxisMin > e.getY()) this.mRightAxisMin = e.getY();
}
}
@ -467,29 +418,19 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param d
*/
protected calcMinMax1(d : T) : void {
protected calcMinMax1(d: T): void {
if (this.mYMax < d.getYMax()) this.mYMax = d.getYMax();
if (this.mYMin > d.getYMin()) this.mYMin = d.getYMin();
if (this.mYMax < d.getYMax())
this.mYMax = d.getYMax();
if (this.mYMin > d.getYMin())
this.mYMin = d.getYMin();
if (this.mXMax < d.getXMax())
this.mXMax = d.getXMax();
if (this.mXMin > d.getXMin())
this.mXMin = d.getXMin();
if (this.mXMax < d.getXMax()) this.mXMax = d.getXMax();
if (this.mXMin > d.getXMin()) this.mXMin = d.getXMin();
if (d.getAxisDependency() == AxisDependency.LEFT) {
if (this.mLeftAxisMax < d.getYMax())
this.mLeftAxisMax = d.getYMax();
if (this.mLeftAxisMin > d.getYMin())
this.mLeftAxisMin = d.getYMin();
if (this.mLeftAxisMax < d.getYMax()) this.mLeftAxisMax = d.getYMax();
if (this.mLeftAxisMin > d.getYMin()) this.mLeftAxisMin = d.getYMin();
} else {
if (this.mRightAxisMax < d.getYMax())
this.mRightAxisMax = d.getYMax();
if (this.mRightAxisMin > d.getYMin())
this.mRightAxisMin = d.getYMin();
if (this.mRightAxisMax < d.getYMax()) this.mRightAxisMax = d.getYMax();
if (this.mRightAxisMin > d.getYMin()) this.mRightAxisMin = d.getYMin();
}
}
@ -499,24 +440,21 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param e
* @param dataSetIndex
*/
public removeEntry(e : EntryOhos, dataSetIndex : number) : boolean {
public removeEntry(e: EntryOhos, dataSetIndex: number): boolean {
// entry null, outofbounds
if (e == null || dataSetIndex >= this.mDataSets.listSize)
return false;
if (e == null || dataSetIndex >= this.mDataSets.listSize) return false;
let data : IDataSet<EntryOhos> = this.mDataSets.get(dataSetIndex);
let data: IDataSet<EntryOhos> = this.mDataSets.get(dataSetIndex);
if (data != null) {
// remove the entry from the dataset
let removed : boolean = data.removeEntry(e);
let removed: boolean = data.removeEntry(e);
if (removed) {
this.notifyDataChanged();
}
return removed;
} else
return false;
} else return false;
}
/**
@ -528,16 +466,13 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param dataSetIndex
* @return
*/
public removeEntryUnused(xValue : number, dataSetIndex : number) : boolean {
public removeEntryUnused(xValue: number, dataSetIndex: number): boolean {
if (dataSetIndex >= this.mDataSets.size()) return false;
if (dataSetIndex >= this.mDataSets.size())
return false;
let dataSet: IDataSet<EntryOhos> = this.mDataSets.get(dataSetIndex);
let e: EntryOhos = dataSet.getEntryForXValue(xValue, Number.NaN);
let dataSet : IDataSet<EntryOhos> = this.mDataSets.get(dataSetIndex);
let e : EntryOhos = dataSet.getEntryForXValue(xValue, Number.NaN);
if (e == null)
return false;
if (e == null) return false;
return this.removeEntry(e, dataSetIndex);
}
@ -549,18 +484,14 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param e
* @return
*/
public getDataSetForEntry(e : EntryOhos) : T {
if (e == null)
return null;
public getDataSetForEntry(e: EntryOhos): T {
if (e == null) return null;
for (let i = 0; i < this.mDataSets.size(); i++) {
let dataSet : T = this.mDataSets.get(i);
let dataSet: T = this.mDataSets.get(i);
for (let j = 0; j < dataSet.getEntryCount(); j++) {
if (e.equalTo(dataSet.getEntryForXValue(e.getX(), e.getY())))
return dataSet;
if (e.equalTo(dataSet.getEntryForXValue(e.getX(), e.getY()))) return dataSet;
}
}
@ -573,25 +504,22 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getColors() : number[] {
public getColors(): number[] {
if (this.mDataSets == null) return null;
if (this.mDataSets == null)
return null;
let clrcnt : number = 0;
let clrcnt: number = 0;
for (let i = 0; i < this.mDataSets.listSize; i++) {
clrcnt += this.mDataSets.get(i).getColors().size();
}
let colors : number[] = new Array(clrcnt);
let cnt : number = 0
let colors: number[] = new Array(clrcnt);
let cnt: number = 0;
for (let i = 0; i < this.mDataSets.size(); i++) {
let clrs: JArrayList<Number> = this.mDataSets.get(i).getColors();
let clrs : JArrayList<Number> = this.mDataSets.get(i).getColors();
for (let j=0; j<clrs.size(); j++) {
for (let j = 0; j < clrs.size(); j++) {
colors[cnt] = clrs.get(j).valueOf();
cnt++;
}
@ -606,7 +534,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param dataSet
* @return
*/
public getIndexOfDataSet(dataSet : T) : number {
public getIndexOfDataSet(dataSet: T): number {
return this.mDataSets.indexOf(dataSet);
}
@ -616,10 +544,9 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
protected getFirstLeft(sets : JArrayList<T>) : T {
protected getFirstLeft(sets: JArrayList<T>): T {
for (let dataSet of sets.dataSouce) {
if (dataSet.getAxisDependency() == AxisDependency.LEFT)
return dataSet;
if (dataSet.getAxisDependency() == AxisDependency.LEFT) return dataSet;
}
return null;
}
@ -630,10 +557,9 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getFirstRight(sets : JArrayList<T>) : T {
public getFirstRight(sets: JArrayList<T>): T {
for (let dataSet of sets.dataSouce) {
if (dataSet.getAxisDependency() == AxisDependency.RIGHT)
return dataSet;
if (dataSet.getAxisDependency() == AxisDependency.RIGHT) return dataSet;
}
return null;
}
@ -643,9 +569,8 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param f
*/
public setValueFormatter(f : IValueFormatter) : void {
if (f == null)
return;
public setValueFormatter(f: IValueFormatter): void {
if (f == null) return;
else {
for (let data of this.mDataSets.dataSouce) {
data.setValueFormatter(f);
@ -659,7 +584,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param color
*/
public setValueTextColor(color : number) : void {
public setValueTextColor(color: number): void {
for (let data of this.mDataSets.dataSouce) {
data.setValueTextColor(color);
}
@ -671,7 +596,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param colors
*/
public setValueTextColors(colors : JArrayList<Number>) : void {
public setValueTextColors(colors: JArrayList<Number>): void {
for (let data of this.mDataSets.dataSouce) {
data.setValueTextColors(colors);
}
@ -683,7 +608,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param tf
*/
public setValueTypeface(tf : FontWeight) : void {
public setValueTypeface(tf: FontWeight): void {
for (let data of this.mDataSets.dataSouce) {
data.setValueTypeface(tf);
}
@ -695,7 +620,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param size
*/
public setValueTextSize(size : number) : void {
public setValueTextSize(size: number): void {
for (let data of this.mDataSets.dataSouce) {
data.setValueTextSize(size);
}
@ -707,7 +632,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @param enabled
*/
public setDrawValues(enabled : boolean) : void {
public setDrawValues(enabled: boolean): void {
for (let data of this.mDataSets.dataSouce) {
data.setDrawValues(enabled);
}
@ -718,7 +643,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* contains. If set to true, this means that values can
* be highlighted programmatically or by touch gesture.
*/
public setHighlightEnabled(enabled : boolean) : void {
public setHighlightEnabled(enabled: boolean): void {
for (let data of this.mDataSets.dataSouce) {
data.setHighlightEnabled(enabled);
}
@ -730,10 +655,9 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public isHighlightEnabled() : boolean {
public isHighlightEnabled(): boolean {
for (let data of this.mDataSets.dataSouce) {
if (!data.isHighlightEnabled())
return false;
if (!data.isHighlightEnabled()) return false;
}
return true;
}
@ -742,7 +666,7 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* Clears this data object from all DataSets and removes all Entries. Don't
* forget to invalidate the chart after this.
*/
clearValues() : void {
clearValues(): void {
if (this.mDataSets != null) {
this.mDataSets.clear();
}
@ -756,11 +680,9 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
* @param dataSet
* @return
*/
public contains(dataSet : T) : boolean {
public contains(dataSet: T): boolean {
for (let data of this.mDataSets.dataSouce) {
if (data == dataSet)
return true;
if (data == dataSet) return true;
}
return false;
@ -771,9 +693,8 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getEntryCount() : number {
let count : number = 0;
public getEntryCount(): number {
let count: number = 0;
for (let data of this.mDataSets.dataSouce) {
count += data.getEntryCount();
@ -787,17 +708,13 @@ export default class ChartData<T extends IDataSet</*T extends*/ EntryOhos>> {
*
* @return
*/
public getMaxEntryCountSet() : T {
public getMaxEntryCountSet(): T {
if (this.mDataSets == null || this.mDataSets.isEmpty()) return null;
if (this.mDataSets == null || this.mDataSets.isEmpty())
return null;
let max : T = this.mDataSets.get(0);
let max: T = this.mDataSets.get(0);
for (let data of this.mDataSets.dataSouce) {
if (data.getEntryCount() > max.getEntryCount())
max = data;
if (data.getEntryCount() > max.getEntryCount()) max = data;
}
return max;

View File

@ -13,9 +13,9 @@
* limitations under the License.
*/
import {JArrayList} from '../utils/JArrayList';
import EntryOhos from './EntryOhos'
import BaseDataSet from './BaseDataSet'
import { JArrayList } from '../utils/JArrayList';
import EntryOhos from './EntryOhos';
import BaseDataSet from './BaseDataSet';
/**
* The DataSet class represents one group or type of entries (Entry) in the
@ -24,33 +24,31 @@ import BaseDataSet from './BaseDataSet'
* LineChart, or the values of a specific group of bars in the BarChart).
*
*/
export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
/**
* the entries that this DataSet represents / holds together
*/
protected mEntries:JArrayList<T>;
protected mEntries: JArrayList<T>;
/**
* maximum y-value in the value array
*/
protected mYMax:number= -Number.MAX_VALUE;
protected mYMax: number = -Number.MAX_VALUE;
/**
* minimum y-value in the value array
*/
protected mYMin:number = Number.MAX_VALUE;
protected mYMin: number = Number.MAX_VALUE;
/**
* maximum x-value in the value array
*/
protected mXMax:number= -Number.MAX_VALUE;
protected mXMax: number = -Number.MAX_VALUE;
/**
* minimum x-value in the value array
*/
protected mXMin:number = Number.MAX_VALUE;
protected mXMin: number = Number.MAX_VALUE;
/**
* Creates a new DataSet object with the given values (entries) it represents. Also, a
@ -60,73 +58,63 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
* @param entries
* @param label
*/
constructor(entries : JArrayList<T>, label : string) {
constructor(entries: JArrayList<T>, label: string) {
super(label);
this.mEntries = entries;
if (!this.mEntries ||this.mEntries== null)
this.mEntries = new JArrayList<T>();
if (!this.mEntries || this.mEntries == null) this.mEntries = new JArrayList<T>();
this.calcMinMax();
}
public calcMinMax():void {
public calcMinMax(): void {
this.mYMax = -Number.MAX_VALUE;
this.mYMin = Number.MAX_VALUE;
this.mXMax = -Number.MAX_VALUE;
this.mXMin = Number.MAX_VALUE;
if (!this.mEntries||this.mEntries == null || this.mEntries.isEmpty())
return;
if (!this.mEntries || this.mEntries == null || this.mEntries.isEmpty()) return;
for (let e of this.mEntries.dataSouce) {
this.myCalcMinMax(e);
}
}
public myCalcMinMax(e ?: T) : void {
if (!e)
return;
public myCalcMinMax(e?: T): void {
if (!e) return;
this.calcMinMaxX(e);
this.myCalcMinMaxY(e);
}
public calcMinMaxY( fromX:number, toX:number):void{
public calcMinMaxY(fromX: number, toX: number): void {
this.mYMax = -Number.MAX_VALUE;
this.mYMin = Number.MAX_VALUE;
if (!this.mEntries||this.mEntries == null || this.mEntries.isEmpty()) {
if (!this.mEntries || this.mEntries == null || this.mEntries.isEmpty()) {
return;
}
var indexFrom : number = this.getEntryIndex(fromX, Number.NaN, Rounding.DOWN);
var indexTo : number = this.getEntryIndex(toX, Number.NaN, Rounding.UP);
var indexFrom: number = this.getEntryIndex(fromX, Number.NaN, Rounding.DOWN);
var indexTo: number = this.getEntryIndex(toX, Number.NaN, Rounding.UP);
if (indexTo < indexFrom) return;
for (var i : number = indexFrom; i <= indexTo; i++) {
for (var i: number = indexFrom; i <= indexTo; i++) {
// only recalculate y
this.myCalcMinMaxY(this.mEntries.get(i));
}
}
protected calcMinMaxX(e: T): void {
if (e.getX() < this.mXMin) this.mXMin = e.getX();
protected calcMinMaxX(e : T) : void {
if (e.getX() < this.mXMin)
this.mXMin = e.getX();
if (e.getX() > this.mXMax)
this.mXMax = e.getX();
if (e.getX() > this.mXMax) this.mXMax = e.getX();
}
protected myCalcMinMaxY(e : T) : void {
if (e.getY() < this.mYMin)
this.mYMin = e.getY();
protected myCalcMinMaxY(e: T): void {
if (e.getY() < this.mYMin) this.mYMin = e.getY();
if (e.getY() > this.mYMax)
this.mYMax = e.getY();
if (e.getY() > this.mYMax) this.mYMax = e.getY();
}
public getEntryCount() : number {
public getEntryCount(): number {
return this.mEntries.size();
}
@ -137,7 +125,7 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
// * @return
// */
// @Deprecated
public getValues() : JArrayList<T> {
public getValues(): JArrayList<T> {
return this.mEntries;
}
@ -146,7 +134,7 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
*
* @return
*/
public getEntries() : JArrayList<T> {
public getEntries(): JArrayList<T> {
return this.mEntries;
}
@ -157,7 +145,7 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
// * @param values
// */
// @Deprecated
public setValues(values : JArrayList<T>) : void {
public setValues(values: JArrayList<T>): void {
this.setEntries(values);
}
@ -166,7 +154,7 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
*
* @return
*/
public setEntries(entries : JArrayList<T>) : void {
public setEntries(entries: JArrayList<T>): void {
this.mEntries = entries;
this.notifyDataSetChanged();
}
@ -179,14 +167,14 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
return null;
}
protected copyTo(dataSet :DataSet<T>) : void {
protected copyTo(dataSet: DataSet<T>): void {
super.copyTo(dataSet);
}
public toString():string {
var str:string=this.toSimpleString()
for (var i : number = 0; i < this.mEntries.size(); i++) {
str+=this.mEntries.get(i).toString() + " "
public toString(): string {
var str: string = this.toSimpleString();
for (var i: number = 0; i < this.mEntries.size(); i++) {
str += this.mEntries.get(i).toString() + ' ';
}
return str;
}
@ -197,31 +185,30 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
*
* @return
*/
public toSimpleString() : string {
var str:string="DataSet, label: " + (!this.getLabel() ? "" : this.getLabel()) + ", entries: " + this.mEntries.size() +"\n";
return str
public toSimpleString(): string {
var str: string =
'DataSet, label: ' + (!this.getLabel() ? '' : this.getLabel()) + ', entries: ' + this.mEntries.size() + '\n';
return str;
}
public getYMin() : number {
public getYMin(): number {
return this.mYMin;
}
public getYMax() : number {
public getYMax(): number {
return this.mYMax;
}
public getXMin() : number {
public getXMin(): number {
return this.mXMin;
}
public getXMax() : number {
public getXMax(): number {
return this.mXMax;
}
public addEntryOrdered(e : T) : void {
if (!e)
return;
public addEntryOrdered(e: T): void {
if (!e) return;
if (!this.mEntries) {
this.mEntries = new JArrayList<T>();
@ -230,23 +217,21 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
this.myCalcMinMax(e);
if (this.mEntries.size() > 0 && this.mEntries.get(this.mEntries.size() - 1).getX() > e.getX()) {
var closestIndex : number = this.getEntryIndex(e.getX(), e.getY(), Rounding.UP);
var closestIndex: number = this.getEntryIndex(e.getX(), e.getY(), Rounding.UP);
} else {
this.mEntries.add(e);
}
}
public clear() : void {
public clear(): void {
this.mEntries.clear();
this.notifyDataSetChanged();
}
public addEntry(e : T) : boolean {
public addEntry(e: T): boolean {
if (!e) return false;
if (!e)
return false;
var values : JArrayList<T> = this.getEntries();
var values: JArrayList<T> = this.getEntries();
if (!values) {
values = new JArrayList<T>();
}
@ -258,15 +243,13 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
return true;
}
public removeEntry(e : T) : boolean {
if (!e)
return false;
public removeEntry(e: T): boolean {
if (!e) return false;
if (!this.mEntries)
return false;
if (!this.mEntries) return false;
// remove the entry
var removed : boolean = this.mEntries.remove(e);
var removed: boolean = this.mEntries.remove(e);
if (removed) {
this.calcMinMax();
@ -275,39 +258,37 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
return removed;
}
public getEntryIndexByEntry(e : T) : number {
public getEntryIndexByEntry(e: T): number {
return this.mEntries.indexOf(e);
}
public getEntryForXValue(xValue : number, closestToY : number, rounding : Rounding) : T {
var myRounding : Rounding
if(rounding==null){
myRounding=Rounding.CLOSEST;
}else{
myRounding=rounding;
public getEntryForXValue(xValue: number, closestToY: number, rounding: Rounding): T {
var myRounding: Rounding;
if (rounding == null) {
myRounding = Rounding.CLOSEST;
} else {
myRounding = rounding;
}
var index : number = this.getEntryIndex(xValue, closestToY, myRounding);
if (index > -1)
return this.mEntries.get(index);
var index: number = this.getEntryIndex(xValue, closestToY, myRounding);
if (index > -1) return this.mEntries.get(index);
}
public getEntryForIndex(index : number):T {
public getEntryForIndex(index: number): T {
return this.mEntries.get(index);
}
public getEntryIndex(xValue : number, closestToY : number, rounding : Rounding) : number {
public getEntryIndex(xValue: number, closestToY: number, rounding: Rounding): number {
if (!this.mEntries || this.mEntries.isEmpty()) return -1;
if (!this.mEntries|| this.mEntries.isEmpty())
return -1;
var low : number = 0;
var high : number = this.mEntries.size() - 1;
var closest : number = high;
var low: number = 0;
var high: number = this.mEntries.size() - 1;
var closest: number = high;
while (low < high) {
var m : number = Math.floor((low + high) / 2);
var d1 : number = this.mEntries.get(m).getX() - xValue;
var d2 : number = this.mEntries.get(m + 1).getX() - xValue;
var ad1 : number = Math.abs(d1), ad2 = Math.abs(d2);
var m: number = Math.floor((low + high) / 2);
var d1: number = this.mEntries.get(m).getX() - xValue;
var d2: number = this.mEntries.get(m + 1).getX() - xValue;
var ad1: number = Math.abs(d1),
ad2 = Math.abs(d2);
if (ad2 < ad1) {
// [m + 1] is closer to xValue
@ -331,7 +312,7 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
}
if (closest != -1) {
var closestXValue : number = this.mEntries.get(closest).getX();
var closestXValue: number = this.mEntries.get(closest).getX();
if (rounding == Rounding.UP) {
// If rounding up, and found x-value is lower than specified x, and we can go upper...
if (closestXValue < xValue && closest < this.mEntries.size() - 1) {
@ -345,21 +326,18 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
}
// Search by closest to y-value
if (!Number.isNaN(closestToY)) {
while (closest > 0 && this.mEntries.get(closest - 1).getX() == closestXValue)
closest -= 1;
while (closest > 0 && this.mEntries.get(closest - 1).getX() == closestXValue) closest -= 1;
var closestYValue : number = this.mEntries.get(closest).getY();
var closestYIndex : number = closest;
var closestYValue: number = this.mEntries.get(closest).getY();
var closestYIndex: number = closest;
while (true) {
closest += 1;
if (closest >= this.mEntries.size())
break;
if (closest >= this.mEntries.size()) break;
var value : EntryOhos = this.mEntries.get(closest);
var value: EntryOhos = this.mEntries.get(closest);
if (value.getX() != closestXValue)
break;
if (value.getX() != closestXValue) break;
if (Math.abs(value.getY() - closestToY) <= Math.abs(closestYValue - closestToY)) {
closestYValue = closestToY;
@ -372,19 +350,17 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
return closest;
}
public getEntriesForXValue(xValue : number) : JArrayList<T> {
var entries : JArrayList<T> = new JArrayList<T>();
var low : number = 0;
var high : number = this.mEntries.size() - 1;
public getEntriesForXValue(xValue: number): JArrayList<T> {
var entries: JArrayList<T> = new JArrayList<T>();
var low: number = 0;
var high: number = this.mEntries.size() - 1;
while (low <= high) {
var m : number = (high + low) / 2;
var entry:T = this.mEntries.get(m);
var m: number = (high + low) / 2;
var entry: T = this.mEntries.get(m);
// if we have a match
if (xValue == entry.getX()) {
while (m > 0 && this.mEntries.get(m - 1).getX() == xValue)
m--;
while (m > 0 && this.mEntries.get(m - 1).getX() == xValue) m--;
high = this.mEntries.size();
@ -400,10 +376,8 @@ export abstract class DataSet<T extends EntryOhos> extends BaseDataSet<T> {
break;
} else {
if (xValue > entry.getX())
low = m + 1;
else
high = m - 1;
if (xValue > entry.getX()) low = m + 1;
else high = m - 1;
}
}

View File

@ -17,46 +17,44 @@ import Utils from '../utils/Utils';
import { ImagePaint } from './Paint';
import BaseEntry from './BaseEntry';
/**
* Class representing one entry in the chart. Might contain multiple values.
* Might only contain a single value depending on the used constructor.
*
*
*/
export default class EntryOhos extends BaseEntry{
export default class EntryOhos extends BaseEntry {
private x: number = 0;
private x:number = 0;
constructor(x?:number, y?:number,icon?:ImagePaint,data?:Object) {
constructor(x?: number, y?: number, icon?: ImagePaint, data?: Object) {
super(y, icon, data);
this.x = x;
}
/**
* Returns the x-value of this Entry object.
*
*
* @return
*/
public getX():number{
public getX(): number {
return this.x;
}
/**
* Sets the x-value of this Entry object.
*
*
* @param x
*/
public setX(x:number):void {
public setX(x: number): void {
this.x = x;
}
/**
* returns an exact copy of the entry
*
*
* @return
*/
public copy():EntryOhos{
var e:EntryOhos= new EntryOhos(this.x, this.getY(),null, this.getData());
public copy(): EntryOhos {
var e: EntryOhos = new EntryOhos(this.x, this.getY(), null, this.getData());
return e;
}
@ -64,23 +62,18 @@ export default class EntryOhos extends BaseEntry{
* Compares value, xIndex and data of the entries. Returns true if entries
* are equal in those points, false if not. Does not check by hash-code like
* it's done by the "equals" method.
*
*
* @param e
* @return
*/
public equalTo( e:EntryOhos):boolean{
public equalTo(e: EntryOhos): boolean {
if (!e) return false;
if (!e)
return false;
if (e.getData() != this.getData()) return false;
if (e.getData() != this.getData())
return false;
if (Math.abs(e.x - this.x) > Utils.FLOAT_EPSILON) return false;
if (Math.abs(e.x - this.x) > Utils.FLOAT_EPSILON)
return false;
if (Math.abs(e.getY() - this.getY()) > Utils.FLOAT_EPSILON)
return false;
if (Math.abs(e.getY() - this.getY()) > Utils.FLOAT_EPSILON) return false;
return true;
}
@ -88,11 +81,11 @@ export default class EntryOhos extends BaseEntry{
/**
* returns a string representation of the entry containing x-index and value
*/
public toString():String {
return "Entry, x: " + this.x + " y: " + this.getY();
public toString(): String {
return 'Entry, x: ' + this.x + ' y: ' + this.getY();
}
public describeContents():number {
public describeContents(): number {
return 0;
}
}

View File

@ -14,16 +14,15 @@
*/
import ILineDataSet from '../interfaces/datasets/ILineDataSet';
import {JArrayList} from '../utils/JArrayList';
import { JArrayList } from '../utils/JArrayList';
import BarLineScatterCandleBubbleData from './BarLineScatterCandleBubbleData';
/**
* Data object that encapsulates all data associated with a LineChart.
*
*
*/
export default class LineData extends BarLineScatterCandleBubbleData<ILineDataSet> {
public constructor(dataSets ?: JArrayList<ILineDataSet>) {
public constructor(dataSets?: JArrayList<ILineDataSet>) {
super(dataSets);
}
}

View File

@ -15,15 +15,14 @@
import { DashPathEffect } from './Paint';
import { DataSet } from './DataSet';
import LineRadarDataSet from './LineRadarDataSet'
import EntryOhos from './EntryOhos'
import ILineDataSet from '../interfaces/datasets/ILineDataSet'
import IFillFormatter from '../formatter/IFillFormatter'
import DefaultFillFormatter from '../formatter/DefaultFillFormatter'
import Utils from '../utils/Utils'
import {JArrayList} from '../utils/JArrayList'
import ColorTemplate from '../utils/ColorTemplate'
import LineRadarDataSet from './LineRadarDataSet';
import EntryOhos from './EntryOhos';
import ILineDataSet from '../interfaces/datasets/ILineDataSet';
import IFillFormatter from '../formatter/IFillFormatter';
import DefaultFillFormatter from '../formatter/DefaultFillFormatter';
import Utils from '../utils/Utils';
import { JArrayList } from '../utils/JArrayList';
import ColorTemplate from '../utils/ColorTemplate';
export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDataSet {
/**
@ -63,7 +62,7 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
/**
* the path effect of this DataSet that makes dashed lines possible
*/
private mDashPathEffect: DashPathEffect = null;
private mDashPathEffect: DashPathEffect = null;
/**
* formatter for customizing the position of the fill-line
@ -83,13 +82,12 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
}
this.mCircleColors.clear();
this.mCircleColors.add(0x8ceaff);
}
public copy(): DataSet<EntryOhos> {
let entries = new JArrayList<EntryOhos>();
for (let i = 0; i < this.mEntries.size(); i++) {
entries.add(this.mEntries.get(i).copy());
entries.add(this.mEntries.get(i).copy());
}
let copied = new LineDataSet(entries, this.getLabel());
this.copyTo(copied);
@ -124,7 +122,7 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
*
* @return
*/
public setMode(mode: Mode): void {
public setMode(mode: Mode): void {
this.mMode = mode;
}
@ -135,11 +133,8 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
* @param intensity
*/
public setCubicIntensity(intensity: number): void {
if (intensity > 1)
intensity = 1;
if (intensity < 0.05)
intensity = 0.05;
;
if (intensity > 1) intensity = 1;
if (intensity < 0.05) intensity = 0.05;
this.mCubicIntensity = intensity;
}
@ -153,12 +148,11 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
*
* @param radius
*/
public setCircleRadius(radius: number): void {
public setCircleRadius(radius: number): void {
if (radius >= 1) {
this.mCircleRadius = radius;
} else {
console.log("LineDataSet", "Circle radius cannot be < 1")
console.log('LineDataSet', 'Circle radius cannot be < 1');
}
}
@ -172,12 +166,11 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
*
* @param holeRadius
*/
public setCircleHoleRadius(holeRadius: number): void{
public setCircleHoleRadius(holeRadius: number): void {
if (holeRadius >= 0.5) {
this.mCircleHoleRadius = holeRadius;
} else {
console.log("LineDataSet", "Circle radius cannot be < 0.5")
console.log('LineDataSet', 'Circle radius cannot be < 0.5');
}
}
@ -231,16 +224,16 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
*
* @param enabled
*/
public setDrawCircles(enabled: boolean): void {
public setDrawCircles(enabled: boolean): void {
this.mDrawCircles = enabled;
}
public isDrawCirclesEnabled(): boolean {
public isDrawCirclesEnabled(): boolean {
return this.mDrawCircles;
}
// @Deprecated
public isDrawCubicEnabled(): boolean {
public isDrawCubicEnabled(): boolean {
return this.mMode == Mode.CUBIC_BEZIER;
}
@ -268,16 +261,15 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
return this.mCircleColors.length();
}
public setCircleColorsByArray(colors: JArrayList<number>): void{
public setCircleColorsByArray(colors: JArrayList<number>): void {
this.mCircleColors = colors;
}
public setCircleColors(colors:number[]):void {
public setCircleColors(colors: number[]): void {
this.mCircleColors = ColorTemplate.createColors(colors);
}
public setCircleColorsByArrayAndCon(colors: number[]): void {
public setCircleColorsByArrayAndCon(colors: number[]): void {
var clrs: JArrayList<Number> = this.mCircleColors;
if (clrs == null) {
clrs = new JArrayList();
@ -295,20 +287,20 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
*
* @param color
*/
public setCircleColor(color: number): void {
public setCircleColor(color: number): void {
this.resetCircleColors();
this.mCircleColor = color;
this.mCircleColors.add(color);
}
public getCircleColor(): number {
public getCircleColor(): number {
return this.mCircleColor;
}
/**
* resets the circle-colors array and creates a new one
*/
public resetCircleColors(): void {
public resetCircleColors(): void {
if (this.mCircleColors == null) {
this.mCircleColors = new JArrayList<Number>();
}
@ -320,7 +312,7 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
*
* @param color
*/
public setCircleHoleColor(color: number): void {
public setCircleHoleColor(color: number): void {
this.mCircleHoleColor = color;
}
@ -333,11 +325,11 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
*
* @param enabled
*/
public setDrawCircleHole(enabled: boolean): void {
public setDrawCircleHole(enabled: boolean): void {
this.mDrawCircleHole = enabled;
}
public isDrawCircleHoleEnabled(): boolean {
public isDrawCircleHoleEnabled(): boolean {
return this.mDrawCircleHole;
}
@ -347,25 +339,23 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
*
* @param formatter
*/
public setFillFormatter(formatter: IFillFormatter): void {
public setFillFormatter(formatter: IFillFormatter): void {
if (!formatter) {
this.mFillFormatter = new DefaultFillFormatter();
} else {
if (formatter instanceof DefaultFillFormatter) {
this.mFillFormatter = <DefaultFillFormatter> formatter;
this.mFillFormatter = <DefaultFillFormatter>formatter;
}
}
}
public getFillFormatter(): IFillFormatter {
public getFillFormatter(): IFillFormatter {
return this.mFillFormatter;
}
getDashPathEffectHighlight():DashPathEffect{
return
getDashPathEffectHighlight(): DashPathEffect {
return;
}
public setFillStyle(fillStyle: FillStyle) {
this.fillStyle = fillStyle;
}
@ -375,17 +365,16 @@ export class LineDataSet extends LineRadarDataSet<EntryOhos> implements ILineDat
}
}
export type ColorStop = [Color | string | number,number];
export type ColorStop = [Color | string | number, number];
export enum Mode {
LINEAR,
STEPPED,
CUBIC_BEZIER,
HORIZONTAL_BEZIER
HORIZONTAL_BEZIER,
}
export enum FillStyle {
MIN,
MAX
MAX,
}

View File

@ -14,29 +14,31 @@
*/
import { ColorStop } from '../data/LineDataSet';
import EntryOhos from './EntryOhos'
import LineScatterCandleRadarDataSet from './LineScatterCandleRadarDataSet'
import ILineRadarDataSet from '../interfaces/datasets/ILineRadarDataSet'
import {JArrayList} from '../utils/JArrayList'
import Utils from '../utils/Utils'
import EntryOhos from './EntryOhos';
import LineScatterCandleRadarDataSet from './LineScatterCandleRadarDataSet';
import ILineRadarDataSet from '../interfaces/datasets/ILineRadarDataSet';
import { JArrayList } from '../utils/JArrayList';
import Utils from '../utils/Utils';
/**
* Base dataset for line and radar DataSets.
*/
export default abstract class LineRadarDataSet <T extends EntryOhos> extends LineScatterCandleRadarDataSet<T> implements ILineRadarDataSet<T> {
// TODO: Move to using `Fill` class
export default abstract class LineRadarDataSet<T extends EntryOhos>
extends LineScatterCandleRadarDataSet<T>
implements ILineRadarDataSet<T>
{
// TODO: Move to using `Fill` class
/**
* the color that is used for filling the line surface
*/
// private mFillColor: number = Color.rgb(140, 234, 255);
private mFillColor: number = 0x8CEAFF;
// private mFillColor: number = Color.rgb(140, 234, 255);
private mFillColor: number = 0x8ceaff;
private mLinearGradientColors: Array<ColorStop>;
/**
* the drawable to be used for filling the line surface
*/
protected mFillDrawable:Object/*Drawable*/;
protected mFillDrawable: Object /*Drawable*/;
/**
* transparency used for filling line surface
@ -57,7 +59,7 @@ export default abstract class LineRadarDataSet <T extends EntryOhos> extends Lin
super(yVals, label);
}
public getFillColor(): number{
public getFillColor(): number {
return this.mFillColor;
}
@ -82,7 +84,7 @@ export default abstract class LineRadarDataSet <T extends EntryOhos> extends Lin
return this.mLinearGradientColors;
}
public getFillDrawable():Object/*Drawable*/ {
public getFillDrawable(): Object /*Drawable*/ {
return this.mFillDrawable;
}
@ -91,12 +93,12 @@ export default abstract class LineRadarDataSet <T extends EntryOhos> extends Lin
*
* @param drawable
*/
// @TargetApi(18)
public setFillDrawable(drawable:Object/*Drawable*/): void {
// @TargetApi(18)
public setFillDrawable(drawable: Object /*Drawable*/): void {
this.mFillDrawable = drawable;
}
public getFillAlpha(): number{
public getFillAlpha(): number {
return this.mFillAlpha;
}
@ -106,7 +108,7 @@ export default abstract class LineRadarDataSet <T extends EntryOhos> extends Lin
*
* @param alpha
*/
public setFillAlpha(alpha:number):void {
public setFillAlpha(alpha: number): void {
this.mFillAlpha = alpha;
}
@ -116,28 +118,25 @@ export default abstract class LineRadarDataSet <T extends EntryOhos> extends Lin
*
* @param width
*/
public setLineWidth(width:number):void {
if (width < 0.0)
width = 0.0;
if (width > 10.0)
width = 10.0;
public setLineWidth(width: number): void {
if (width < 0.0) width = 0.0;
if (width > 10.0) width = 10.0;
this.mLineWidth = width;
}
public getLineWidth():number {
public getLineWidth(): number {
return this.mLineWidth;
}
public setDrawFilled(filled:boolean):void {
public setDrawFilled(filled: boolean): void {
this.mDrawFilled = filled;
}
public isDrawFilledEnabled():boolean {
public isDrawFilledEnabled(): boolean {
return this.mDrawFilled;
}
protected copyTo(lineRadarDataSet:LineRadarDataSet<T>): void {
protected copyTo(lineRadarDataSet: LineRadarDataSet<T>): void {
super.copyTo(lineRadarDataSet);
lineRadarDataSet.mDrawFilled = this.mDrawFilled;
lineRadarDataSet.mFillAlpha = this.mFillAlpha;

View File

@ -14,13 +14,16 @@
*/
import { DashPathEffect } from './Paint';
import EntryOhos from './EntryOhos'
import BarLineScatterCandleBubbleDataSet from './BarLineScatterCandleBubbleDataSet'
import ILineScatterCandleRadarDataSet from '../interfaces/datasets/ILineScatterCandleRadarDataSet'
import Utils from '../utils/Utils'
import {JArrayList} from '../utils/JArrayList'
import EntryOhos from './EntryOhos';
import BarLineScatterCandleBubbleDataSet from './BarLineScatterCandleBubbleDataSet';
import ILineScatterCandleRadarDataSet from '../interfaces/datasets/ILineScatterCandleRadarDataSet';
import Utils from '../utils/Utils';
import { JArrayList } from '../utils/JArrayList';
export default abstract class LineScatterCandleRadarDataSet <T extends EntryOhos> extends BarLineScatterCandleBubbleDataSet<T> implements ILineScatterCandleRadarDataSet<T> {
export default abstract class LineScatterCandleRadarDataSet<T extends EntryOhos>
extends BarLineScatterCandleBubbleDataSet<T>
implements ILineScatterCandleRadarDataSet<T>
{
protected mDrawVerticalHighlightIndicator: boolean = true;
protected mDrawHorizontalHighlightIndicator: boolean = true;
@ -28,7 +31,7 @@ export default abstract class LineScatterCandleRadarDataSet <T extends EntryOhos
protected mHighlightLineWidth: number = 0.5;
/** the path effect for dashed highlight-lines */
protected mHighlightDashPathEffect:DashPathEffect = null;
protected mHighlightDashPathEffect: DashPathEffect = null;
constructor(yVals: JArrayList<T>, label: string) {
super(yVals, label);
@ -47,7 +50,7 @@ export default abstract class LineScatterCandleRadarDataSet <T extends EntryOhos
* Enables / disables the vertical highlight-indicator. If disabled, the indicator is not drawn.
* @param enabled
*/
public setDrawVerticalHighlightIndicator(enabled: boolean): void {
public setDrawVerticalHighlightIndicator(enabled: boolean): void {
this.mDrawVerticalHighlightIndicator = enabled;
}
@ -55,7 +58,7 @@ export default abstract class LineScatterCandleRadarDataSet <T extends EntryOhos
* Enables / disables both vertical and horizontal highlight-indicators.
* @param enabled
*/
public setDrawHighlightIndicators(enabled: boolean): void {
public setDrawHighlightIndicators(enabled: boolean): void {
this.setDrawVerticalHighlightIndicator(enabled);
this.setDrawHorizontalHighlightIndicator(enabled);
}
@ -72,11 +75,11 @@ export default abstract class LineScatterCandleRadarDataSet <T extends EntryOhos
* Sets the width of the highlight line in dp.
* @param width
*/
public setHighlightLineWidth(width: number): void {
public setHighlightLineWidth(width: number): void {
this.mHighlightLineWidth = Utils.convertDpToPixel(width);
}
public getHighlightLineWidth(): number{
public getHighlightLineWidth(): number {
return this.mHighlightLineWidth;
}
@ -87,10 +90,9 @@ export default abstract class LineScatterCandleRadarDataSet <T extends EntryOhos
* @param spaceLength the length of space inbetween the line-pieces
* @param phase offset, in degrees (normally, use 0)
*/
public enableDashedHighlightLine(lineLength: number, spaceLength: number, phase: number): void {
var arr=[lineLength, spaceLength];
this.mHighlightDashPathEffect = new DashPathEffect(arr,
phase);
public enableDashedHighlightLine(lineLength: number, spaceLength: number, phase: number): void {
var arr = [lineLength, spaceLength];
this.mHighlightDashPathEffect = new DashPathEffect(arr, phase);
}
/**
@ -105,15 +107,15 @@ export default abstract class LineScatterCandleRadarDataSet <T extends EntryOhos
* Default: disabled
* @return
*/
public isDashedHighlightLineEnabled(): boolean {
return !this.mHighlightDashPathEffect? false : true;
public isDashedHighlightLineEnabled(): boolean {
return !this.mHighlightDashPathEffect ? false : true;
}
public getDashPathEffectHighlight():DashPathEffect /*DashPathEffect*/ {
public getDashPathEffectHighlight(): DashPathEffect /*DashPathEffect*/ {
return this.mHighlightDashPathEffect;
}
protected copyTo(lineScatterCandleRadarDataSet: LineScatterCandleRadarDataSet<T>): void {
protected copyTo(lineScatterCandleRadarDataSet: LineScatterCandleRadarDataSet<T>): void {
super.copyTo(lineScatterCandleRadarDataSet);
lineScatterCandleRadarDataSet.mDrawHorizontalHighlightIndicator = this.mDrawHorizontalHighlightIndicator;
lineScatterCandleRadarDataSet.mDrawVerticalHighlightIndicator = this.mDrawVerticalHighlightIndicator;

View File

@ -33,21 +33,21 @@ export default class Paint {
typeface: FontWeight = FontWeight.Normal;
textAlign: TextAlign = TextAlign.Start;
align: Align = Align.LEFT;
strokeDashArray: number[] = [0,0];
strokeDashArray: number[] = [0, 0];
strokeDashOffset: number = 0;
dashPathEffect: DashPathEffect;
x: number = 0;
y: number = 0;
width: number | string = null;
height: number | string = null;
visibility: Visibility = Visibility.Visible
visibility: Visibility = Visibility.Visible;
clickPosition = -1;
value = 0;
translateX = 0;
translateY = 0;
constructor(paint?:Paint){
if(paint != null && paint != undefined){
constructor(paint?: Paint) {
if (paint != null && paint != undefined) {
this.color = paint.color;
this.textSize = paint.textSize;
this.fill = paint.fill;
@ -71,7 +71,7 @@ export default class Paint {
}
}
public set(paint:Paint){
public set(paint: Paint) {
this.color = paint.color;
this.textSize = paint.textSize;
this.fill = paint.fill;
@ -95,60 +95,60 @@ export default class Paint {
}
setColor(value: Color | number | string | Resource) {
this.color = value
switch(this.style){
this.color = value;
switch (this.style) {
case Style.STROKE:
this.setStroke(value)
this.setStroke(value);
break;
case Style.FILL:
this.setFill(value)
this.setFill(value);
break;
case Style.FILL_AND_STROKE:
this.setStroke(value)
this.setFill(value)
this.setStroke(value);
this.setFill(value);
break;
}
}
getColor(): Color | number | string | Resource{
getColor(): Color | number | string | Resource {
return this.color;
}
setTextSize(value: number) {
this.textSize = value
this.textSize = value;
}
getTextSize(): number{
getTextSize(): number {
return this.textSize;
}
setFill(value: Color | number | string | Resource){
this.fill = value
setFill(value: Color | number | string | Resource) {
this.fill = value;
}
setStroke(value: Color | number | string | Resource){
this.stroke = value
setStroke(value: Color | number | string | Resource) {
this.stroke = value;
}
setStrokeWidth(value: number) {
this.strokeWidth = value
this.strokeWidth = value;
}
getStrokeWidth(): number{
getStrokeWidth(): number {
return this.strokeWidth;
}
setStrokeRadius(value: number){
setStrokeRadius(value: number) {
this.strokeRadius = value;
}
getStrokeRadius(): number{
getStrokeRadius(): number {
return this.strokeRadius;
}
setStyle(value: Style) {
this.style = value
switch(value){
this.style = value;
switch (value) {
case Style.STROKE:
this.setStroke(this.color);
break;
@ -162,110 +162,109 @@ export default class Paint {
}
}
getStyle(): Style{
return this.style
getStyle(): Style {
return this.style;
}
setAlpha(value: number) {
this.alpha = value
this.alpha = value;
}
getAlpha(): number{
getAlpha(): number {
return this.alpha;
}
setTypeface(value: FontWeight) {
this.typeface = value
this.typeface = value;
}
getTypeface(): number{
getTypeface(): number {
return this.typeface;
}
setTextAlign(value: TextAlign) {
this.textAlign = value
this.textAlign = value;
}
getTextAlign(): TextAlign{
getTextAlign(): TextAlign {
return this.textAlign;
}
setAlign(value: Align) {
this.align = value
this.align = value;
}
getAlign(): Align{
getAlign(): Align {
return this.align;
}
setStrokeDashArray(value: number[]) {
this.strokeDashArray = value
this.strokeDashArray = value;
}
getStrokeDashArray(): number[]{
return this.strokeDashArray
getStrokeDashArray(): number[] {
return this.strokeDashArray;
}
setStrokeDashOffset(value: number) {
this.strokeDashOffset = value
this.strokeDashOffset = value;
}
getStrokeDashOffset(): number{
return this.strokeDashOffset
getStrokeDashOffset(): number {
return this.strokeDashOffset;
}
setDashPathEffect(value: DashPathEffect) {
this.dashPathEffect = value;
if(this.dashPathEffect != null){
this.setStrokeDashArray(this.dashPathEffect.dash)
this.setStrokeDashOffset(this.dashPathEffect.offset)
if (this.dashPathEffect != null) {
this.setStrokeDashArray(this.dashPathEffect.dash);
this.setStrokeDashOffset(this.dashPathEffect.offset);
}
}
getDashPathEffect(): DashPathEffect{
getDashPathEffect(): DashPathEffect {
return this.dashPathEffect;
}
setX(value: number) {
this.x = value
this.x = value;
}
getX(): number{
return this.x
getX(): number {
return this.x;
}
setY(value: number) {
this.y = value
this.y = value;
}
getY(): number{
return this.y
getY(): number {
return this.y;
}
setWidth(value: number | string) {
this.width = value;
}
getWidth(): number | string{
return this.width
getWidth(): number | string {
return this.width;
}
setHeight(value: number | string) {
this.height = value
this.height = value;
}
getHeight(): number | string{
return this.height
getHeight(): number | string {
return this.height;
}
setVisibility(visibility: Visibility){
setVisibility(visibility: Visibility) {
this.visibility = visibility;
}
setClickPosition(position: number){
setClickPosition(position: number) {
this.clickPosition = position;
}
}
/**
@ -273,38 +272,38 @@ export default class Paint {
*/
export class LinePaint extends Paint {
startPoint: number[] = [0, 0];
endPoint: number[] = [0, 0]
endPoint: number[] = [0, 0];
constructor(paint?:LinePaint){
super(paint)
if(paint != null && paint != undefined){
constructor(paint?: LinePaint) {
super(paint);
if (paint != null && paint != undefined) {
this.startPoint = paint.startPoint;
this.endPoint = paint.endPoint;
}
}
setStartPoint(value: number[]) {
this.startPoint = value
this.startPoint = value;
}
getStartPoint(): number[]{
return this.startPoint
getStartPoint(): number[] {
return this.startPoint;
}
setEndPoint(value: number[]) {
this.endPoint = value
this.endPoint = value;
}
getEndPoint(): number[]{
return this.endPoint
getEndPoint(): number[] {
return this.endPoint;
}
}
export class TextPaint extends Paint {
text: string = "";
constructor(paint?:TextPaint){
super(paint)
if(paint != null && paint != undefined){
text: string = '';
constructor(paint?: TextPaint) {
super(paint);
if (paint != null && paint != undefined) {
this.text = paint.text;
}
}
@ -312,214 +311,213 @@ export class TextPaint extends Paint {
translateY: number = 0;
rotate: number = 0;
setText(value: string) {
this.text = value
this.text = value;
}
getText(): string{
return this.text
getText(): string {
return this.text;
}
setTranslateX(value: number) {
this.translateX = value
this.translateX = value;
}
getTranslateX(): number{
return this.translateX
getTranslateX(): number {
return this.translateX;
}
setTranslateY(value: number) {
this.translateY = value
this.translateY = value;
}
getTranslateY(): number{
return this.translateY
getTranslateY(): number {
return this.translateY;
}
setRotate(value: number) {
this.rotate = value
this.rotate = value;
}
getRotate(): number{
return this.rotate
getRotate(): number {
return this.rotate;
}
}
export class PathPaint extends Paint {
commands: string = "";
commandsFill: string = "";
commands: string = '';
commandsFill: string = '';
filled: boolean = false;
linearGradientColors: Array<ColorStop> = null;
enabled: boolean = false;
circleColor: string | number | Color = Color.White;
colors:JArrayList<Number> = null;
colors: JArrayList<Number> = null;
radius: number = 2;
circleHoleRadius: number = 1;
circleHoleColor: string | number | Color = Color.White;
circleHoleEnabled: boolean = true;
drawValueEnable: boolean = true;
rotate:number
rotateText:number
percentage:string = ''
filledColor:number = 0
label:string = ''
axisDependency:AxisDependency = AxisDependency.LEFT
lineSvg:string = ''
rotate: number;
rotateText: number;
percentage: string = '';
filledColor: number = 0;
label: string = '';
axisDependency: AxisDependency = AxisDependency.LEFT;
lineSvg: string = '';
fillStyle: FillStyle = FillStyle.MIN;
positionX:number
positionY:number
labelX:number
labelY:number
iconX:number = 0
iconY:number = 0
positionX: number;
positionY: number;
labelX: number;
labelY: number;
iconX: number = 0;
iconY: number = 0;
constructor(paint?:PathPaint){
super(paint)
if(paint != null && paint != undefined){
constructor(paint?: PathPaint) {
super(paint);
if (paint != null && paint != undefined) {
this.commands = paint.commands;
}
}
setIconY(iconY:number){
this.iconY = iconY
setIconY(iconY: number) {
this.iconY = iconY;
}
setIconX(iconX:number){
this.iconX = iconX
setIconX(iconX: number) {
this.iconX = iconX;
}
setLabelX(labelX:number){
this.labelX = labelX
setLabelX(labelX: number) {
this.labelX = labelX;
}
setLabelY(labelY:number){
this.labelY = labelY
setLabelY(labelY: number) {
this.labelY = labelY;
}
setPositionX(positionX:number){
this.positionX = positionX
setPositionX(positionX: number) {
this.positionX = positionX;
}
setPositionY(positionY:number){
this.positionY = positionY
setPositionY(positionY: number) {
this.positionY = positionY;
}
setLineSvg(lineSvg:string){
this.lineSvg = lineSvg
setLineSvg(lineSvg: string) {
this.lineSvg = lineSvg;
}
setLabel(label:string){
this.label = label
setLabel(label: string) {
this.label = label;
}
getLabel():string{
return this.label
getLabel(): string {
return this.label;
}
setFilledColor(filledColor:number){
this.filledColor = filledColor
setFilledColor(filledColor: number) {
this.filledColor = filledColor;
}
getFilledColor():number{
return this.filledColor
getFilledColor(): number {
return this.filledColor;
}
setRotateText(rotateText: number){
setRotateText(rotateText: number) {
this.rotateText = rotateText;
}
getRotateText():number{
return this.rotateText
getRotateText(): number {
return this.rotateText;
}
setPercentage(percentage:string){
this.percentage = percentage
setPercentage(percentage: string) {
this.percentage = percentage;
}
getPercentage():string{
return this.percentage
getPercentage(): string {
return this.percentage;
}
setRotate(value:number){
this.rotate = value
setRotate(value: number) {
this.rotate = value;
}
setCommands(value: string){
setCommands(value: string) {
this.commands = value;
}
setCommandsFill(commandsFill: string){
setCommandsFill(commandsFill: string) {
this.commandsFill = commandsFill;
}
public setFillStyle(fillStyle: FillStyle){
public setFillStyle(fillStyle: FillStyle) {
this.fillStyle = fillStyle;
}
setDrawFilled(filled:boolean){
this.filled = filled
setDrawFilled(filled: boolean) {
this.filled = filled;
}
isDrawFilledEnabled(): boolean{
return this.filled
isDrawFilledEnabled(): boolean {
return this.filled;
}
setGradientFillColor(linearGradientColors: Array<ColorStop>): void{
setGradientFillColor(linearGradientColors: Array<ColorStop>): void {
this.linearGradientColors = linearGradientColors;
}
setColors(colors: JArrayList<Number>){
this.colors = colors
setColors(colors: JArrayList<Number>) {
this.colors = colors;
}
setDrawCircles(enabled: boolean){
this.enabled = enabled
setDrawCircles(enabled: boolean) {
this.enabled = enabled;
}
isDrawCirclesEnabled(): boolean{
return this.enabled
isDrawCirclesEnabled(): boolean {
return this.enabled;
}
setCirclesColor(circleColor: string | number | Color){
setCirclesColor(circleColor: string | number | Color) {
this.circleColor = circleColor;
}
setCircleRadius(radius: number){
setCircleRadius(radius: number) {
this.radius = radius;
}
setCircleHoleRadius(circleHoleRadius: number){
setCircleHoleRadius(circleHoleRadius: number) {
this.circleHoleRadius = circleHoleRadius;
}
setCircleHoleColor(circleHoleColor: string | number | Color){
setCircleHoleColor(circleHoleColor: string | number | Color) {
this.circleHoleColor = circleHoleColor;
}
setDrawCircleHole(circleHoleEnabled: boolean){
setDrawCircleHole(circleHoleEnabled: boolean) {
this.circleHoleEnabled = circleHoleEnabled;
}
setDrawValueEnable(drawValueEnable: boolean){
setDrawValueEnable(drawValueEnable: boolean) {
this.drawValueEnable = drawValueEnable;
}
setAxisDependency(axisDependency:AxisDependency){
setAxisDependency(axisDependency: AxisDependency) {
this.axisDependency = axisDependency;
}
}
export class PathFillPaint extends Paint {
commandsFill: string = "";
commandsFill: string = '';
filled: boolean = false;
linearGradientColors: Array<ColorStop> = null;
constructor(paint?:PathFillPaint){
super(paint)
constructor(paint?: PathFillPaint) {
super(paint);
}
setCommandsFill(commandsFill: string){
setCommandsFill(commandsFill: string) {
this.commandsFill = commandsFill;
}
setDrawFilled(filled:boolean){
this.filled = filled
setDrawFilled(filled: boolean) {
this.filled = filled;
}
isDrawFilledEnabled(): boolean{
return this.filled
isDrawFilledEnabled(): boolean {
return this.filled;
}
setGradientFillColor(linearGradientColors: Array<ColorStop>): void{
setGradientFillColor(linearGradientColors: Array<ColorStop>): void {
this.linearGradientColors = linearGradientColors;
}
}
@ -527,186 +525,180 @@ export class PathFillPaint extends Paint {
export enum Style {
FILL,
STROKE,
FILL_AND_STROKE
FILL_AND_STROKE,
}
/**
* 用于绘制Legend的属性类
*/
export class RectPaint extends Paint {
startPoint: number[] = [0, 0]
linearGradientColors: Array<ColorStop>
startPoint: number[] = [0, 0];
linearGradientColors: Array<ColorStop>;
constructor(paint?:RectPaint){
super(paint)
if(paint != null && paint != undefined){
constructor(paint?: RectPaint) {
super(paint);
if (paint != null && paint != undefined) {
this.startPoint = paint.startPoint;
}
}
setStartPoint(value: number[]) {
this.x = value[0]
this.y = value[1]
this.startPoint = value
this.x = value[0];
this.y = value[1];
this.startPoint = value;
}
getStartPoint(): number[]{
return this.startPoint
getStartPoint(): number[] {
return this.startPoint;
}
setGradientFillColor(linearGradientColors: Array<ColorStop>): void{
setGradientFillColor(linearGradientColors: Array<ColorStop>): void {
this.linearGradientColors = linearGradientColors;
}
}
export class BackGroundPaint extends RectPaint {
backgroundColor: number = 0xffffff
backgroundColor: number = 0xffffff;
constructor(paint?:BackGroundPaint){
super(paint)
if(paint != null && paint != undefined){
constructor(paint?: BackGroundPaint) {
super(paint);
if (paint != null && paint != undefined) {
this.backgroundColor = paint.backgroundColor;
}
}
setBackgroundColor(value: number) {
this.backgroundColor = value
this.backgroundColor = value;
}
getBackgroundColor(): number{
return this.backgroundColor
getBackgroundColor(): number {
return this.backgroundColor;
}
}
export class LinearGradientPaint extends RectPaint {
constructor(paint?:BackGroundPaint){
super(paint)
constructor(paint?: BackGroundPaint) {
super(paint);
}
}
export class IndexPositionPaint extends RectPaint {
dataSetIndex:number
dataIndex:number
constructor(paint?:IndexPositionPaint){
super(paint)
dataSetIndex: number;
dataIndex: number;
constructor(paint?: IndexPositionPaint) {
super(paint);
}
setDataSetIndex(value: number) {
this.dataSetIndex = value
this.dataSetIndex = value;
}
getDataSetIndex(): number{
return this.dataSetIndex
getDataSetIndex(): number {
return this.dataSetIndex;
}
setDataIndex(value: number) {
this.dataIndex = value
this.dataIndex = value;
}
getDataIndex(): number{
return this.dataIndex
getDataIndex(): number {
return this.dataIndex;
}
}
export class CirclePaint extends Paint {
enabled: boolean = false;
circleColor: string | number | Color = Color.White;
colors:JArrayList<number> = null;
colors: JArrayList<number> = null;
radius: number = 2;
circleHoleRadius: number = 1;
circleHoleColor: string | number | Color = Color.White;
circleHoleEnabled: boolean = true;
constructor(paint?:Paint){
super(paint)
constructor(paint?: Paint) {
super(paint);
}
setDrawCircles(enabled: boolean){
this.enabled = enabled
setDrawCircles(enabled: boolean) {
this.enabled = enabled;
}
isDrawCirclesEnabled(): boolean{
return this.enabled
isDrawCirclesEnabled(): boolean {
return this.enabled;
}
setCirclesColor(circleColor: string | number | Color){
setCirclesColor(circleColor: string | number | Color) {
this.circleColor = circleColor;
}
setCircleRadius(radius: number){
setCircleRadius(radius: number) {
this.radius = radius;
}
setCircleHoleRadius(circleHoleRadius: number){
setCircleHoleRadius(circleHoleRadius: number) {
this.circleHoleRadius = circleHoleRadius;
}
setCircleHoleColor(circleHoleColor: string | number | Color){
setCircleHoleColor(circleHoleColor: string | number | Color) {
this.circleHoleColor = circleHoleColor;
}
setDrawCircleHole(circleHoleEnabled: boolean){
setDrawCircleHole(circleHoleEnabled: boolean) {
this.circleHoleEnabled = circleHoleEnabled;
}
}
export class ImagePaint extends Paint {
icon: string|Resource = null;
constructor(paint?:ImagePaint){
super(paint)
if(paint != null && paint != undefined){
icon: string | Resource = null;
constructor(paint?: ImagePaint) {
super(paint);
if (paint != null && paint != undefined) {
this.icon = paint.icon;
}
}
setIcon(value: string|Resource){
setIcon(value: string | Resource) {
this.icon = value;
}
getIcon(): string|Resource{
getIcon(): string | Resource {
return this.icon;
}
}
export enum Align {
LEFT,
CENTER,
RIGHT
LEFT,
CENTER,
RIGHT,
}
export class DashPathEffect{
export class DashPathEffect {
dash: number[];
offset: number
offset: number;
constructor(dash:number[],offset:number){
constructor(dash: number[], offset: number) {
this.dash = dash;
this.offset = offset;
}
}
export class FontMetrics {
/**
* The maximum distance above the baseline for the tallest glyph in
* the font at a given text size.
*/
public top : number;
/**
* The recommended distance above the baseline for singled spaced text.
*/
public ascent : number;
/**
* The recommended distance below the baseline for singled spaced text.
*/
public descent : number;
/**
* The maximum distance below the baseline for the lowest glyph in
* the font at a given text size.
*/
public bottom : number;
/**
* The recommended additional space to add between lines of text.
*/
public leading : number;
}
/**
* The maximum distance above the baseline for the tallest glyph in
* the font at a given text size.
*/
public top: number;
/**
* The recommended distance above the baseline for singled spaced text.
*/
public ascent: number;
/**
* The recommended distance below the baseline for singled spaced text.
*/
public descent: number;
/**
* The maximum distance below the baseline for the lowest glyph in
* the font at a given text size.
*/
public bottom: number;
/**
* The recommended additional space to add between lines of text.
*/
public leading: number;
}

View File

@ -20,128 +20,127 @@ import XAxisRendererRadarChart from '../renderer/XAxisRendererRadarChart';
import YAxisRendererRadarChart from '../renderer/YAxisRendererRadarChart';
import { XAxis } from '../components/XAxis';
import RadarData from './RadarData';
import YAxis from '../components/YAxis'
import Paint, { IndexPositionPaint , CirclePaint, TextPaint} from './Paint';
import YAxis from '../components/YAxis';
import Paint, { IndexPositionPaint, CirclePaint, TextPaint } from './Paint';
import MPPointF from '../utils/MPPointF';
import MyRect from './Rect';
import Utils from '../utils/Utils';
import Utils from '../utils/Utils';
import Highlight from '../highlight/Highlight';
export default class RadarChartMode{
export default class RadarChartMode {
public width: number;
public height: number;
public minOffset: number;
public paddingTop:number;
public paddingLeft:number=30;
public xExtraOffset=0
public yExtraOffset=0
public mRotateEnabled:boolean = true;
public paddingTop: number;
public paddingLeft: number = 30;
public xExtraOffset = 0;
public yExtraOffset = 0;
public mRotateEnabled: boolean = true;
/**
* width of the main web lines
*/
public mWebLineWidth:number = 2.5;
public mWebLineWidth: number = 2.5;
/**
* width of the inner web lines
*/
public mInnerWebLineWidth:number = 1.5;
public mInnerWebLineWidth: number = 1.5;
/**
* color for the main web lines
*/
public mWebColor:number = 0x64cccccc;
public mWebColor: number = 0x64cccccc;
/**
* color for the inner web
*/
public mWebColorInner:number =0x64cccccc;
public mWebColorInner: number = 0x64cccccc;
/**
* transparency the grid is drawn with (0-255)
*/
public mWebAlpha:number = 150;
public mWebAlpha: number = 150;
/**
* flag indicating if the web lines should be drawn or not
*/
public mDrawWeb:boolean = true;
public mDrawWeb: boolean = true;
/**
* modulus that determines how many labels and web-lines are skipped before the next is drawn
*/
public mSkipWebLineCount:number = 0;
public mSkipWebLineCount: number = 0;
public yAxis:YAxis;
public xAxis:XAxis;
public xScale:number;
public yScale:number;
public yAxis: YAxis;
public xAxis: XAxis;
public xScale: number;
public yScale: number;
data:RadarData= new RadarData();
data: RadarData = new RadarData();
displayCenterY: number = 0;
mRotationAngle:number = 270;
mRotationAngle: number = 270;
mRawRotationAngle = 270;
mStartAngle:number=0
yAxisRenderer:YAxisRendererRadarChart
xAxisRenderer:XAxisRendererRadarChart
radarRender:RadarChartRenderer
handler:ViewPortHandler
mAnimator:ChartAnimator
constructor(yAxis?:YAxis,data?:RadarData){
if(yAxis){
this.yAxis=yAxis;
mStartAngle: number = 0;
yAxisRenderer: YAxisRendererRadarChart;
xAxisRenderer: XAxisRendererRadarChart;
radarRender: RadarChartRenderer;
handler: ViewPortHandler;
mAnimator: ChartAnimator;
constructor(yAxis?: YAxis, data?: RadarData) {
if (yAxis) {
this.yAxis = yAxis;
}
if(data){
this.data=data;
if (data) {
this.data = data;
}
}
public getRotationAngle():number {
public getRotationAngle(): number {
return this.mRotationAngle;
}
public setYAxis(mYAxis:YAxis) :RadarChartMode{
this.yAxis=mYAxis
public setYAxis(mYAxis: YAxis): RadarChartMode {
this.yAxis = mYAxis;
return this;
}
public getYAxis() :YAxis{
public getYAxis(): YAxis {
return this.yAxis;
}
public setXAxis(xAxis:XAxis) :RadarChartMode{
this.xAxis=xAxis
public setXAxis(xAxis: XAxis): RadarChartMode {
this.xAxis = xAxis;
return this;
}
public setYExtraOffset(yExtraOffset:number){
this.yExtraOffset=yExtraOffset
return this
public setYExtraOffset(yExtraOffset: number) {
this.yExtraOffset = yExtraOffset;
return this;
}
public getXAxis() :XAxis{
public getXAxis(): XAxis {
return this.xAxis;
}
public getWebLineWidth():number {
public getWebLineWidth(): number {
return this.mWebLineWidth;
}
public getWebLineWidthInner():number {
public getWebLineWidthInner(): number {
return this.mInnerWebLineWidth;
}
public getWebAlpha():number {
public getWebAlpha(): number {
return this.mWebAlpha;
}
public getWebColor():number {
public getWebColor(): number {
return this.mWebColor;
}
public getWebColorInner():number {
public getWebColorInner(): number {
return this.mWebColorInner;
}
public getSkipWebLineCount():number {
public getSkipWebLineCount(): number {
return this.mSkipWebLineCount;
}
public getYChartMax():number {
public getYChartMax(): number {
return this.yAxis.mAxisMaximum;
}
/**
* Returns the minimum value this chart can display on it's y-axis.
*/
public getYChartMin():number {
public getYChartMin(): number {
return this.yAxis.mAxisMinimum;
}
@ -150,223 +149,223 @@ export default class RadarChartMode{
*
* @return
*/
public getYRange():number{
public getYRange(): number {
return this.yAxis.mAxisRange;
}
public getSliceAngle():number{
return 360/ this.data.getMaxEntryCountSet().getEntryCount();
public getSliceAngle(): number {
return 360 / this.data.getMaxEntryCountSet().getEntryCount();
}
public setWidth(width:number):RadarChartMode{
this.width=width
return this
public setWidth(width: number): RadarChartMode {
this.width = width;
return this;
}
public setHeight(height:number):RadarChartMode{
this.height=height
return this
public setHeight(height: number): RadarChartMode {
this.height = height;
return this;
}
public setMinOffset(minOffset:number):RadarChartMode{
this.minOffset=minOffset
return this
public setMinOffset(minOffset: number): RadarChartMode {
this.minOffset = minOffset;
return this;
}
public setPaddingTop(paddingTop:number):RadarChartMode{
this.paddingTop=paddingTop
return this
public setPaddingTop(paddingTop: number): RadarChartMode {
this.paddingTop = paddingTop;
return this;
}
public setPaddingLeft(paddingLeft:number):RadarChartMode{
this.paddingLeft=paddingLeft
return this
public setPaddingLeft(paddingLeft: number): RadarChartMode {
this.paddingLeft = paddingLeft;
return this;
}
public getWidth():number{
return this.width
public getWidth(): number {
return this.width;
}
public getHeight():number{
return this.height
public getHeight(): number {
return this.height;
}
public getMinOffset():number{
return this.minOffset
public getMinOffset(): number {
return this.minOffset;
}
public getPaddingTop():number{
return this.paddingTop
public getPaddingTop(): number {
return this.paddingTop;
}
public getPaddingLeft():number{
return this.paddingLeft
public getPaddingLeft(): number {
return this.paddingLeft;
}
public setData(data:RadarData):RadarChartMode{
this.data=data
return this
public setData(data: RadarData): RadarChartMode {
this.data = data;
return this;
}
public getData():RadarData{
return this.data
public getData(): RadarData {
return this.data;
}
public setXScale(xScale:number):RadarChartMode{
this.xScale=xScale
return this
public setXScale(xScale: number): RadarChartMode {
this.xScale = xScale;
return this;
}
public getXScale():number{
return this.xScale
public getXScale(): number {
return this.xScale;
}
public setYScale(yScale:number):RadarChartMode{
this.yScale=yScale
return this
public setYScale(yScale: number): RadarChartMode {
this.yScale = yScale;
return this;
}
public getYScale():number{
return this.yScale
public getYScale(): number {
return this.yScale;
}
public setDisplayCenterY(displayCenterY:number):RadarChartMode{
this.displayCenterY=displayCenterY
return this
public setDisplayCenterY(displayCenterY: number): RadarChartMode {
this.displayCenterY = displayCenterY;
return this;
}
public getDisplayCenterY():number{
return this.displayCenterY
public getDisplayCenterY(): number {
return this.displayCenterY;
}
public getRawRotationAngle():number {
public getRawRotationAngle(): number {
return this.mRawRotationAngle;
}
public setRotationAngle(angle:number) {
public setRotationAngle(angle: number) {
this.mRawRotationAngle = angle;
this.mRotationAngle = Utils.getNormalizedAngle(this.mRawRotationAngle);
}
public calcScale(){
public calcScale() {
let rect = this.data.mDisplayRect;
this.displayCenterY = (rect.bottom - rect.top)/2;
let minX=this.xAxis.getAxisMinimum()>0?0:this.xAxis.getAxisMinimum()
let miny=this.yAxis.getAxisMinimum()>0?0:this.xAxis.getAxisMinimum()
this.displayCenterY = (rect.bottom - rect.top) / 2;
let minX = this.xAxis.getAxisMinimum() > 0 ? 0 : this.xAxis.getAxisMinimum();
let miny = this.yAxis.getAxisMinimum() > 0 ? 0 : this.xAxis.getAxisMinimum();
this.xScale = (rect.right - rect.left)/(this.xAxis.getAxisMaximum()-minX);
this.yScale = (rect.bottom - rect.top)/(this.yAxis.getAxisMaximum()-miny);
this.xScale = (rect.right - rect.left) / (this.xAxis.getAxisMaximum() - minX);
this.yScale = (rect.bottom - rect.top) / (this.yAxis.getAxisMaximum() - miny);
}
public init(){
public init() {
this.calcScale();
this.handler = new ViewPortHandler();
this.handler.restrainViewPort(this.minOffset, this.minOffset, this.minOffset, this.minOffset)
this.handler.restrainViewPort(this.minOffset, this.minOffset, this.minOffset, this.minOffset);
this.handler.setChartDimens(this.width, this.height);
this.xAxisRenderer=new XAxisRendererRadarChart(this);
this.yAxisRenderer=new YAxisRendererRadarChart(this);
this.yAxisRenderer.computeAxis(this.yAxis.mAxisMinimum, this.yAxis.mAxisMaximum, this.yAxis.isInverted())
this.mAnimator=new ChartAnimator();
this.radarRender=new RadarChartRenderer(this);
this.xAxisRenderer = new XAxisRendererRadarChart(this);
this.yAxisRenderer = new YAxisRendererRadarChart(this);
this.yAxisRenderer.computeAxis(this.yAxis.mAxisMinimum, this.yAxis.mAxisMaximum, this.yAxis.isInverted());
this.mAnimator = new ChartAnimator();
this.radarRender = new RadarChartRenderer(this);
}
public getFactor():number {
let content:MyRect = this.handler.getContentRect();
public getFactor(): number {
let content: MyRect = this.handler.getContentRect();
return Math.min(content.width() / 2, content.height() / 2) / this.getYRange();
}
public getCenterOffsets():MPPointF{
public getCenterOffsets(): MPPointF {
return this.handler.getContentCenter();
}
public getAngleForPoint( x:number, y:number):number {
let c:MPPointF = this.getCenterOffsets();
let tx = x - c.x, ty = y - c.y;
public getAngleForPoint(x: number, y: number): number {
let c: MPPointF = this.getCenterOffsets();
let tx = x - c.x,
ty = y - c.y;
let length = Math.sqrt(tx * tx + ty * ty);
let r = Math.acos(ty / length);
let angle:number = 180*r/Math.PI;
if (x > c.x){
let angle: number = (180 * r) / Math.PI;
if (x > c.x) {
angle = 360 - angle;
}
angle = angle + 90;
if (angle > 360)
angle = angle - 360;
if (angle > 360) angle = angle - 360;
MPPointF.recycleInstance(c);
return angle;
}
paints:Paint[]=[]
highLight:Paint[]=[]
indexHighLightPaint:IndexPositionPaint=null;
public drawChart():Paint[]{
let paintsTemp:Paint[]=[];
let webPaint:Paint[]=this.radarRender.drawExtras();
paintsTemp=paintsTemp.concat(webPaint)
paints: Paint[] = [];
highLight: Paint[] = [];
indexHighLightPaint: IndexPositionPaint = null;
public drawChart(): Paint[] {
let paintsTemp: Paint[] = [];
let webPaint: Paint[] = this.radarRender.drawExtras();
paintsTemp = paintsTemp.concat(webPaint);
let dataPaint:Paint[]=this.radarRender.drawData();
paintsTemp=paintsTemp.concat(dataPaint)
let dataPaint: Paint[] = this.radarRender.drawData();
paintsTemp = paintsTemp.concat(dataPaint);
let xDataPaint:Paint[]=this.xAxisRenderer.renderAxisLabels();
paintsTemp=paintsTemp.concat(xDataPaint)
let xDataPaint: Paint[] = this.xAxisRenderer.renderAxisLabels();
paintsTemp = paintsTemp.concat(xDataPaint);
let valuePaint:Paint[]=this.radarRender.drawValues();
paintsTemp=paintsTemp.concat(valuePaint)
this.paints=[]
this.paints=this.paints.concat(paintsTemp)
return this.paints
let valuePaint: Paint[] = this.radarRender.drawValues();
paintsTemp = paintsTemp.concat(valuePaint);
this.paints = [];
this.paints = this.paints.concat(paintsTemp);
return this.paints;
}
public drawHighLight(){
if(this.indexHighLightPaint==null||!this.data.isHighlightEnabled()){
this.indexHighLightPaint=null;//便于旋转的时候判断是否需要绘制点击效果
this.highLight=[]
this.highLight.push(new CirclePaint())
this.highLight.push(new TextPaint())
return
public drawHighLight() {
if (this.indexHighLightPaint == null || !this.data.isHighlightEnabled()) {
this.indexHighLightPaint = null; //便于旋转的时候判断是否需要绘制点击效果
this.highLight = [];
this.highLight.push(new CirclePaint());
this.highLight.push(new TextPaint());
return;
}
let hightL:Highlight=new Highlight(this.indexHighLightPaint.x,this.indexHighLightPaint.y,
this.indexHighLightPaint.dataSetIndex,this.indexHighLightPaint.dataIndex,
-1,vp2px(this.indexHighLightPaint.x),vp2px(this.indexHighLightPaint.y)
let hightL: Highlight = new Highlight(
this.indexHighLightPaint.x,
this.indexHighLightPaint.y,
this.indexHighLightPaint.dataSetIndex,
this.indexHighLightPaint.dataIndex,
-1,
vp2px(this.indexHighLightPaint.x),
vp2px(this.indexHighLightPaint.y)
);
this.highLight=this.radarRender.drawHighlighted([hightL]);
this.highLight = this.radarRender.drawHighlighted([hightL]);
}
public drawClick(event: ClickEvent){
let x = event.screenX-this.paddingLeft-this.xExtraOffset;
let y = event.screenY-this.paddingTop-this.yExtraOffset;
let factor:number=this.getFactor();
let r:number= this.getYRange() * factor
let center:MPPointF=this.getCenterOffsets();
let clickToCenterSpace=Math.sqrt((x-center.x)*(x-center.x)+(y-center.y)*(y-center.y));
if(clickToCenterSpace>r){
this.indexHighLightPaint=null;//便于旋转的时候判断是否需要绘制点击效果
public drawClick(event: ClickEvent) {
let x = event.screenX - this.paddingLeft - this.xExtraOffset;
let y = event.screenY - this.paddingTop - this.yExtraOffset;
let factor: number = this.getFactor();
let r: number = this.getYRange() * factor;
let center: MPPointF = this.getCenterOffsets();
let clickToCenterSpace = Math.sqrt((x - center.x) * (x - center.x) + (y - center.y) * (y - center.y));
if (clickToCenterSpace > r) {
this.indexHighLightPaint = null; //便于旋转的时候判断是否需要绘制点击效果
this.drawHighLight();
return
return;
}
if(this.radarRender==null||this.radarRender==undefined){
return
if (this.radarRender == null || this.radarRender == undefined) {
return;
}
let dataP:Paint[]=this.radarRender.drawDataByType(this.radarRender.TYPE_POINT);
if(dataP==null||dataP==undefined||dataP.length==0){
return
let dataP: Paint[] = this.radarRender.drawDataByType(this.radarRender.TYPE_POINT);
if (dataP == null || dataP == undefined || dataP.length == 0) {
return;
}
let minPoint:Paint
let minSpaceResult:number;
for(let hightLight of dataP){
let xSpace=Math.abs(x-hightLight.x)
let ySpace=Math.abs(y-hightLight.y)
let minSpace=Math.sqrt(xSpace*xSpace+ySpace*ySpace)
if(minPoint==null||minPoint==undefined||minSpace<minSpaceResult){
minSpaceResult=minSpace
minPoint=hightLight;
let minPoint: Paint;
let minSpaceResult: number;
for (let hightLight of dataP) {
let xSpace = Math.abs(x - hightLight.x);
let ySpace = Math.abs(y - hightLight.y);
let minSpace = Math.sqrt(xSpace * xSpace + ySpace * ySpace);
if (minPoint == null || minPoint == undefined || minSpace < minSpaceResult) {
minSpaceResult = minSpace;
minPoint = hightLight;
}
}
if(minPoint==null||minPoint==undefined||!(minPoint instanceof IndexPositionPaint)){
return
if (minPoint == null || minPoint == undefined || !(minPoint instanceof IndexPositionPaint)) {
return;
}
this.indexHighLightPaint=(minPoint as IndexPositionPaint);
this.indexHighLightPaint = minPoint as IndexPositionPaint;
this.drawHighLight();
}
public drawTouch(event: TouchEvent){
if(!this.mRotateEnabled){
return
public drawTouch(event: TouchEvent) {
if (!this.mRotateEnabled) {
return;
}
let x:number=event.touches[0].x
let y:number=event.touches[0].y
let x: number = event.touches[0].x;
let y: number = event.touches[0].y;
if (event.type === TouchType.Down) {
this.mStartAngle=this.getAngleForPoint(x,y) - this.getRawRotationAngle()
this.mStartAngle = this.getAngleForPoint(x, y) - this.getRawRotationAngle();
}
if (event.type === TouchType.Up) {
}
if (event.type === TouchType.Move) {
this.setRotationAngle( this.getAngleForPoint(x, y) - this.mStartAngle);
this.drawChart()
if(this.indexHighLightPaint==null){
return
this.setRotationAngle(this.getAngleForPoint(x, y) - this.mStartAngle);
this.drawChart();
if (this.indexHighLightPaint == null) {
return;
}
this.drawHighLight();
}
}
}
}

View File

@ -14,8 +14,8 @@
*/
import Highlight from '../highlight/Highlight';
import IRadarDataSet from '../interfaces/datasets/IRadarDataSet'
import {JArrayList} from '../utils/JArrayList';
import IRadarDataSet from '../interfaces/datasets/IRadarDataSet';
import { JArrayList } from '../utils/JArrayList';
import ChartData from './ChartData';
import EntryOhos from './EntryOhos';
@ -23,10 +23,9 @@ import EntryOhos from './EntryOhos';
* Data container for the RadarChart.
*/
export default class RadarData extends ChartData<IRadarDataSet> {
private mLabels: JArrayList<string>;
private mLabels : JArrayList<string>;
constructor(dataSets ?: JArrayList<IRadarDataSet>) {
constructor(dataSets?: JArrayList<IRadarDataSet>) {
super(dataSets);
}
@ -35,16 +34,16 @@ export default class RadarData extends ChartData<IRadarDataSet> {
*
* @param labels
*/
public setLabels(labels : JArrayList<string>) : void {
this.mLabels = labels;
public setLabels(labels: JArrayList<string>): void {
this.mLabels = labels;
}
public getLabels() : JArrayList<string> {
public getLabels(): JArrayList<string> {
return this.mLabels;
}
// @Override
public getEntryForHighlight(highlight : Highlight) : EntryOhos {
public getEntryForHighlight(highlight: Highlight): EntryOhos {
return super.getDataSetByIndex(highlight.getDataSetIndex()).getEntryForIndex(highlight.getX());
}
}

View File

@ -15,98 +15,97 @@
import IRadarDataSet from '../interfaces/datasets/IRadarDataSet';
import ColorTemplate from '../utils/ColorTemplate';
import {JArrayList} from '../utils/JArrayList';
import { JArrayList } from '../utils/JArrayList';
import RadarEntry from './RadarEntry';
import LineRadarDataSet from './LineRadarDataSet';
import {DataSet} from './DataSet';
import { DataSet } from './DataSet';
export default class RadarDataSet extends LineRadarDataSet<RadarEntry> implements IRadarDataSet {
// flag indicating whether highlight circle should be drawn or not
protected mDrawHighlightCircleEnabled : boolean = false;
protected mDrawHighlightCircleEnabled: boolean = false;
protected mHighlightCircleFillColor : number = Color.White;
protected mHighlightCircleFillColor: number = Color.White;
// The stroke color for highlight circle.
// If Utils.COLOR_NONE, the color of the dataset is taken.
protected mHighlightCircleStrokeColor : number = ColorTemplate.COLOR_NONE;
protected mHighlightCircleStrokeColor: number = ColorTemplate.COLOR_NONE;
protected mHighlightCircleStrokeAlpha : number = (0.3 * 255);
protected mHighlightCircleInnerRadius : number = 3.0;
protected mHighlightCircleOuterRadius : number = 4.0;
protected mHighlightCircleStrokeWidth : number = 2.0;
protected mHighlightCircleStrokeAlpha: number = 0.3 * 255;
protected mHighlightCircleInnerRadius: number = 3.0;
protected mHighlightCircleOuterRadius: number = 4.0;
protected mHighlightCircleStrokeWidth: number = 2.0;
constructor(yVals : JArrayList<RadarEntry>, label : string ) {
constructor(yVals: JArrayList<RadarEntry>, label: string) {
super(yVals, label);
}
// Returns true if highlight circle should be drawn, false if not
// @Override
public isDrawHighlightCircleEnabled() : boolean {
public isDrawHighlightCircleEnabled(): boolean {
return this.mDrawHighlightCircleEnabled;
}
// Sets whether highlight circle should be drawn or not
// @Override
public setDrawHighlightCircleEnabled(enabled : boolean) : void {
public setDrawHighlightCircleEnabled(enabled: boolean): void {
this.mDrawHighlightCircleEnabled = enabled;
}
// @Override
public getHighlightCircleFillColor() : number {
public getHighlightCircleFillColor(): number {
return this.mHighlightCircleFillColor;
}
public setHighlightCircleFillColor(color : number) : void {
public setHighlightCircleFillColor(color: number): void {
this.mHighlightCircleFillColor = color;
}
// Returns the stroke color for highlight circle.
// If Utils.COLOR_NONE, the color of the dataset is taken.
// @Override
public getHighlightCircleStrokeColor() : number {
public getHighlightCircleStrokeColor(): number {
return this.mHighlightCircleStrokeColor;
}
// Sets the stroke color for highlight circle.
// Set to Utils.COLOR_NONE in order to use the color of the dataset;
public setHighlightCircleStrokeColor(color) : void {
public setHighlightCircleStrokeColor(color): void {
this.mHighlightCircleStrokeColor = color;
}
// @Override
public getHighlightCircleStrokeAlpha() : number {
public getHighlightCircleStrokeAlpha(): number {
return this.mHighlightCircleStrokeAlpha;
}
public setHighlightCircleStrokeAlpha(alpha : number) : void {
public setHighlightCircleStrokeAlpha(alpha: number): void {
this.mHighlightCircleStrokeAlpha = alpha;
}
// @Override
public getHighlightCircleInnerRadius() : number {
public getHighlightCircleInnerRadius(): number {
return this.mHighlightCircleInnerRadius;
}
public setHighlightCircleInnerRadius(radius : number) : void {
public setHighlightCircleInnerRadius(radius: number): void {
this.mHighlightCircleInnerRadius = radius;
}
// @Override
public getHighlightCircleOuterRadius() : number{
public getHighlightCircleOuterRadius(): number {
return this.mHighlightCircleOuterRadius;
}
public setHighlightCircleOuterRadius(radius : number) : void {
public setHighlightCircleOuterRadius(radius: number): void {
this.mHighlightCircleOuterRadius = radius;
}
// @Override
public getHighlightCircleStrokeWidth() : number {
public getHighlightCircleStrokeWidth(): number {
return this.mHighlightCircleStrokeWidth;
}
public setHighlightCircleStrokeWidth(strokeWidth : number) : void {
public setHighlightCircleStrokeWidth(strokeWidth: number): void {
this.mHighlightCircleStrokeWidth = strokeWidth;
}

View File

@ -16,8 +16,8 @@
import EntryOhos from './EntryOhos';
export default class RadarEntry extends EntryOhos {
constructor(value : number, data ?: Object) {
super(0, value,null,data);
constructor(value: number, data?: Object) {
super(0, value, null, data);
}
/**
@ -25,11 +25,11 @@ export default class RadarEntry extends EntryOhos {
*
* @return
*/
public getValue() : number {
public getValue(): number {
return super.getY();
}
public copy() : RadarEntry {
public copy(): RadarEntry {
var e = new RadarEntry(super.getY(), super.getData());
return e;
}

View File

@ -28,7 +28,6 @@ export default class MyRect {
right: number;
bottom: number;
/**
* Create a new rectangle with the specified coordinates. Note: no range
* checking is performed, so the caller must ensure that left <= right and
@ -40,7 +39,7 @@ export default class MyRect {
* @param bottom The Y coordinate of the bottom of the rectangle
*/
constructor(left?: number, top?: number, right?: number, bottom?: number, r?: MyRect) {
this.left = left == undefined ? 0 : left
this.left = left == undefined ? 0 : left;
this.top = top == undefined ? 0 : top;
this.right = right == undefined ? 0 : right;
this.bottom = bottom == undefined ? 0 : bottom;
@ -68,20 +67,19 @@ export default class MyRect {
}
public toString(): string {
var sb = "";
sb += "Rect(";
var sb = '';
sb += 'Rect(';
sb += this.left;
sb += ", ";
sb += ', ';
sb += this.top;
sb += " - ";
sb += ' - ';
sb += this.right;
sb += ", ";
sb += ', ';
sb += this.bottom;
sb += ")";
sb += ')';
return sb;
}
/**
* Returns true if the rectangle is empty (left >= right or top >= bottom)
*/
@ -189,15 +187,14 @@ export default class MyRect {
this.top = newTop;
}
/**
* Insets the rectangle on all sides specified by the insets.
* @hide
* @param left The amount to add from the rectangle's left
* @param top The amount to add from the rectangle's top
* @param right The amount to subtract from the rectangle's right
* @param bottom The amount to subtract from the rectangle's bottom
*/
* Insets the rectangle on all sides specified by the insets.
* @hide
* @param left The amount to add from the rectangle's left
* @param top The amount to add from the rectangle's top
* @param right The amount to subtract from the rectangle's right
* @param bottom The amount to subtract from the rectangle's bottom
*/
public inset(left: number, top: number, right: number, bottom: number) {
this.left += left;
this.top += top;
@ -206,18 +203,24 @@ export default class MyRect {
}
/**
* Returns true if (x,y) is inside the rectangle. The left and top are
* considered to be inside, while the right and bottom are not. This means
* that for a x,y to be contained: left <= x < right and top <= y < bottom.
* An empty rectangle never contains any point.
*
* @param x The X coordinate of the point being tested for containment
* @param y The Y coordinate of the point being tested for containment
* @return true iff (x,y) are contained by the rectangle, where containment
* means left <= x < right and top <= y < bottom
*/
* Returns true if (x,y) is inside the rectangle. The left and top are
* considered to be inside, while the right and bottom are not. This means
* that for a x,y to be contained: left <= x < right and top <= y < bottom.
* An empty rectangle never contains any point.
*
* @param x The X coordinate of the point being tested for containment
* @param y The Y coordinate of the point being tested for containment
* @return true iff (x,y) are contained by the rectangle, where containment
* means left <= x < right and top <= y < bottom
*/
public contains(x: number, y: number): boolean {
return this.left < this.right && this.top < this.bottom // check for empty first
&& x >= this.left && x < this.right && y >= this.top && y < this.bottom;
return (
this.left < this.right &&
this.top < this.bottom && // check for empty first
x >= this.left &&
x < this.right &&
y >= this.top &&
y < this.bottom
);
}
}
}

View File

@ -13,23 +13,25 @@
* limitations under the License.
*/
import {Poolable} from '../utils/Poolable';
import { Poolable } from '../utils/Poolable';
export default class Runnable extends Poolable {
_type:string;
_type: string;
callback: {};
constructor(_type:string,callback:{}){
constructor(_type: string, callback: {}) {
super();
this._type = _type;
this.callback = callback;
}
protected setType(_type:string){
protected setType(_type: string) {
this._type = _type;
}
protected setCallback(callback: {}){
protected setCallback(callback: {}) {
this.callback = callback;
}
public instantiate(): Poolable{return null};
}
public instantiate(): Poolable {
return null;
}
}

View File

@ -19,142 +19,140 @@ import { YAxisModel } from '../components/renderer/YAxisView';
export default class ScaleMode {
width: number = 300; //表的宽度
height: number = 300; //表的高度
scaleX: number= 1 //当前X累计放大倍数
scaleY: number= 1 //当前Y累计放大倍数
preTouchScaleX: number= 1 //上一次 手势、双击缩放后的缩放
scaleX: number = 1; //当前X累计放大倍数
scaleY: number = 1; //当前Y累计放大倍数
preTouchScaleX: number = 1; //上一次 手势、双击缩放后的缩放
moveX: number= 0 //累计平移X
moveY: number= 0 //累计平移Y
currentMoveX:number=0//当前次的位移
currentMoveY:number=0//当前次的位移
startMoveX: number= 0
startMoveY: number= 0
moveX: number = 0; //累计平移X
moveY: number = 0; //累计平移Y
currentMoveX: number = 0; //当前次的位移
currentMoveY: number = 0; //当前次的位移
startMoveX: number = 0;
startMoveY: number = 0;
currentXSpace:number=0//缩放之后 需要移回的距离
currentYSpace:number=0//缩放之后 需要移回的距离
currentXSpace: number = 0; //缩放之后 需要移回的距离
currentYSpace: number = 0; //缩放之后 需要移回的距离
isZoom: boolean = false;
centerX: number = 0; //双指缩放、双击的中心点X
centerY: number = 0; //双指缩放、双击的中心点Y
firstTouch: TouchObject; //第一个手指按下点
secondTouch: TouchObject; //第二个手指按下点
firstClickTime: number = 0; //第一次点击的时间 用于判断是否为双击
isZoom: boolean= false
centerX: number= 0 //双指缩放、双击的中心点X
centerY: number= 0 //双指缩放、双击的中心点Y
firstTouch: TouchObject //第一个手指按下点
secondTouch: TouchObject //第二个手指按下点
firstClickTime: number= 0 //第一次点击的时间 用于判断是否为双击
onDoubleClickScale: number = 0.1; //双击放大倍数 增加0.4倍
leftAxisModel: YAxisModel = new YAxisModel();
rightAxisModel: YAxisModel = new YAxisModel();
onDoubleClickScale:number=0.1;//双击放大倍数 增加0.4倍
leftAxisModel:YAxisModel = new YAxisModel();
rightAxisModel:YAxisModel = new YAxisModel();
xAixsMode: XAixsMode = new XAixsMode();
isNeedScale: boolean = true;
xAixsMode:XAixsMode=new XAixsMode()
isNeedScale:boolean=true
public touchScale(xScale: number, yScale: number,event: TouchEvent) {
this.scaleX = (xScale * this.preTouchScaleX)
this.scaleY = (yScale * this.preTouchScaleX)
public touchScale(xScale: number, yScale: number, event: TouchEvent) {
this.scaleX = xScale * this.preTouchScaleX;
this.scaleY = yScale * this.preTouchScaleX;
if (this.scaleX < 1) {
this.scaleX = 1
this.centerX = 0
this.scaleX = 1;
this.centerX = 0;
}
if (this.scaleY < 1) {
this.scaleY = 1
this.centerY = 0
this.scaleY = 1;
this.centerY = 0;
}
this.xAixsMode.width=this.width*this.scaleX
this.onScale(event)
this.leftAxisModel.scale(this.scaleY)
this.rightAxisModel.scale(this.scaleY)
this.xAixsMode.width = this.width * this.scaleX;
this.onScale(event);
this.leftAxisModel.scale(this.scaleY);
this.rightAxisModel.scale(this.scaleY);
}
public doubleClickScale(event: ClickEvent,xScale: number, yScale: number) {
this.scaleX += xScale
this.scaleY += yScale
this.preTouchScaleX = this.scaleX
public doubleClickScale(event: ClickEvent, xScale: number, yScale: number) {
this.scaleX += xScale;
this.scaleY += yScale;
this.preTouchScaleX = this.scaleX;
if (this.scaleX < 1) {
this.scaleX = 1
this.centerX = 0
this.scaleX = 1;
this.centerX = 0;
}
if (this.scaleY < 1) {
this.scaleY = 1
this.centerY = 0
this.scaleY = 1;
this.centerY = 0;
}
this.xAixsMode.width=this.width*this.scaleX
this.onDoubleClick(event)
this.leftAxisModel.scale(this.scaleY)
this.rightAxisModel.scale(this.scaleY)
this.xAixsMode.width = this.width * this.scaleX;
this.onDoubleClick(event);
this.leftAxisModel.scale(this.scaleY);
this.rightAxisModel.scale(this.scaleY);
}
public move(moveX, moveY,event: TouchEvent) {
this.currentMoveX = moveX
this.currentMoveY = moveY
this.moveX += moveX
this.moveY += moveY
this.onMove(event)
public move(moveX, moveY, event: TouchEvent) {
this.currentMoveX = moveX;
this.currentMoveY = moveY;
this.moveX += moveX;
this.moveY += moveY;
this.onMove(event);
}
public setXPosition(xPosition:number){
this.xAixsMode.xPosition=xPosition
this.xAixsMode.draw()
public setXPosition(xPosition: number) {
this.xAixsMode.xPosition = xPosition;
this.xAixsMode.draw();
}
/**
* 重置
*/
public reset() {
this.scaleX = 1
this.scaleY = 1
this.moveX = 0
this.moveY = 0
this.centerX = 0
this.centerY = 0
this.preTouchScaleX = 1
this.currentXSpace=0
this.currentYSpace=0
this.scaleX = 1;
this.scaleY = 1;
this.moveX = 0;
this.moveY = 0;
this.centerX = 0;
this.centerY = 0;
this.preTouchScaleX = 1;
this.currentXSpace = 0;
this.currentYSpace = 0;
}
/**
* view 调用 点击事件 此事件分发单击、双击事件
* @param event
*/
public onClick(event: ClickEvent){
let currnetTime=new Date().getTime();
let spaceTime=currnetTime-this.firstClickTime
this.firstClickTime=currnetTime
public onClick(event: ClickEvent) {
let currnetTime = new Date().getTime();
let spaceTime = currnetTime - this.firstClickTime;
this.firstClickTime = currnetTime;
if(spaceTime<300){
if (spaceTime < 300) {
/**
* 双击放大事件
*/
this.centerX=event.x;
this.centerY=event.y;
this.doubleClickScale(event,this.onDoubleClickScale,this.onDoubleClickScale)
}else{
this.centerX = event.x;
this.centerY = event.y;
this.doubleClickScale(event, this.onDoubleClickScale, this.onDoubleClickScale);
} else {
//单击
this.onSingleClick(event)
this.onSingleClick(event);
}
}
/**
* view 调用的触摸事件 此事件可分发 缩放、平移两个事件,缩放 监听为两指
* @param event
*/
public onTouch(event: TouchEvent){
public onTouch(event: TouchEvent) {
/**
* 监听按下手指的数量,最大监听两个手指
*/
if (event.type === TouchType.Down) {
this.firstTouch=event.touches[0]
if(event.touches.length>1){
this.secondTouch=event.touches[1]
}else{
this.startMoveX=0
this.startMoveY=0
this.firstTouch = event.touches[0];
if (event.touches.length > 1) {
this.secondTouch = event.touches[1];
} else {
this.startMoveX = 0;
this.startMoveY = 0;
}
}
if (event.type === TouchType.Up) {
//双指 突然变一指 后,界面将不在移动
if(event.touches.length==1){
if(this.isZoom==true){
this.preTouchScaleX=this.scaleX
if (event.touches.length == 1) {
if (this.isZoom == true) {
this.preTouchScaleX = this.scaleX;
}
this.isZoom=false
this.isZoom = false;
}
}
}
@ -162,36 +160,28 @@ export default class ScaleMode {
* 需要覆写的 单击事件
* @param event
*/
public onSingleClick(event: ClickEvent){
public onSingleClick(event: ClickEvent) {
/* scaleX: number= 1 //当前X累计放大倍数
scaleY: number= 1 //当前Y累计放大倍数
moveX: number= 0 //累计平移X
moveY: number= 0 //累计平移Y
centerX: number= 0 //双指缩放、双击的中心点X
centerY: number= 0 //双指缩放、双击的中心点Y*/
scaleY: number= 1 //当前Y累计放大倍数
moveX: number= 0 //累计平移X
moveY: number= 0 //累计平移Y
centerX: number= 0 //双指缩放、双击的中心点X
centerY: number= 0 //双指缩放、双击的中心点Y*/
//参数可在子类直接调用
}
/**
* 需要覆写的 双击击事件
* @param event
*/
public onDoubleClick(event: ClickEvent){
}
* 需要覆写的 双击击事件
* @param event
*/
public onDoubleClick(event: ClickEvent) {}
/**
* 需要覆写的平移事件
* @param event
*/
public onMove(event: TouchEvent){
}
public onMove(event: TouchEvent) {}
/**
* 需要覆写的平移事件 的缩放事件
* @param event
*/
public onScale(event: TouchEvent){
}
}
public onScale(event: TouchEvent) {}
}

View File

@ -13,18 +13,12 @@
* limitations under the License.
*/
import LineScatterCandleRadarDataSet from './LineScatterCandleRadarDataSet'
import EntryOhos from './EntryOhos'
import IScatterDataSet from '../interfaces/datasets/IScatterDataSet'
import ColorTemplate from '../utils/ColorTemplate'
import {JArrayList} from '../utils/JArrayList'
import IShapeRenderer from '../renderer/scatter/IShapeRenderer'
import LineScatterCandleRadarDataSet from './LineScatterCandleRadarDataSet';
import EntryOhos from './EntryOhos';
import IScatterDataSet from '../interfaces/datasets/IScatterDataSet';
import ColorTemplate from '../utils/ColorTemplate';
import { JArrayList } from '../utils/JArrayList';
import IShapeRenderer from '../renderer/scatter/IShapeRenderer';
export class ScatterDataSet extends LineScatterCandleRadarDataSet<EntryOhos> implements IScatterDataSet {
/**
@ -36,7 +30,6 @@ export class ScatterDataSet extends LineScatterCandleRadarDataSet<EntryOhos> imp
* Renderer responsible for rendering this DataSet, default: square
*/
/**
* The radius of the hole in the shape (applies to Square, Circle and Triangle)
* - default: 0.0
@ -64,7 +57,7 @@ export class ScatterDataSet extends LineScatterCandleRadarDataSet<EntryOhos> imp
return copied;
}
public copyTo(scatterDataSet: ScatterDataSet): void{
public copyTo(scatterDataSet: ScatterDataSet): void {
super.copyTo(scatterDataSet);
scatterDataSet.mShapeSize = this.mShapeSize;
@ -93,7 +86,6 @@ export class ScatterDataSet extends LineScatterCandleRadarDataSet<EntryOhos> imp
* @param shape
*/
/**
* Sets a new IShapeRenderer responsible for drawing this DataSet.
* This can also be used to set a custom IShapeRenderer aside from the default ones.
@ -101,14 +93,13 @@ export class ScatterDataSet extends LineScatterCandleRadarDataSet<EntryOhos> imp
* @param shapeRenderer
*/
/**
* Sets the radius of the hole in the shape (applies to Square, Circle and Triangle)
* Set this to <= 0 to remove holes.
*
* @param holeRadius
*/
public setScatterShapeHoleRadius(holeRadius: number): void {
public setScatterShapeHoleRadius(holeRadius: number): void {
this.mScatterShapeHoleRadius = holeRadius;
}
@ -128,6 +119,4 @@ export class ScatterDataSet extends LineScatterCandleRadarDataSet<EntryOhos> imp
public getScatterShapeHoleColor(): number {
return this.mScatterShapeHoleColor;
}
}

View File

@ -20,54 +20,56 @@ import { XAxis } from '../components/XAxis';
import Paint from './Paint';
import ViewPortHandler from '../utils/ViewPortHandler';
export default class XAixsMode {
paints: Paint[] = [];
handler: ViewPortHandler = new ViewPortHandler();
topAxis: XAxis = new XAxis();
bottomAxis: XAxis = new XAxis();
width: number = 300;
height: number = 300;
minOffset: number = 15;
yLeftLongestLabel: string = 'AAA';
yRightLongestLabel: string = 'AAA';
XLimtLine: LimitLine = new LimitLine(35, 'Index 10');
export default class XAixsMode{
xPosition: number = 0;
yPosition: number = 0;
clipPath: string;
paints:Paint[] = []
handler:ViewPortHandler = new ViewPortHandler();
topAxis:XAxis = new XAxis();
bottomAxis:XAxis = new XAxis();
width:number = 300;
height:number = 300;
minOffset:number = 15;
yLeftLongestLabel:string="AAA"
yRightLongestLabel:string="AAA"
XLimtLine:LimitLine = new LimitLine(35, "Index 10");
public draw() {
this.paints = [];
let minYOffset = this.topAxis.getTextSize() + this.topAxis.getYOffset();
this.minOffset = this.minOffset < minYOffset ? minYOffset : this.minOffset;
xPosition:number=0
yPosition:number=0
clipPath:string;
public draw(){
this.paints=[]
let minYOffset=this.topAxis.getTextSize()+this.topAxis.getYOffset();
this.minOffset=this.minOffset<minYOffset?minYOffset:this.minOffset
this.handler.restrainViewPort(this.minOffset,this.minOffset,this.minOffset,this.minOffset)
this.handler.setChartDimens(this.width,this.height);
let mAxisRendererTop:XAxisRenderer = new XAxisRenderer(this.handler,this.topAxis,new Transformer(this.handler));
mAxisRendererTop.yLeftLongestLabel=this.yLeftLongestLabel;
mAxisRendererTop.yRightLongestLabel=this.yRightLongestLabel;
mAxisRendererTop.computeAxis(this.topAxis.mAxisMinimum,this.topAxis.mAxisMaximum,false)
this.handler.restrainViewPort(this.minOffset, this.minOffset, this.minOffset, this.minOffset);
this.handler.setChartDimens(this.width, this.height);
let mAxisRendererTop: XAxisRenderer = new XAxisRenderer(this.handler, this.topAxis, new Transformer(this.handler));
mAxisRendererTop.yLeftLongestLabel = this.yLeftLongestLabel;
mAxisRendererTop.yRightLongestLabel = this.yRightLongestLabel;
mAxisRendererTop.computeAxis(this.topAxis.mAxisMinimum, this.topAxis.mAxisMaximum, false);
this.paints = this.paints.concat(mAxisRendererTop.renderAxisLine());
this.paints = this.paints.concat(mAxisRendererTop.renderAxisLabels())
this.paints = this.paints.concat(mAxisRendererTop.renderGridLines())
let mAxisRendererBottom:XAxisRenderer = new XAxisRenderer(this.handler,this.bottomAxis,new Transformer(this.handler));
mAxisRendererBottom.yLeftLongestLabel=this.yLeftLongestLabel;
mAxisRendererBottom.yRightLongestLabel=this.yRightLongestLabel;
mAxisRendererBottom.computeAxis(this.bottomAxis.mAxisMinimum,this.bottomAxis.mAxisMaximum,false)
this.paints = this.paints.concat(mAxisRendererTop.renderAxisLabels());
this.paints = this.paints.concat(mAxisRendererTop.renderGridLines());
let mAxisRendererBottom: XAxisRenderer = new XAxisRenderer(
this.handler,
this.bottomAxis,
new Transformer(this.handler)
);
mAxisRendererBottom.yLeftLongestLabel = this.yLeftLongestLabel;
mAxisRendererBottom.yRightLongestLabel = this.yRightLongestLabel;
mAxisRendererBottom.computeAxis(this.bottomAxis.mAxisMinimum, this.bottomAxis.mAxisMaximum, false);
this.paints = this.paints.concat(mAxisRendererBottom.renderAxisLine());
this.paints = this.paints.concat(mAxisRendererBottom.renderAxisLabels())
this.paints = this.paints.concat(mAxisRendererBottom.renderAxisLabels());
this.paints = this.paints.concat(mAxisRendererTop.renderLimitLines());
let arr = [];
for(let item of this.paints){
if(item){
for (let item of this.paints) {
if (item) {
arr.push(item);
}
}
this.paints = arr;
}
}
}

View File

@ -13,49 +13,46 @@
* limitations under the License.
*/
import IAxisValueFormatter from './IAxisValueFormatter'
import AxisBase from '../components/AxisBase'
import IAxisValueFormatter from './IAxisValueFormatter';
import AxisBase from '../components/AxisBase';
export default class DefaultAxisValueFormatter implements IAxisValueFormatter {
/**
* the number of decimal digits this formatter uses
*/
* the number of decimal digits this formatter uses
*/
protected digits: number = 0;
/**
* Constructor that specifies to how many digits the value should be
* formatted.
*
* @param digits
*/
* Constructor that specifies to how many digits the value should be
* formatted.
*
* @param digits
*/
constructor(digits: number) {
this.digits = digits;
var b: string = "";
var b: string = '';
for (var i = 0; i < digits; i++) {
if (i == 0)
b += ".";
b += "0";
if (i == 0) b += '.';
b += '0';
}
}
public getFormattedValue(value: number, axis: AxisBase): string {
// avoid memory allocations here (for performance)
var str = String(value.toFixed(1)).split(".");
if(str[1] == "0"){
var str = String(value.toFixed(1)).split('.');
if (str[1] == '0') {
return str[0];
}else{
return String(value.toFixed(1))
} else {
return String(value.toFixed(1));
}
}
/**
* Returns the number of decimal digits this formatter uses or -1, if unspecified.
*
* @return
*/
* Returns the number of decimal digits this formatter uses or -1, if unspecified.
*
* @return
*/
public getDecimalDigits(): number {
return this.digits;
}

View File

@ -23,36 +23,28 @@ import IFillFormatter from './IFillFormatter';
*
* @author Philipp Jahoda
*/
export default class DefaultFillFormatter implements IFillFormatter
{
export default class DefaultFillFormatter implements IFillFormatter {
public getFillLinePosition(dataSet: ILineDataSet, dataProvider: LineDataProvider): number {
var fillMin: number = 0;
var chartMaxY: number = dataProvider.getYChartMax();
var chartMinY: number = dataProvider.getYChartMin();
public getFillLinePosition( dataSet:ILineDataSet, dataProvider:LineDataProvider):number {
var fillMin:number = 0;
var chartMaxY:number = dataProvider.getYChartMax();
var chartMinY:number= dataProvider.getYChartMin();
var data:LineData= dataProvider.getLineData();
var data: LineData = dataProvider.getLineData();
if (dataSet.getYMax() > 0 && dataSet.getYMin() < 0) {
fillMin = 0;
} else {
var max: number;
var min: number;
var max:number;
var min:number;
if (data.getYMax() > 0)
max = 0;
else
max = chartMaxY;
if (data.getYMin() < 0)
min = 0;
else
min = chartMinY;
if (data.getYMax() > 0) max = 0;
else max = chartMaxY;
if (data.getYMin() < 0) min = 0;
else min = chartMinY;
fillMin = dataSet.getYMin() >= 0 ? min : max;
}
return fillMin;
}
}
}

View File

@ -23,15 +23,13 @@ import ViewPortHandler from '../utils/ViewPortHandler';
*
* @author Philipp Jahoda
*/
export default class DefaultValueFormatter implements IValueFormatter
{
export default class DefaultValueFormatter implements IValueFormatter {
/**
* DecimalFormat for formatting
*/
//protected mFormat:DecimalFormat;
protected mDecimalDigits:number;
protected mDecimalDigits: number;
/**
* Constructor that specifies to how many digits the value should be
@ -39,33 +37,34 @@ export default class DefaultValueFormatter implements IValueFormatter
*
* @param digits
*/
constructor(digits:number){
this.setup(digits);
}
constructor(digits: number) {
this.setup(digits);
}
/**
* Sets up the formatter with a given number of decimal digits.
*
* @param digits
*/
public setup(digits:number):void {
public setup(digits: number): void {
this.mDecimalDigits = digits;
var b:string = "";
var b: string = '';
for (var i = 0; i < digits; i++) {
if (i == 0)
b+=".";
b+="0";
if (i == 0) b += '.';
b += '0';
}
}
public getFormattedValue( value:number, entry:EntryOhos, dataSetIndex:number, viewPortHandler:ViewPortHandler):string {
public getFormattedValue(
value: number,
entry: EntryOhos,
dataSetIndex: number,
viewPortHandler: ViewPortHandler
): string {
// put more logic here ...
// avoid memory allocations here (for performance reasons)
return value.toFixed(1)+"" ;
return value.toFixed(1) + '';
}
/**
@ -73,7 +72,7 @@ export default class DefaultValueFormatter implements IValueFormatter
*
* @return
*/
public getDecimalDigits():number {
public getDecimalDigits(): number {
return this.mDecimalDigits;
}
}

View File

@ -13,22 +13,20 @@
* limitations under the License.
*/
import AxisBase from '../components/AxisBase'
import AxisBase from '../components/AxisBase';
/**
* Custom formatter interface that allows formatting of
* axis labels before they are being drawn.
*/
export default interface IAxisValueFormatter
{
/**
* Called when a value from an axis is to be formatted
* before being drawn. For performance reasons, avoid excessive calculations
* and memory allocations inside this method.
*
* @param value the value to be formatted
* @param axis the axis the value belongs to
* @return
*/
getFormattedValue(value:number,axis:AxisBase):string;
export default interface IAxisValueFormatter {
/**
* Called when a value from an axis is to be formatted
* before being drawn. For performance reasons, avoid excessive calculations
* and memory allocations inside this method.
*
* @param value the value to be formatted
* @param axis the axis the value belongs to
* @return
*/
getFormattedValue(value: number, axis: AxisBase): string;
}

View File

@ -21,9 +21,7 @@ import ILineDataSet from '../interfaces/datasets/ILineDataSet';
*
* @author Philipp Jahoda
*/
export default interface IFillFormatter
{
export default interface IFillFormatter {
/**
* Returns the vertical (y-axis) position where the filled-line of the
* LineDataSet should end.
@ -32,5 +30,5 @@ export default interface IFillFormatter
* @param dataProvider
* @return
*/
getFillLinePosition( dataSet:ILineDataSet, dataProvider:LineDataProvider):number;
getFillLinePosition(dataSet: ILineDataSet, dataProvider: LineDataProvider): number;
}

View File

@ -23,19 +23,17 @@ import ViewPortHandler from '../utils/ViewPortHandler';
*
* @author Philipp Jahoda
*/
export default interface IValueFormatter
{
/**
* Called when a value (from labels inside the chart) is formatted
* before being drawn. For performance reasons, avoid excessive calculations
* and memory allocations inside this method.
*
* @param value the value to be formatted
* @param entry the entry the value belongs to - in e.g. BarChart, this is of class BarEntry
* @param dataSetIndex the index of the DataSet the entry in focus belongs to
* @param viewPortHandler provides information about the current chart state (scale, translation, ...)
* @return the formatted label ready for being drawn
*/
getFormattedValue(value:number, entry:EntryOhos, dataSetIndex:number, viewPortHandler:ViewPortHandler):string;
export default interface IValueFormatter {
/**
* Called when a value (from labels inside the chart) is formatted
* before being drawn. For performance reasons, avoid excessive calculations
* and memory allocations inside this method.
*
* @param value the value to be formatted
* @param entry the entry the value belongs to - in e.g. BarChart, this is of class BarEntry
* @param dataSetIndex the index of the DataSet the entry in focus belongs to
* @param viewPortHandler provides information about the current chart state (scale, translation, ...)
* @return the formatted label ready for being drawn
*/
getFormattedValue(value: number, entry: EntryOhos, dataSetIndex: number, viewPortHandler: ViewPortHandler): string;
}

View File

@ -13,43 +13,40 @@
* limitations under the License.
*/
import YAxis,{AxisDependency} from '../components/YAxis';
import YAxis, { AxisDependency } from '../components/YAxis';
import BarLineScatterCandleBubbleData from '../data/BarLineScatterCandleBubbleData';
import { Rounding} from '../data/DataSet';
import { Rounding } from '../data/DataSet';
import EntryOhos from '../data/EntryOhos';
import BarLineScatterCandleBubbleDataProvider from '../interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider';
import IDataSet from '../interfaces/datasets/IDataSet';
import MPPointD from '../utils/MPPointD';
import {JArrayList} from '../utils/JArrayList';
import { JArrayList } from '../utils/JArrayList';
import Highlight from './Highlight';
import IHighlighter from './IHighlighter';
import IBarLineScatterCandleBubbleDataSet from '../interfaces/datasets/IBarLineScatterCandleBubbleDataSet';
export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataProvider> implements IHighlighter
{
export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataProvider> implements IHighlighter {
/**
* instance of the data-provider
*/
protected mChart : T;
protected mChart: T;
/**
* buffer for storing previously highlighted values
*/
protected mHighlightBuffer : JArrayList<Highlight> = new JArrayList<Highlight>();
protected mHighlightBuffer: JArrayList<Highlight> = new JArrayList<Highlight>();
constructor(chart : T) {
constructor(chart: T) {
this.mChart = chart;
}
// @Override
public getHighlight(x : number, y : number) : Highlight {
var pos : MPPointD = this.getValsForTouch(x, y);
var xVal : number = pos.x;
// @Override
public getHighlight(x: number, y: number): Highlight {
var pos: MPPointD = this.getValsForTouch(x, y);
var xVal: number = pos.x;
MPPointD.recycleInstance(pos);
var high : Highlight = this.getHighlightForX(xVal, x, y);
var high: Highlight = this.getHighlightForX(xVal, x, y);
return high;
}
@ -61,10 +58,9 @@ export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataPr
* @param y
* @return
*/
protected getValsForTouch(x : number, y : number) : MPPointD {
protected getValsForTouch(x: number, y: number): MPPointD {
// take any transformer to determine the x-axis value
var pos : MPPointD = this.mChart.getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(x, y);
var pos: MPPointD = this.mChart.getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(x, y);
return pos;
}
@ -76,20 +72,25 @@ export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataPr
* @param y
* @return
*/
protected getHighlightForX(xVal : number, x : number, y : number) : Highlight {
protected getHighlightForX(xVal: number, x: number, y: number): Highlight {
var closestValues: JArrayList<Highlight> = this.getHighlightsAtXValue(xVal, x, y);
var closestValues : JArrayList<Highlight> = this.getHighlightsAtXValue(xVal, x, y);
if(closestValues.isEmpty()) {
if (closestValues.isEmpty()) {
return null;
}
var leftAxisMinDist : number = this.getMinimumDistance(closestValues, y, AxisDependency.LEFT);
var rightAxisMinDist : number = this.getMinimumDistance(closestValues, y, AxisDependency.RIGHT);
var leftAxisMinDist: number = this.getMinimumDistance(closestValues, y, AxisDependency.LEFT);
var rightAxisMinDist: number = this.getMinimumDistance(closestValues, y, AxisDependency.RIGHT);
var axis : AxisDependency = leftAxisMinDist < rightAxisMinDist ? AxisDependency.LEFT : AxisDependency.RIGHT;
var axis: AxisDependency = leftAxisMinDist < rightAxisMinDist ? AxisDependency.LEFT : AxisDependency.RIGHT;
var detail : Highlight = this.getClosestHighlightByPixel(closestValues, x, y, axis, this.mChart.getMaxHighlightDistance());
var detail: Highlight = this.getClosestHighlightByPixel(
closestValues,
x,
y,
axis,
this.mChart.getMaxHighlightDistance()
);
return detail;
}
@ -103,17 +104,14 @@ export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataPr
* @param axis
* @return
*/
protected getMinimumDistance(closestValues : JArrayList<Highlight>, pos : number, axis : AxisDependency) : number {
protected getMinimumDistance(closestValues: JArrayList<Highlight>, pos: number, axis: AxisDependency): number {
var distance: number = Number.MAX_VALUE;
var distance : number = Number.MAX_VALUE;
for (var i : number = 0; i < closestValues.size(); i++) {
var high : Highlight = closestValues.get(i);
for (var i: number = 0; i < closestValues.size(); i++) {
var high: Highlight = closestValues.get(i);
if (high.getAxis() == axis) {
var tempDistance : number = Math.abs(this.getHighlightPos(high) - pos);
var tempDistance: number = Math.abs(this.getHighlightPos(high) - pos);
if (tempDistance < distance) {
distance = tempDistance;
}
@ -123,7 +121,7 @@ export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataPr
return distance;
}
protected getHighlightPos(h : Highlight) : number {
protected getHighlightPos(h: Highlight): number {
return h.getYPx();
}
@ -136,22 +134,18 @@ export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataPr
* @param y touch position
* @return
*/
protected getHighlightsAtXValue(xVal : number, x : number, y : number) : JArrayList<Highlight> {
protected getHighlightsAtXValue(xVal: number, x: number, y: number): JArrayList<Highlight> {
this.mHighlightBuffer.clear();
var data : BarLineScatterCandleBubbleData<IBarLineScatterCandleBubbleDataSet<EntryOhos>> = this.getData();
var data: BarLineScatterCandleBubbleData<IBarLineScatterCandleBubbleDataSet<EntryOhos>> = this.getData();
if (data == null)
return this.mHighlightBuffer;
if (data == null) return this.mHighlightBuffer;
for (var i : number = 0, dataSetCount = data.getDataSetCount(); i < dataSetCount; i++) {
var dataSet : IDataSet<EntryOhos> = data.getDataSetByIndex(i);
for (var i: number = 0, dataSetCount = data.getDataSetCount(); i < dataSetCount; i++) {
var dataSet: IDataSet<EntryOhos> = data.getDataSetByIndex(i);
// don't include DataSets that cannot be highlighted
if (!dataSet.isHighlightEnabled())
continue;
if (!dataSet.isHighlightEnabled()) continue;
this.mHighlightBuffer.addAll(this.buildHighlights(dataSet, i, xVal, Rounding.CLOSEST));
}
@ -168,33 +162,31 @@ export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataPr
* @param rounding
* @return
*/
protected buildHighlights(set : IDataSet<EntryOhos>, dataSetIndex : number, xVal : number, rounding : Rounding) : JArrayList<Highlight> {
var highlights : JArrayList<Highlight> = new JArrayList<Highlight>();
protected buildHighlights(
set: IDataSet<EntryOhos>,
dataSetIndex: number,
xVal: number,
rounding: Rounding
): JArrayList<Highlight> {
var highlights: JArrayList<Highlight> = new JArrayList<Highlight>();
//noinspection unchecked
var entries : JArrayList<EntryOhos> = set.getEntriesForXValue(xVal);
var entries: JArrayList<EntryOhos> = set.getEntriesForXValue(xVal);
if (entries.size() == 0) {
// Try to find closest x-value and take all entries for that x-value
var closest : EntryOhos = set.getEntryForXValue(xVal, Number.NaN, rounding);
if (closest != null)
{
var closest: EntryOhos = set.getEntryForXValue(xVal, Number.NaN, rounding);
if (closest != null) {
//noinspection unchecked
entries = set.getEntriesForXValue(closest.getX());
}
}
if (entries.size() == 0)
return highlights;
if (entries.size() == 0) return highlights;
for (let e of entries.dataSouce) {
var pixels : MPPointD = this.mChart.getTransformer(
set.getAxisDependency()).getPixelForValues(e.getX(), e.getY());
var pixels: MPPointD = this.mChart.getTransformer(set.getAxisDependency()).getPixelForValues(e.getX(), e.getY());
highlights.add(new Highlight(
e.getX(), e.getY(),
pixels.x, pixels.y,
dataSetIndex, set.getAxisDependency()));
highlights.add(new Highlight(e.getX(), e.getY(), pixels.x, pixels.y, dataSetIndex, set.getAxisDependency()));
}
return highlights;
@ -212,19 +204,21 @@ export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataPr
* @param minSelectionDistance
* @return
*/
public getClosestHighlightByPixel(closestValues : JArrayList<Highlight>, x : number, y : number,
axis : AxisDependency, minSelectionDistance : number) : Highlight {
public getClosestHighlightByPixel(
closestValues: JArrayList<Highlight>,
x: number,
y: number,
axis: AxisDependency,
minSelectionDistance: number
): Highlight {
var closest: Highlight = null;
var distance: number = minSelectionDistance;
var closest : Highlight = null;
var distance : number = minSelectionDistance;
for (var i : number = 0; i < closestValues.size(); i++) {
var high : Highlight = closestValues.get(i);
for (var i: number = 0; i < closestValues.size(); i++) {
var high: Highlight = closestValues.get(i);
if (axis == null || high.getAxis() == axis) {
var cDistance : number = this.getDistance(x, y, high.getXPx(), high.getYPx());
var cDistance: number = this.getDistance(x, y, high.getXPx(), high.getYPx());
if (cDistance < distance) {
closest = high;
@ -245,11 +239,11 @@ export default class ChartHighlighter<T extends BarLineScatterCandleBubbleDataPr
* @param y2
* @return
*/
protected getDistance(x1 : number, y1 : number, x2 : number, y2 : number) : number {
protected getDistance(x1: number, y1: number, x2: number, y2: number): number {
return Math.hypot(x1 - x2, y1 - y2);
}
protected getData() : BarLineScatterCandleBubbleData<IBarLineScatterCandleBubbleDataSet<EntryOhos>> {
protected getData(): BarLineScatterCandleBubbleData<IBarLineScatterCandleBubbleDataSet<EntryOhos>> {
return this.mChart.getData();
}
}
}

View File

@ -13,47 +13,46 @@
* limitations under the License.
*/
import {AxisDependency} from '../components/YAxis'
import { AxisDependency } from '../components/YAxis';
/**
* Contains information needed to determine the highlighted value.
*/
export default class Highlight {
/**
* the x-value of the highlighted value
*/
private mX:number = Number.NaN;
private mX: number = Number.NaN;
/**
* the y-value of the highlighted value
*/
private mY:number = Number.NaN;
private mY: number = Number.NaN;
/**
* the x-pixel of the highlight
*/
private mXPx:number;
private mXPx: number;
/**
* the y-pixel of the highlight
*/
private mYPx:number;
private mYPx: number;
/**
* the index of the data object - in case it refers to more than one
*/
private mDataIndex:number = -1;
private mDataIndex: number = -1;
/**
* the index of the dataset the highlighted value is in
*/
private mDataSetIndex:number;
private mDataSetIndex: number;
/**
* index which value of a stacked bar entry is highlighted, default -1
*/
private mStackIndex:number = -1;
private mStackIndex: number = -1;
/**
* the axis the highlighted value belongs to
@ -63,39 +62,47 @@ export default class Highlight {
/**
* the x-position (pixels) on which this highlight object was last drawn
*/
private mDrawX:number;
private mDrawX: number;
/**
* the y-position (pixels) on which this highlight object was last drawn
*/
private mDrawY:number;
private mDrawY: number;
constructor(x:number,y?:number,dataSetIndex?:number,dataIndex?:number,stackIndex?:number,xPx?:number,yPx?:number,axis?:AxisDependency){
this.mX = x;
if(y==null||y==undefined){
this.mY = Number.NaN
}else{
this.mY = y;
}
this.mDataSetIndex = dataSetIndex;
this.mStackIndex = stackIndex;
if (dataIndex==null||dataIndex==undefined){
this.mDataIndex = -1;
} else {
this.mDataIndex = dataIndex;
}
this.mXPx = xPx;
this.mYPx = yPx;
this.axis = axis;
constructor(
x: number,
y?: number,
dataSetIndex?: number,
dataIndex?: number,
stackIndex?: number,
xPx?: number,
yPx?: number,
axis?: AxisDependency
) {
this.mX = x;
if (y == null || y == undefined) {
this.mY = Number.NaN;
} else {
this.mY = y;
}
this.mDataSetIndex = dataSetIndex;
this.mStackIndex = stackIndex;
if (dataIndex == null || dataIndex == undefined) {
this.mDataIndex = -1;
} else {
this.mDataIndex = dataIndex;
}
this.mXPx = xPx;
this.mYPx = yPx;
this.axis = axis;
}
/**
* returns the x-value of the highlighted value
*
* @return
*/
public getX():number {
public getX(): number {
return this.mX;
}
@ -104,21 +111,21 @@ export default class Highlight {
*
* @return
*/
public getY():number {
public getY(): number {
return this.mY;
}
/**
* returns the x-position of the highlight in pixels
*/
public getXPx():number {
public getXPx(): number {
return this.mXPx;
}
/**
* returns the y-position of the highlight in pixels
*/
public getYPx():number {
public getYPx(): number {
return this.mYPx;
}
@ -127,11 +134,11 @@ export default class Highlight {
*
* @return
*/
public getDataIndex():number {
public getDataIndex(): number {
return this.mDataIndex;
}
public setDataIndex(mDataIndex:number):void {
public setDataIndex(mDataIndex: number): void {
this.mDataIndex = mDataIndex;
}
@ -140,7 +147,7 @@ export default class Highlight {
*
* @return
*/
public getDataSetIndex():number {
public getDataSetIndex(): number {
return this.mDataSetIndex;
}
@ -150,11 +157,11 @@ export default class Highlight {
*
* @return
*/
public getStackIndex():number {
public getStackIndex(): number {
return this.mStackIndex;
}
public isStacked():boolean {
public isStacked(): boolean {
return this.mStackIndex >= 0;
}
@ -163,7 +170,7 @@ export default class Highlight {
*
* @return
*/
public getAxis():AxisDependency {
public getAxis(): AxisDependency {
return this.axis;
}
@ -173,7 +180,7 @@ export default class Highlight {
* @param x
* @param y
*/
public setDraw(x:number, y:number):void {
public setDraw(x: number, y: number): void {
this.mDrawX = x;
this.mDrawY = y;
}
@ -183,7 +190,7 @@ export default class Highlight {
*
* @return
*/
public getDrawX():number {
public getDrawX(): number {
return this.mDrawX;
}
@ -192,7 +199,7 @@ export default class Highlight {
*
* @return
*/
public getDrawY():number {
public getDrawY(): number {
return this.mDrawY;
}
@ -203,21 +210,30 @@ export default class Highlight {
* @param h
* @return
*/
public equalTo(h:Highlight):boolean {
if (h == null)
return false;
public equalTo(h: Highlight): boolean {
if (h == null) return false;
else {
if (this.mDataSetIndex == h.mDataSetIndex && this.mX == h.mX
&& this.mStackIndex == h.mStackIndex && this.mDataIndex == h.mDataIndex)
return true;
else
return false;
if (
this.mDataSetIndex == h.mDataSetIndex &&
this.mX == h.mX &&
this.mStackIndex == h.mStackIndex &&
this.mDataIndex == h.mDataIndex
)
return true;
else return false;
}
}
public toString():String {
return "Highlight, x: " + this.mX + ", y: " + this.mY + ", dataSetIndex: " + this.mDataSetIndex
+ ", stackIndex (only stacked barentry): " + this.mStackIndex;
public toString(): String {
return (
'Highlight, x: ' +
this.mX +
', y: ' +
this.mY +
', dataSetIndex: ' +
this.mDataSetIndex +
', stackIndex (only stacked barentry): ' +
this.mStackIndex
);
}
}

View File

@ -13,11 +13,9 @@
* limitations under the License.
*/
import Highlight from './Highlight'
export default interface IHighlighter
{
import Highlight from './Highlight';
export default interface IHighlighter {
/**
* Returns a Highlight object corresponding to the given x- and y- touch positions in pixels.
*
@ -25,5 +23,5 @@ export default interface IHighlighter
* @param y
* @return
*/
getHighlight(x:number,y:number):Highlight ;
getHighlight(x: number, y: number): Highlight;
}

View File

@ -13,35 +13,31 @@
* limitations under the License.
*/
export default class Range {
export default class Range {
public myfrom: number;
public to: number;
public myfrom:number;
public to:number;
constructor( myfrom:number, to:number) {
constructor(myfrom: number, to: number) {
this.myfrom = myfrom;
this.to = to;
}
/**
* Returns true if this range contains (if the value is in between) the given value, false if not.
*
*
* @param value
* @return
*/
public contains( value:number):boolean {
if (value > this.myfrom && value <= this.to)
return true;
else
return false;
public contains(value: number): boolean {
if (value > this.myfrom && value <= this.to) return true;
else return false;
}
public isLarger(value:number):boolean {
public isLarger(value: number): boolean {
return value > this.to;
}
public isSmaller(value:number):boolean {
public isSmaller(value: number): boolean {
return value < this.myfrom;
}
}
}

View File

@ -13,15 +13,14 @@
* limitations under the License.
*/
import ChartInterface from '../dataprovider/ChartInterface'
import BarLineScatterCandleBubbleData from '../../data/BarLineScatterCandleBubbleData'
import IBarLineScatterCandleBubbleDataSet from '../datasets/IBarLineScatterCandleBubbleDataSet'
import EntryOhos from '../../data/EntryOhos'
import Transformer from '../../utils/Transformer'
import {AxisDependency} from '../../components/YAxis'
import ChartInterface from '../dataprovider/ChartInterface';
import BarLineScatterCandleBubbleData from '../../data/BarLineScatterCandleBubbleData';
import IBarLineScatterCandleBubbleDataSet from '../datasets/IBarLineScatterCandleBubbleDataSet';
import EntryOhos from '../../data/EntryOhos';
import Transformer from '../../utils/Transformer';
import { AxisDependency } from '../../components/YAxis';
export default interface BarLineScatterCandleBubbleDataProvider extends ChartInterface {
getTransformer(axis: AxisDependency): Transformer;
isInverted(axis: AxisDependency): boolean;

View File

@ -14,54 +14,53 @@
*/
import MyRect from '../../data/Rect';
import MPPointF from '../../utils/MPPointF'
import IValueFormatter from '../../formatter/IValueFormatter'
import ChartData from '../../data/ChartData'
import IDataSet from '../datasets/IDataSet'
import EntryOhos from '../../data/EntryOhos'
import MPPointF from '../../utils/MPPointF';
import IValueFormatter from '../../formatter/IValueFormatter';
import ChartData from '../../data/ChartData';
import IDataSet from '../datasets/IDataSet';
import EntryOhos from '../../data/EntryOhos';
/**
* Interface that provides everything there is to know about the dimensions,
* bounds, and range of the chart.
*/
export default interface ChartInterface {
/**
* Returns the minimum x value of the chart, regardless of zoom or translation.
*
* @return
*/
* Returns the minimum x value of the chart, regardless of zoom or translation.
*
* @return
*/
getXChartMin(): number;
/**
* Returns the maximum x value of the chart, regardless of zoom or translation.
*
* @return
*/
* Returns the maximum x value of the chart, regardless of zoom or translation.
*
* @return
*/
getXChartMax(): number;
getXRange(): number;
/**
* Returns the minimum y value of the chart, regardless of zoom or translation.
*
* @return
*/
* Returns the minimum y value of the chart, regardless of zoom or translation.
*
* @return
*/
getYChartMin(): number;
/**
* Returns the maximum y value of the chart, regardless of zoom or translation.
*
* @return
*/
* Returns the maximum y value of the chart, regardless of zoom or translation.
*
* @return
*/
getYChartMax(): number;
/**
* Returns the maximum distance in scren dp a touch can be away from an entry to cause it to get highlighted.
*
* @return
*/
getMaxHighlightDistance(): number;
* Returns the maximum distance in scren dp a touch can be away from an entry to cause it to get highlighted.
*
* @return
*/
getMaxHighlightDistance(): number;
getWidth(): number;
@ -71,7 +70,7 @@ export default interface ChartInterface {
getCenterOffsets();
getContentRect(): MyRect/*RectF*/;
getContentRect(): MyRect /*RectF*/;
getDefaultValueFormatter(): IValueFormatter;

View File

@ -13,12 +13,11 @@
* limitations under the License.
*/
import BarLineScatterCandleBubbleDataProvider from './BarLineScatterCandleBubbleDataProvider'
import YAxis,{AxisDependency} from '../../components/YAxis'
import BarLineScatterCandleBubbleDataProvider from './BarLineScatterCandleBubbleDataProvider';
import YAxis, { AxisDependency } from '../../components/YAxis';
import LineData from '../../data/LineData';
export default interface LineDataProvider extends BarLineScatterCandleBubbleDataProvider {
getLineData(): LineData;
getAxis(dependency: AxisDependency): YAxis;

View File

@ -15,21 +15,20 @@
import EntryOhos from '../../data/EntryOhos';
import Fill from '../../utils/Fill';
import {JArrayList} from '../../utils/JArrayList'
import IBarLineScatterCandleBubbleDataSet from './IBarLineScatterCandleBubbleDataSet'
import { JArrayList } from '../../utils/JArrayList';
import IBarLineScatterCandleBubbleDataSet from './IBarLineScatterCandleBubbleDataSet';
export default interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet<EntryOhos> {
getFills(): JArrayList<Fill>;
getFills() : JArrayList<Fill>;
getFill(index : number) : Fill;
getFill(index: number): Fill;
/**
* Returns true if this DataSet is stacked (stacksize > 1) or not.
*
* @return
*/
isStacked() : boolean;
isStacked(): boolean;
/**
* Returns the maximum number of bars that can be stacked upon another in
@ -37,7 +36,7 @@ export default interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet<
*
* @return
*/
getStackSize() : number;
getStackSize(): number;
/**
* Returns the color used for drawing the bar-shadows. The bar shadows is a
@ -45,7 +44,7 @@ export default interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet<
*
* @return
*/
getBarShadowColor() : number;
getBarShadowColor(): number;
/**
* Returns the width used for drawing borders around the bars.
@ -53,14 +52,14 @@ export default interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet<
*
* @return
*/
getBarBorderWidth() : number;
getBarBorderWidth(): number;
/**
* Returns the color drawing borders around the bars.
*
* @return
*/
getBarBorderColor() : number;
getBarBorderColor(): number;
/**
* Returns the alpha value (transparency) that is used for drawing the
@ -68,8 +67,7 @@ export default interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet<
*
* @return
*/
getHighLightAlpha() : number;
getHighLightAlpha(): number;
/**
* Returns the labels used for the different value-stacks in the legend.
@ -77,5 +75,5 @@ export default interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet<
*
* @return
*/
getStackLabels() : string[];
getStackLabels(): string[];
}

View File

@ -17,11 +17,10 @@ import EntryOhos from '../../data/EntryOhos';
import IDataSet from './IDataSet';
export default interface IBarLineScatterCandleBubbleDataSet<T extends EntryOhos> extends IDataSet<T> {
/**
* Returns the color that is used for drawing the highlight indicators.
*
* @return
*/
getHighLightColor() : number;
}
getHighLightColor(): number;
}

View File

@ -17,22 +17,21 @@ import EntryOhos from '../../data/EntryOhos';
import IBarLineScatterCandleBubbleDataSet from './IBarLineScatterCandleBubbleDataSet';
export default interface IBubbleDataSet extends IBarLineScatterCandleBubbleDataSet<EntryOhos> {
/**
* Sets the width of the circle that surrounds the bubble when highlighted,
* in dp.
*
* @param width
*/
setHighlightCircleWidth(width : number) : void;
setHighlightCircleWidth(width: number): void;
getMaxSize() : number;
getMaxSize(): number;
isNormalizeSizeEnabled() : boolean;
isNormalizeSizeEnabled(): boolean;
/**
* Returns the width of the highlight-circle that surrounds the bubble
* @return
* @return
*/
getHighlightCircleWidth() : number;
getHighlightCircleWidth(): number;
}

View File

@ -15,17 +15,16 @@
import EntryOhos from '../../data/EntryOhos';
import ILineScatterCandleRadarDataSet from './ILineScatterCandleRadarDataSet';
import {Style} from '../../data/Paint'
import { Style } from '../../data/Paint';
export default interface ICandleDataSet extends ILineScatterCandleRadarDataSet<EntryOhos> {
/**
* Returns the space that is left out on the left and right side of each
* candle.
*
* @return
*/
getBarSpace() : number;
getBarSpace(): number;
/**
* Returns whether the candle bars should show?
@ -35,61 +34,61 @@ export default interface ICandleDataSet extends ILineScatterCandleRadarDataSet<E
*
* @return
*/
getShowCandleBar() : boolean;
getShowCandleBar(): boolean;
/**
* Returns the width of the candle-shadow-line in pixels.
*
* @return
*/
getShadowWidth() : number;
getShadowWidth(): number;
/**
* Returns shadow color for all entries
*
* @return
*/
getShadowColor() : number;
getShadowColor(): number;
/**
* Returns the neutral color (for open == close)
*
* @return
*/
getNeutralColor() : number;
getNeutralColor(): number;
/**
* Returns the increasing color (for open < close).
*
* @return
*/
getIncreasingColor() : number;
getIncreasingColor(): number;
/**
* Returns the decreasing color (for open > close).
*
* @return
*/
getDecreasingColor() : number;
getDecreasingColor(): number;
/**
* Returns paint style when open < close
*
* @return
*/
getIncreasingPaintStyle() :Style;
getIncreasingPaintStyle(): Style;
/**
* Returns paint style when open > close
*
* @return
*/
getDecreasingPaintStyle() : Style;
getDecreasingPaintStyle(): Style;
/**
* Is the shadow color same as the candle color?
*
* @return
*/
getShadowColorSameAsCandle() : boolean;
getShadowColorSameAsCandle(): boolean;
}

View File

@ -14,16 +14,15 @@
*/
import { DashPathEffect } from '../../data/Paint';
import {LegendForm} from '../../components/Legend'
import {AxisDependency} from '../../components/YAxis'
import {Rounding} from '../../data/DataSet'
import EntryOhos from '../../data/EntryOhos'
import IValueFormatter from '../../formatter/IValueFormatter'
import MPPointF from '../../utils/MPPointF'
import {JArrayList} from '../../utils/JArrayList'
import { LegendForm } from '../../components/Legend';
import { AxisDependency } from '../../components/YAxis';
import { Rounding } from '../../data/DataSet';
import EntryOhos from '../../data/EntryOhos';
import IValueFormatter from '../../formatter/IValueFormatter';
import MPPointF from '../../utils/MPPointF';
import { JArrayList } from '../../utils/JArrayList';
export default interface IDataSet<T extends EntryOhos> {
/** ###### ###### DATA RELATED METHODS ###### ###### */
/**
@ -31,28 +30,28 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @return
*/
getYMin() : number;
getYMin(): number;
/**
* returns the maximum y-value this DataSet holds
*
* @return
*/
getYMax() : number;
getYMax(): number;
/**
* returns the minimum x-value this DataSet holds
*
* @return
*/
getXMin() : number;
getXMin(): number;
/**
* returns the maximum x-value this DataSet holds
*
* @return
*/
getXMax() : number;
getXMax(): number;
/**
* Returns the number of y-values this DataSet represents -> the size of the y-values array
@ -60,12 +59,12 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @return
*/
getEntryCount() : number;
getEntryCount(): number;
/**
* Calculates the minimum and maximum x and y values (mXMin, mXMax, mYMin, mYMax).
*/
calcMinMax() : void;
calcMinMax(): void;
/**
* Calculates the min and max y-values from the Entry closest to the given fromX to the Entry closest to the given toX value.
@ -74,7 +73,7 @@ export default interface IDataSet<T extends EntryOhos> {
* @param fromX
* @param toX
*/
calcMinMaxY(fromX : number, toX : number) : void;
calcMinMaxY(fromX: number, toX: number): void;
/**
* Returns the first Entry object found at the given x-value with binary
@ -89,10 +88,10 @@ export default interface IDataSet<T extends EntryOhos> {
* @param rounding determine whether to round up/down/closest
* if there is no Entry matching the provided x-value
* @return
*
*
*
*/
getEntryForXValue(xValue : number, closestToY : number, rounding?: Rounding) : T;
getEntryForXValue(xValue: number, closestToY: number, rounding?: Rounding): T;
/**
* Returns the first Entry object found at the given x-value with binary
@ -118,7 +117,7 @@ export default interface IDataSet<T extends EntryOhos> {
* @param xValue
* @return
*/
getEntriesForXValue(xValue : number):JArrayList<T> ;
getEntriesForXValue(xValue: number): JArrayList<T>;
/**
* Returns the Entry object found at the given index (NOT xIndex) in the values array.
@ -126,7 +125,7 @@ export default interface IDataSet<T extends EntryOhos> {
* @param index
* @return
*/
getEntryForIndex(index : number) : T;
getEntryForIndex(index: number): T;
/**
* Returns the first Entry index found at the given x-value with binary
@ -142,7 +141,7 @@ export default interface IDataSet<T extends EntryOhos> {
* if there is no Entry matching the provided x-value
* @return
*/
getEntryIndex(xValue : number, closestToY:number, rounding:Rounding) : number;
getEntryIndex(xValue: number, closestToY: number, rounding: Rounding): number;
/**
* Returns the position of the provided entry in the DataSets Entry array.
@ -151,8 +150,7 @@ export default interface IDataSet<T extends EntryOhos> {
* @param e
* @return
*/
getEntryIndexByEntry(e : T) : number;
getEntryIndexByEntry(e: T): number;
/**
* This method returns the actual
@ -163,7 +161,7 @@ export default interface IDataSet<T extends EntryOhos> {
* @param xIndex
* @return
*/
getIndexInEntries(xIndex : number) : number;
getIndexInEntries(xIndex: number): number;
/**
* Adds an Entry to the DataSet dynamically.
@ -173,8 +171,7 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param e
*/
addEntry(e : T) : boolean;
addEntry(e: T): boolean;
/**
* Adds an Entry to the DataSet dynamically.
@ -184,7 +181,7 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param e
*/
addEntryOrdered(e : T) : void;
addEntryOrdered(e: T): void;
/**
* Removes the first Entry (at index 0) of this DataSet from the entries array.
@ -192,7 +189,7 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @return
*/
removeFirst() : boolean;
removeFirst(): boolean;
/**
* Removes the last Entry (at index size-1) of this DataSet from the entries array.
@ -210,7 +207,7 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param e
*/
removeEntry(e : T) : boolean;
removeEntry(e: T): boolean;
/**
* Removes the Entry object closest to the given x-value from the DataSet.
@ -218,7 +215,7 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param xValue
*/
removeEntryByXValue(xValue : number) : boolean;
removeEntryByXValue(xValue: number): boolean;
/**
* Removes the Entry object at the given index in the values array from the DataSet.
@ -227,7 +224,7 @@ export default interface IDataSet<T extends EntryOhos> {
* @param index
* @return
*/
removeEntryByIndex(index : number) : boolean;
removeEntryByIndex(index: number): boolean;
/**
* Checks if this DataSet contains the specified Entry. Returns true if so,
@ -237,13 +234,12 @@ export default interface IDataSet<T extends EntryOhos> {
* @param entry
* @return
*/
contains(entry : T) : boolean;
contains(entry: T): boolean;
/**
* Removes all values from this DataSet and does all necessary recalculations.
*/
clear() : void;
clear(): void;
/** ###### ###### STYLING RELATED (& OTHER) METHODS ###### ###### */
@ -252,14 +248,14 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @return
*/
getLabel():string;
getLabel(): string;
/**
* Sets the label string that describes the DataSet.
*
* @param label
*/
setLabel( label:string) : void;
setLabel(label: string): void;
/**
* Returns the axis this DataSet should be plotted against.
@ -274,14 +270,14 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param dependency
*/
setAxisDependency( dependency:AxisDependency) : void;
setAxisDependency(dependency: AxisDependency): void;
/**
* returns all the colors that are set for this DataSet
*
* @return
*/
getColors():JArrayList<Number>;
getColors(): JArrayList<Number>;
/**
* Returns the first color (index 0) of the colors-array this DataSet
@ -289,7 +285,7 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @return
*/
getColor() : number;
getColor(): number;
/**
* Returns the color at the given index of the DataSet's color array.
@ -298,14 +294,14 @@ export default interface IDataSet<T extends EntryOhos> {
* @param index
* @return
*/
getColor(index : number) : number;
getColor(index: number): number;
/**
* returns true if highlighting of values is enabled, false if not
*
* @return
*/
isHighlightEnabled() : boolean;
isHighlightEnabled(): boolean;
/**
* If set to true, value highlighting is enabled which means that values can
@ -313,7 +309,7 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param enabled
*/
setHighlightEnabled(enabled : boolean) : void;
setHighlightEnabled(enabled: boolean): void;
/**
* Sets the formatter to be used for drawing the values inside the chart. If
@ -324,56 +320,56 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param f
*/
setValueFormatter(f:IValueFormatter) : void;
setValueFormatter(f: IValueFormatter): void;
/**
* Returns the formatter used for drawing the values inside the chart.
*
* @return
*/
getValueFormatter() : IValueFormatter;
getValueFormatter(): IValueFormatter;
/**
* Returns true if the valueFormatter object of this DataSet is null.
*
* @return
*/
needsFormatter() : boolean;
needsFormatter(): boolean;
/**
* Sets the color the value-labels of this DataSet should have.
*
* @param color
*/
setValueTextColor(color : number) : void;
setValueTextColor(color: number): void;
/**
* Sets a list of colors to be used as the colors for the drawn values.
*
* @param colors
*/
setValueTextColors(colors:JArrayList<Number> ) : void;
setValueTextColors(colors: JArrayList<Number>): void;
/**
* Sets a Typeface for the value-labels of this DataSet.
*
* @param tf
*/
setValueTypeface( tf:FontWeight) : void;
setValueTypeface(tf: FontWeight): void;
/**
* Sets the text-size of the value-labels of this DataSet in dp.
*
* @param size
*/
setValueTextSize(size : number) : void;
setValueTextSize(size: number): void;
/**
* Returns only the first color of all colors that are set to be used for the values.
*
* @return
*/
getValueTextColor() : number;
getValueTextColor(): number;
/**
* Returns the color at the specified index that is used for drawing the values inside the chart.
@ -382,49 +378,49 @@ export default interface IDataSet<T extends EntryOhos> {
* @param index
* @return
*/
getValueTextColor(index : number) : number;
getValueTextColor(index: number): number;
/**
* Returns the typeface that is used for drawing the values inside the chart
*
* @return
*/
getValueTypeface():FontWeight;
getValueTypeface(): FontWeight;
/**
* Returns the text size that is used for drawing the values inside the chart
*
* @return
*/
getValueTextSize() : number;
getValueTextSize(): number;
/**
* The form to draw for this dataset in the legend.
* <p/>
* Return `DEFAULT` to use the default legend form.
*/
getForm():LegendForm;
getForm(): LegendForm;
/**
* The form size to draw for this dataset in the legend.
* <p/>
* Return `Float.NaN` to use the default legend form size.
*/
getFormSize() : number;
getFormSize(): number;
/**
* The line width for drawing the form of this dataset in the legend
* <p/>
* Return `Float.NaN` to use the default legend form line width.
*/
getFormLineWidth() : number;
getFormLineWidth(): number;
/**
* The line dash path effect used for shapes that consist of lines.
* <p/>
* Return `null` to use the default legend form line dash effect.
*/
getFormLineDashEffect() : DashPathEffect/*DashPathEffect*/;
getFormLineDashEffect(): DashPathEffect /*DashPathEffect*/;
/**
* set this to true to draw y-values on the chart.
@ -433,14 +429,14 @@ export default interface IDataSet<T extends EntryOhos> {
* if this is enabled
* @param enabled
*/
setDrawValues(enabled : boolean) : void;
setDrawValues(enabled: boolean): void;
/**
* Returns true if y-value drawing is enabled, false if not
*
* @return
*/
isDrawValuesEnabled() : boolean;
isDrawValuesEnabled(): boolean;
/**
* Set this to true to draw y-icons on the chart.
@ -450,14 +446,14 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param enabled
*/
setDrawIcons(enabled : boolean) : void;
setDrawIcons(enabled: boolean): void;
/**
* Returns true if y-icon drawing is enabled, false if not
*
* @return
*/
isDrawIconsEnabled() : boolean;
isDrawIconsEnabled(): boolean;
/**
* Offset of icons drawn on the chart.
@ -467,12 +463,12 @@ export default interface IDataSet<T extends EntryOhos> {
* For Pie and Radar chart it will be (y offset, distance from center offset); so if you want icon to be rendered under value, you should increase X component of CGPoint, and if you want icon to be rendered closet to center, you should decrease height component of CGPoint.
* @param offset
*/
setIconsOffset( offset:MPPointF) : void;
setIconsOffset(offset: MPPointF): void;
/**
* Get the offset for drawing icons.
*/
getIconsOffset():MPPointF;
getIconsOffset(): MPPointF;
/**
* Set the visibility of this DataSet. If not visible, the DataSet will not
@ -480,7 +476,7 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @param visible
*/
setVisible(visible : boolean) : void;
setVisible(visible: boolean): void;
/**
* Returns true if this DataSet is visible inside the chart, or false if it
@ -488,5 +484,5 @@ export default interface IDataSet<T extends EntryOhos> {
*
* @return
*/
isVisible() : boolean;
isVisible(): boolean;
}

View File

@ -14,11 +14,11 @@
*/
import EntryOhos from '../../data/EntryOhos';
import {Mode} from '../../data/LineDataSet';
import { Mode } from '../../data/LineDataSet';
import IFillFormatter from '../../formatter/IFillFormatter';
import ILineRadarDataSet from './ILineRadarDataSet';
import {DashPathEffect} from '../../data/Paint'
import { FillStyle } from '../../data/LineDataSet'
import { DashPathEffect } from '../../data/Paint';
import { FillStyle } from '../../data/LineDataSet';
export default interface ILineDataSet extends ILineRadarDataSet<EntryOhos> {
/**
@ -26,7 +26,7 @@ export default interface ILineDataSet extends ILineRadarDataSet<EntryOhos> {
*
* @return
*/
getMode() : Mode;
getMode(): Mode;
/**
* Returns the intensity of the cubic lines (the effect intensity).
@ -34,17 +34,17 @@ export default interface ILineDataSet extends ILineRadarDataSet<EntryOhos> {
*
* @return
*/
getCubicIntensity() : number;
getCubicIntensity(): number;
/**
* Returns the size of the drawn circles.
*/
getCircleRadius() : number;
getCircleRadius(): number;
/**
* Returns the hole radius of the drawn circles.
*/
getCircleHoleRadius() : number;
getCircleHoleRadius(): number;
/**
* Returns the color at the given index of the DataSet's circle-color array.
@ -53,44 +53,44 @@ export default interface ILineDataSet extends ILineRadarDataSet<EntryOhos> {
* @param index
* @return
*/
getCircleColorByIndex(index : number) : number;
getCircleColorByIndex(index: number): number;
getCircleColor() : number;
getCircleColor(): number;
/**
* Returns the number of colors in this DataSet's circle-color array.
*
* @return
*/
getCircleColorCount() : number;
getCircleColorCount(): number;
/**
* Returns true if drawing circles for this DataSet is enabled, false if not
*
* @return
*/
isDrawCirclesEnabled() : boolean;
isDrawCirclesEnabled(): boolean;
/**
* Returns the color of the inner circle (the circle-hole).
*
* @return
*/
getCircleHoleColor() : number;
getCircleHoleColor(): number;
/**
* Returns true if drawing the circle-holes is enabled, false if not.
*
* @return
*/
isDrawCircleHoleEnabled() : boolean;
isDrawCircleHoleEnabled(): boolean;
/**
* Returns the DashPathEffect that is used for drawing the lines.
*
* @return
*/
getDashPathEffect() : DashPathEffect;
getDashPathEffect(): DashPathEffect;
/**
* Returns true if the dashed-line effect is enabled, false if not.
@ -98,14 +98,14 @@ export default interface ILineDataSet extends ILineRadarDataSet<EntryOhos> {
*
* @return
*/
isDashedLineEnabled() : boolean;
isDashedLineEnabled(): boolean;
/**
* Returns the IFillFormatter that is set for this DataSet.
*
* @return
*/
getFillFormatter() : IFillFormatter;
getFillFormatter(): IFillFormatter;
getFillStyle(): FillStyle;
}
}

View File

@ -15,23 +15,22 @@
import EntryOhos from '../../data/EntryOhos';
import ILineScatterCandleRadarDataSet from './ILineScatterCandleRadarDataSet';
import {ColorStop} from '../../data/LineDataSet';
import { ColorStop } from '../../data/LineDataSet';
export default interface ILineRadarDataSet<T extends EntryOhos> extends ILineScatterCandleRadarDataSet<T> {
/**
* Returns the color that is used for filling the line surface area.
*
* @return
*/
getFillColor() : number;
getFillColor(): number;
/**
* Returns the drawable used for filling the area below the line.
*
* @return
*/
getFillDrawable() :Object/* Drawable*/;
getFillDrawable(): Object /* Drawable*/;
/**
* Returns the alpha value that is used for filling the line surface,
@ -39,21 +38,21 @@ export default interface ILineRadarDataSet<T extends EntryOhos> extends ILineSca
*
* @return
*/
getFillAlpha() : number;
getFillAlpha(): number;
/**
* Returns the stroke-width of the drawn line
*
* @return
*/
getLineWidth() : number;
getLineWidth(): number;
/**
* Returns true if filled drawing is enabled, false if not
*
* @return
*/
isDrawFilledEnabled() : boolean;
isDrawFilledEnabled(): boolean;
/**
* Set to true if the DataSet should be drawn filled (surface), and not just
@ -63,7 +62,7 @@ export default interface ILineRadarDataSet<T extends EntryOhos> extends ILineSca
*
* @param enabled
*/
setDrawFilled(enabled : boolean) : void;
setDrawFilled(enabled: boolean): void;
getGradientFillColor(): Array<ColorStop>;

View File

@ -17,29 +17,29 @@ import { DashPathEffect } from '../../data/Paint';
import EntryOhos from '../../data/EntryOhos';
import IBarLineScatterCandleBubbleDataSet from './IBarLineScatterCandleBubbleDataSet';
export default interface ILineScatterCandleRadarDataSet<T extends EntryOhos> extends IBarLineScatterCandleBubbleDataSet<T> {
export default interface ILineScatterCandleRadarDataSet<T extends EntryOhos>
extends IBarLineScatterCandleBubbleDataSet<T> {
/**
* Returns true if vertical highlight indicator lines are enabled (drawn)
* @return
*/
isVerticalHighlightIndicatorEnabled(): boolean;
/**
* Returns true if vertical highlight indicator lines are enabled (drawn)
* @return
*/
isVerticalHighlightIndicatorEnabled() : boolean;
/**
* Returns true if vertical highlight indicator lines are enabled (drawn)
* @return
*/
isHorizontalHighlightIndicatorEnabled() : boolean;
isHorizontalHighlightIndicatorEnabled(): boolean;
/**
* Returns the line-width in which highlight lines are to be drawn.
* @return
*/
getHighlightLineWidth() : number;
getHighlightLineWidth(): number;
/**
* Returns the DashPathEffect that is used for highlighting.
* @return
*/
getDashPathEffectHighlight() : DashPathEffect;
getDashPathEffectHighlight(): DashPathEffect;
}

View File

@ -17,25 +17,23 @@ import RadarEntry from '../../data/RadarEntry';
import ILineRadarDataSet from './ILineRadarDataSet';
export default interface IRadarDataSet extends ILineRadarDataSet<RadarEntry> {
// flag indicating whether highlight circle should be drawn or not
isDrawHighlightCircleEnabled() : boolean;
isDrawHighlightCircleEnabled(): boolean;
// Sets whether highlight circle should be drawn or not
setDrawHighlightCircleEnabled(enabled : boolean) : void;
setDrawHighlightCircleEnabled(enabled: boolean): void;
getHighlightCircleFillColor() : number;
getHighlightCircleFillColor(): number;
// The stroke color for highlight circle.
// If Utils.COLOR_NONE, the color of the dataset is taken.
getHighlightCircleStrokeColor() : number;
getHighlightCircleStrokeColor(): number;
getHighlightCircleStrokeAlpha() : number;
getHighlightCircleStrokeAlpha(): number;
getHighlightCircleInnerRadius() : number;
getHighlightCircleInnerRadius(): number;
getHighlightCircleOuterRadius() : number;
getHighlightCircleStrokeWidth() : number;
getHighlightCircleOuterRadius(): number;
getHighlightCircleStrokeWidth(): number;
}

View File

@ -18,32 +18,31 @@ import ILineScatterCandleRadarDataSet from './ILineScatterCandleRadarDataSet';
import IShapeRenderer from '../../renderer/scatter/IShapeRenderer';
export default interface IScatterDataSet extends ILineScatterCandleRadarDataSet<EntryOhos> {
/**
* Returns the currently set scatter shape size
*
* @return
*/
getScatterShapeSize() : number;
getScatterShapeSize(): number;
/**
* Returns radius of the hole in the shape
*
* @return
*/
getScatterShapeHoleRadius() : number;
getScatterShapeHoleRadius(): number;
/**
* Returns the color for the hole in the shape
*
* @return
*/
getScatterShapeHoleColor() : number;
getScatterShapeHoleColor(): number;
/**
* Returns the IShapeRenderer responsible for rendering this DataSet.
*
* @return
*/
getShapeRenderer() : IShapeRenderer;
getShapeRenderer(): IShapeRenderer;
}

View File

@ -16,7 +16,7 @@
import Transformer from '../utils/Transformer';
import ViewPortHandler from '../utils/ViewPortHandler';
import Runnable from '../data/Runnable';
import Chart from '../charts/Chart'
import Chart from '../charts/Chart';
/**
* Runnable that is used for viewport modifications since they cannot be
@ -24,35 +24,32 @@ import Chart from '../charts/Chart'
* modifications until the onSizeChanged(...) method of the chart-view is called.
* This is especially important if viewport modifying methods are called on the chart
* directly after initialization.
*
*
* @author Philipp Jahoda
*/
export default abstract class ViewPortJob extends Runnable {
protected pts: number[] = new Array(2);
protected pts:number[] = new Array(2);
protected mViewPortHandler: ViewPortHandler;
protected xValue: number = 0;
protected yValue: number = 0;
protected mTrans: Transformer;
protected view: Chart<any>;
protected mViewPortHandler:ViewPortHandler;
protected xValue:number = 0;
protected yValue:number = 0;
protected mTrans:Transformer;
protected view:Chart<any>;
constructor(viewPortHandler:ViewPortHandler, xValue:number, yValue:number,
trans:Transformer, v:Chart<any>) {
super(null,null);
constructor(viewPortHandler: ViewPortHandler, xValue: number, yValue: number, trans: Transformer, v: Chart<any>) {
super(null, null);
this.mViewPortHandler = viewPortHandler;
this.xValue = xValue;
this.yValue = yValue;
this.mTrans = trans;
this.view = v;
}
public getXValue():number{
public getXValue(): number {
return this.xValue;
}
public getYValue():number {
public getYValue(): number {
return this.yValue;
}
}

View File

@ -14,26 +14,33 @@
*/
import Highlight from '../highlight/Highlight';
import Chart from '../charts/Chart'
import OnChartGestureListener from './OnChartGestureListener'
import Chart from '../charts/Chart';
import OnChartGestureListener from './OnChartGestureListener';
export enum ChartGesture {
NONE, DRAG, X_ZOOM, Y_ZOOM, PINCH_ZOOM, ROTATE, SINGLE_TAP, DOUBLE_TAP, LONG_PRESS, FLING
NONE,
DRAG,
X_ZOOM,
Y_ZOOM,
PINCH_ZOOM,
ROTATE,
SINGLE_TAP,
DOUBLE_TAP,
LONG_PRESS,
FLING,
}
/**
* Created by philipp on 12/06/15.
*/
// @ts-ignore
export default abstract class ChartTouchListener <T extends Chart> {
/**
* the last touch gesture that has been performed
**/
export default abstract class ChartTouchListener<T extends Chart> {
/**
* the last touch gesture that has been performed
**/
protected mLastGesture: ChartGesture = ChartGesture.NONE;
// states
// states
protected static NONE: number = 0;
protected static DRAG: number = 1;
protected static X_ZOOM: number = 2;
@ -42,91 +49,85 @@ export default abstract class ChartTouchListener <T extends Chart> {
protected static POST_ZOOM: number = 5;
protected static ROTATE: number = 6;
/**
* integer field that holds the current touch-state
*/
/**
* integer field that holds the current touch-state
*/
protected mTouchMode: number = ChartTouchListener.NONE;
/**
* the last highlighted object (via touch)
*/
/**
* the last highlighted object (via touch)
*/
protected mLastHighlighted: Highlight;
/**
* the gesturedetector used for detecting taps and longpresses, ...
*/
// protected mGestureDetector:GestureDetector;
/**
* the gesturedetector used for detecting taps and longpresses, ...
*/
// protected mGestureDetector:GestureDetector;
/**
* the chart the listener represents
*/
/**
* the chart the listener represents
*/
protected mChart: T;
constructor(chart: T) {
this.mChart = chart;
}
/**
* Calls the OnChartGestureListener to do the start callback
*
* @param me
*/
/**
* Calls the OnChartGestureListener to do the start callback
*
* @param me
*/
public startAction(me: TouchEvent) {
var l: OnChartGestureListener = this.mChart.getOnChartGestureListener();
if (l != null)
l.onChartGestureStart(me, this.mLastGesture);
if (l != null) l.onChartGestureStart(me, this.mLastGesture);
}
/**
* Calls the OnChartGestureListener to do the end callback
*
* @param me
*/
/**
* Calls the OnChartGestureListener to do the end callback
*
* @param me
*/
public endAction(me: TouchEvent) {
var l: OnChartGestureListener = this.mChart.getOnChartGestureListener();
if (l != null)
l.onChartGestureEnd(me, this.mLastGesture);
if (l != null) l.onChartGestureEnd(me, this.mLastGesture);
}
/**
* Sets the last value that was highlighted via touch.
*
* @param high
*/
/**
* Sets the last value that was highlighted via touch.
*
* @param high
*/
public setLastHighlighted(high: Highlight) {
this.mLastHighlighted = high;
}
/**
* returns the touch mode the listener is currently in
*
* @return
*/
/**
* returns the touch mode the listener is currently in
*
* @return
*/
public getTouchMode(): number {
return this.mTouchMode;
}
/**
* Returns the last gesture that has been performed on the chart.
*
* @return
*/
/**
* Returns the last gesture that has been performed on the chart.
*
* @return
*/
public getLastGesture(): ChartGesture {
return this.mLastGesture;
}
/**
* Perform a highlight operation.
*
* @param e
*/
/**
* Perform a highlight operation.
*
* @param e
*/
protected performHighlight(h: Highlight, e: TouchEvent) {
if (h == null || h == this.mLastHighlighted) {
this.mChart.highlightValue(null, true);
this.mLastHighlighted = null;
@ -135,15 +136,15 @@ export default abstract class ChartTouchListener <T extends Chart> {
this.mLastHighlighted = h;
}
}
/**
* returns the distance between two points
*
* @param eventX
* @param startX
* @param eventY
* @param startY
* @return
*/
/**
* returns the distance between two points
*
* @param eventX
* @param startX
* @param eventY
* @param startY
* @return
*/
protected static distance(eventX: number, startX: number, eventY: number, startY: number): number {
let dx: number = eventX - startX;
let dy: number = eventY - startY;

View File

@ -13,76 +13,75 @@
* limitations under the License.
*/
import ChartTouchListener, {ChartGesture} from './ChartTouchListener'
import ChartTouchListener, { ChartGesture } from './ChartTouchListener';
/**
* Listener for callbacks when doing gestures on the chart.
*
* @author Philipp Jahoda
*/
export default interface OnChartGestureListener {
/**
* Callbacks when a touch-gesture has started on the chart (ACTION_DOWN)
*
* @param me
* @param lastPerformedGesture
*/
* Callbacks when a touch-gesture has started on the chart (ACTION_DOWN)
*
* @param me
* @param lastPerformedGesture
*/
onChartGestureStart(me: TouchEvent, lastPerformedGesture: ChartGesture);
/**
* Callbacks when a touch-gesture has ended on the chart (ACTION_UP, ACTION_CANCEL)
*
* @param me
* @param lastPerformedGesture
*/
* Callbacks when a touch-gesture has ended on the chart (ACTION_UP, ACTION_CANCEL)
*
* @param me
* @param lastPerformedGesture
*/
onChartGestureEnd(me: TouchEvent, lastPerformedGesture: ChartGesture);
/**
* Callbacks when the chart is longpressed.
*
* @param me
*/
* Callbacks when the chart is longpressed.
*
* @param me
*/
onChartLongPressed(me: TouchEvent);
/**
* Callbacks when the chart is double-tapped.
*
* @param me
*/
* Callbacks when the chart is double-tapped.
*
* @param me
*/
onChartDoubleTapped(me: TouchEvent);
/**
* Callbacks when the chart is single-tapped.
*
* @param me
*/
* Callbacks when the chart is single-tapped.
*
* @param me
*/
onChartSingleTapped(me: TouchEvent);
/**
* Callbacks then a fling gesture is made on the chart.
*
* @param me1
* @param me2
* @param velocityX
* @param velocityY
*/
* Callbacks then a fling gesture is made on the chart.
*
* @param me1
* @param me2
* @param velocityX
* @param velocityY
*/
onChartFling(me1: TouchEvent, me2: TouchEvent, velocityX: number, velocityY: number);
/**
* Callbacks when the chart is scaled / zoomed via pinch zoom / double-tap gesture.
*
* @param me
* @param scaleX scalefactor on the x-axis
* @param scaleY scalefactor on the y-axis
*/
* Callbacks when the chart is scaled / zoomed via pinch zoom / double-tap gesture.
*
* @param me
* @param scaleX scalefactor on the x-axis
* @param scaleY scalefactor on the y-axis
*/
onChartScale(me: TouchEvent, scaleX: number, scaleY: number);
/**
* Callbacks when the chart is moved / translated via drag gesture.
*
* @param me
* @param dX translation distance on the x-axis
* @param dY translation distance on the y-axis
*/
* Callbacks when the chart is moved / translated via drag gesture.
*
* @param me
* @param dX translation distance on the x-axis
* @param dY translation distance on the y-axis
*/
onChartTranslate(me: TouchEvent, dX: number, dY: number);
}

View File

@ -22,18 +22,17 @@ import EntryOhos from '../data/EntryOhos';
* @author Philipp Jahoda
*/
export default interface OnChartValueSelectedListener {
/**
* Called when a value has been selected inside the chart.
*
* @param e The selected Entry
* @param h The corresponding highlight object that contains information
* about the highlighted position such as dataSetIndex, ...
*/
* Called when a value has been selected inside the chart.
*
* @param e The selected Entry
* @param h The corresponding highlight object that contains information
* about the highlighted position such as dataSetIndex, ...
*/
onValueSelected(e: EntryOhos, h: Highlight);
/**
* Called when nothing has been selected or an "un-select" has been made.
*/
* Called when nothing has been selected or an "un-select" has been made.
*/
onNothingSelected();
}

View File

@ -13,48 +13,47 @@
* limitations under the License.
*/
import AxisBase from '../components/AxisBase'
import Renderer from '../renderer/Renderer'
import Paint, {Style, LinePaint, TextPaint,PathPaint} from '../data/Paint'
import Utils from '../utils/Utils'
import Transformer from '../utils/Transformer'
import ViewPortHandler from '../utils/ViewPortHandler'
import MPPointD from '../utils/MPPointD'
import AxisBase from '../components/AxisBase';
import Renderer from '../renderer/Renderer';
import Paint, { Style, LinePaint, TextPaint, PathPaint } from '../data/Paint';
import Utils from '../utils/Utils';
import Transformer from '../utils/Transformer';
import ViewPortHandler from '../utils/ViewPortHandler';
import MPPointD from '../utils/MPPointD';
/**
* Baseclass of all axis renderers.
*
*/
export default abstract class AxisRenderer extends Renderer {
/** base axis this axis renderer works with */
/** base axis this axis renderer works with */
protected mAxis: AxisBase;
/** transformer to transform values to screen pixels and return */
/** transformer to transform values to screen pixels and return */
protected mTrans: Transformer;
/**
/**
* paint object for the grid lines
*/
protected mGridPaint: Paint;
/**
/**
* paint for the x-label values
*/
protected mAxisLabelPaint: Paint;
/**
/**
* paint for the line surrounding the chart
*/
protected mAxisLinePaint: Paint;
/**
/**
* paint used for the limit lines
*/
protected mLimitLinePaint: Paint;
constructor(viewPortHandler: ViewPortHandler, trans: Transformer, axis: AxisBase) {
super(viewPortHandler)
super(viewPortHandler);
this.mTrans = trans;
this.mAxis = axis;
@ -65,29 +64,28 @@ export default abstract class AxisRenderer extends Renderer {
this.mGridPaint.setColor(Color.Gray);
this.mGridPaint.setStrokeWidth(1);
this.mGridPaint.setStyle(Style.STROKE);
this.mGridPaint.setAlpha(90 / 255)
this.mGridPaint.setAlpha(90 / 255);
this.mAxisLinePaint = new LinePaint();
this.mAxisLinePaint.setColor(Color.Black)
this.mAxisLinePaint.setStrokeWidth(1)
this.mAxisLinePaint.setStyle(Style.STROKE)
this.mAxisLinePaint.setColor(Color.Black);
this.mAxisLinePaint.setStrokeWidth(1);
this.mAxisLinePaint.setStyle(Style.STROKE);
this.mLimitLinePaint = new PathPaint();
this.mLimitLinePaint.setStyle(Style.STROKE)
this.mLimitLinePaint.setStyle(Style.STROKE);
}
}
/**
/**
* Returns the Paint object used for drawing the axis (labels).
*
* @return
*/
public getPaintAxisLabels(): Paint{
public getPaintAxisLabels(): Paint {
return this.mAxisLabelPaint;
}
/**
/**
* Returns the Paint object that is used for drawing the grid-lines of the
* axis.
*
@ -97,7 +95,7 @@ export default abstract class AxisRenderer extends Renderer {
return this.mGridPaint;
}
/**
/**
* Returns the Paint object that is used for drawing the axis-line that goes
* alongside the axis.
*
@ -107,37 +105,42 @@ export default abstract class AxisRenderer extends Renderer {
return this.mAxisLinePaint;
}
/**
* Returns the Transformer object used for transforming the axis values.
*
* @return
*/
/**
* Returns the Transformer object used for transforming the axis values.
*
* @return
*/
public getTransformer(): Transformer {
return this.mTrans;
}
/**
* Computes the axis values.
*
* @param min - the minimum value in the data object for this axis
* @param max - the maximum value in the data object for this axis
*/
/**
* Computes the axis values.
*
* @param min - the minimum value in the data object for this axis
* @param max - the maximum value in the data object for this axis
*/
public computeAxis(min: number, max: number, inverted: boolean) {
// calculate the starting and entry point of the y-labels (depending on
// zoom / contentrect bounds)
if (this.mViewPortHandler != null && this.mViewPortHandler.contentWidth() > 10 && !this.mViewPortHandler.isFullyZoomedOutY()) {
var p1: MPPointD = this.mTrans.getValuesByTouchPoint(this.mViewPortHandler.contentLeft(), this.mViewPortHandler.contentTop());
var p2: MPPointD = this.mTrans.getValuesByTouchPoint(this.mViewPortHandler.contentLeft(), this.mViewPortHandler.contentBottom());
if (
this.mViewPortHandler != null &&
this.mViewPortHandler.contentWidth() > 10 &&
!this.mViewPortHandler.isFullyZoomedOutY()
) {
var p1: MPPointD = this.mTrans.getValuesByTouchPoint(
this.mViewPortHandler.contentLeft(),
this.mViewPortHandler.contentTop()
);
var p2: MPPointD = this.mTrans.getValuesByTouchPoint(
this.mViewPortHandler.contentLeft(),
this.mViewPortHandler.contentBottom()
);
if (!inverted) {
min = p2.y;
max = p1.y;
} else {
min = p1.y;
max = p2.y;
}
@ -149,13 +152,12 @@ export default abstract class AxisRenderer extends Renderer {
this.computeAxisValues(min, max);
}
/**
/**
* Sets up the axis values. Computes the desired number of labels between the two given extremes.
*
* @return
*/
protected computeAxisValues(min: number, max: number) {
var yMin = min;
var yMax = max;
@ -180,21 +182,17 @@ export default abstract class AxisRenderer extends Renderer {
// Normalize interval
var intervalMagnitude = Utils.roundToNextSignificant(Math.pow(10, Math.floor(Math.log10(interval))));
var intervalSigDigit = Math.floor((interval / intervalMagnitude));
var intervalSigDigit = Math.floor(interval / intervalMagnitude);
if (intervalSigDigit > 5) {
// Use one order of magnitude higher, to avoid intervals like 0.9 or 90
// if it's 0.0 after floor(), we use the old value
interval = Math.floor(10.0 * intervalMagnitude) == 0.0
? interval
: Math.floor(10.0 * intervalMagnitude);
interval = Math.floor(10.0 * intervalMagnitude) == 0.0 ? interval : Math.floor(10.0 * intervalMagnitude);
}
var n = this.mAxis.isCenterAxisLabelsEnabled() ? 1 : 0;
// force label count
if (this.mAxis.isForceLabelsEnabled()) {
interval = range / (labelCount - 1);
this.mAxis.mEntryCount = labelCount;
@ -214,7 +212,6 @@ export default abstract class AxisRenderer extends Renderer {
// no forced count
} else {
var first = interval == 0.0 ? 0.0 : Math.ceil(yMin / interval) * interval;
if (this.mAxis.isCenterAxisLabelsEnabled()) {
first -= interval;
@ -229,8 +226,7 @@ export default abstract class AxisRenderer extends Renderer {
for (f = first; f <= last; f += interval) {
++n;
}
}
else if (last == first && n == 0) {
} else if (last == first && n == 0) {
n = 1;
}
@ -242,8 +238,8 @@ export default abstract class AxisRenderer extends Renderer {
}
for (f = first, i = 0; i < n; f += interval, ++i) {
if (f == 0.0) // Fix for negative zero case (Where value == -0.0, and 0.0 == -0.0)
if (f == 0.0)
// Fix for negative zero case (Where value == -0.0, and 0.0 == -0.0)
f = 0.0;
this.mAxis.mEntries[i] = f;
@ -258,7 +254,6 @@ export default abstract class AxisRenderer extends Renderer {
}
if (this.mAxis.isCenterAxisLabelsEnabled()) {
if (this.mAxis.mCenteredEntries.length < n) {
this.mAxis.mCenteredEntries = new Array<number>(n);
}
@ -271,28 +266,28 @@ export default abstract class AxisRenderer extends Renderer {
}
}
/**
/**
* Draws the axis labels to the screen.
*
* @param c
*/
public abstract renderAxisLabels(c: Paint[]);
/**
/**
* Draws the grid lines belonging to the axis.
*
* @param c
*/
public abstract renderGridLines(c: Paint[]);
/**
/**
* Draws the line that goes alongside the axis.
*
* @param c
*/
public abstract renderAxisLine(c: Paint[]);
/**
/**
* Draws the LimitLines associated with this axis to the screen.
*
* @param c

View File

@ -14,45 +14,48 @@
*/
import MPPointD from '../utils/MPPointD';
import {XAxis} from '../components/XAxis';
import { XAxis } from '../components/XAxis';
import EntryOhos from '../data/EntryOhos';
import {DataSet, Rounding} from '../data/DataSet';
import { DataSet, Rounding } from '../data/DataSet';
import ChartAnimator from '../animation/ChartAnimator';
import DataRenderer from './DataRenderer'
import ViewPortHandler from '../utils/ViewPortHandler'
import IBarLineScatterCandleBubbleDataSet from '../interfaces/datasets/IBarLineScatterCandleBubbleDataSet'
import BarLineScatterCandleBubbleDataProvider from '../interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider'
import IDataSet from '../interfaces/datasets/IDataSet'
import DataRenderer from './DataRenderer';
import ViewPortHandler from '../utils/ViewPortHandler';
import IBarLineScatterCandleBubbleDataSet from '../interfaces/datasets/IBarLineScatterCandleBubbleDataSet';
import BarLineScatterCandleBubbleDataProvider from '../interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider';
import IDataSet from '../interfaces/datasets/IDataSet';
export class XBounds {
constructor(mAnimator:ChartAnimator){
this.mAnimator=mAnimator;
constructor(mAnimator: ChartAnimator) {
this.mAnimator = mAnimator;
}
/**
* minimum visible entry index
*/
* minimum visible entry index
*/
public min: number;
/**
* maximum visible entry index
*/
* maximum visible entry index
*/
public max: number;
/**
* range of visible entry indices
*/
* range of visible entry indices
*/
public range: number;
public mAnimator:ChartAnimator
public mAnimator: ChartAnimator;
/**
* Calculates the minimum and maximum x values as well as the range between them.
*
* @param chart
* @param dataSet
*/
public set(chart: BarLineScatterCandleBubbleDataProvider, dataSet: IBarLineScatterCandleBubbleDataSet<any>,mAnimator:ChartAnimator) {
* Calculates the minimum and maximum x values as well as the range between them.
*
* @param chart
* @param dataSet
*/
public set(
chart: BarLineScatterCandleBubbleDataProvider,
dataSet: IBarLineScatterCandleBubbleDataSet<any>,
mAnimator: ChartAnimator
) {
let phaseX: number = Math.max(0, Math.min(1, mAnimator.getPhaseX()));
let low: number = chart.getLowestVisibleX();
@ -63,7 +66,7 @@ export class XBounds {
this.min = entryFrom == null ? 0 : dataSet.getEntryIndexByEntry(entryFrom);
this.max = entryTo == null ? 0 : dataSet.getEntryIndexByEntry(entryTo);
this.range = ((this.max - this.min) * phaseX);
this.range = (this.max - this.min) * phaseX;
}
}
@ -71,38 +74,35 @@ export class XBounds {
* Created by Philipp Jahoda on 09/06/16.
*/
export default abstract class BarLineScatterCandleBubbleRenderer extends DataRenderer {
/**
* buffer for storing the current minimum and maximum visible x
*/
protected mXBounds: XBounds
/**
* buffer for storing the current minimum and maximum visible x
*/
protected mXBounds: XBounds;
constructor(animator: ChartAnimator, viewPortHandler: ViewPortHandler) {
super(animator, viewPortHandler);
this.mXBounds= new XBounds(this.mAnimator);
this.mXBounds = new XBounds(this.mAnimator);
}
/**
* Returns true if the DataSet values should be drawn, false if not.
*
* @param set
* @return
*/
/**
* Returns true if the DataSet values should be drawn, false if not.
*
* @param set
* @return
*/
protected shouldDrawValues(dataSet: IDataSet<any>): boolean {
return dataSet.isVisible() && (dataSet.isDrawValuesEnabled() || dataSet.isDrawIconsEnabled());
}
/**
* Checks if the provided entry object is in bounds for drawing considering the current animation phase.
*
* @param e
* @param set
* @return
*/
/**
* Checks if the provided entry object is in bounds for drawing considering the current animation phase.
*
* @param e
* @param set
* @return
*/
protected isInBoundsX(e: EntryOhos, dataSet: IBarLineScatterCandleBubbleDataSet<EntryOhos>): boolean {
if (e == null)
return false;
if (e == null) return false;
let entryIndex = dataSet.getEntryIndexByEntry(e);
@ -113,5 +113,3 @@ export default abstract class BarLineScatterCandleBubbleRenderer extends DataRen
}
}
}

View File

@ -16,14 +16,14 @@
import MyRect from '../data/Rect';
import Highlight from '../highlight/Highlight';
import EntryOhos from '../data/EntryOhos';
import Renderer from '../renderer/Renderer'
import ChartAnimator from '../animation/ChartAnimator'
import Paint, {Style,LinePaint,PathPaint, TextPaint} from '../data/Paint'
import ViewPortHandler from '../utils/ViewPortHandler'
import Utils from '../utils/Utils'
import IDataSet from '../interfaces/datasets/IDataSet'
import ChartInterface from '../interfaces/dataprovider/ChartInterface'
import IValueFormatter from '../formatter/IValueFormatter'
import Renderer from '../renderer/Renderer';
import ChartAnimator from '../animation/ChartAnimator';
import Paint, { Style, LinePaint, PathPaint, TextPaint } from '../data/Paint';
import ViewPortHandler from '../utils/ViewPortHandler';
import Utils from '../utils/Utils';
import IDataSet from '../interfaces/datasets/IDataSet';
import ChartInterface from '../interfaces/dataprovider/ChartInterface';
import IValueFormatter from '../formatter/IValueFormatter';
/**
* Superclass of all render classes for the different data types (line, bar, ...).
@ -31,33 +31,32 @@ import IValueFormatter from '../formatter/IValueFormatter'
* @author Philipp Jahoda
*/
export default abstract class DataRenderer extends Renderer {
/**
* the animator object used to perform animations on the chart data
*/
protected mAnimator: ChartAnimator = new ChartAnimator();
/**
* the animator object used to perform animations on the chart data
*/
protected mAnimator:ChartAnimator = new ChartAnimator();
/**
* main paint object used for rendering
*/
protected mRenderPaint: Paint;
/**
* main paint object used for rendering
*/
protected mRenderPaint:Paint;
protected mPathPaint: PathPaint;
protected mPathPaint:PathPaint;
/**
* paint used for highlighting values
*/
protected mHighlightPaint: Paint;
/**
* paint used for highlighting values
*/
protected mHighlightPaint:Paint;
protected mDrawPaint: Paint;
protected mDrawPaint:Paint;
/**
* paint object for drawing values (text representing values of chart
* entries)
*/
public mValuePaint: Paint;
/**
* paint object for drawing values (text representing values of chart
* entries)
*/
public mValuePaint:Paint;
constructor(animator:ChartAnimator, viewPortHandler:ViewPortHandler) {
constructor(animator: ChartAnimator, viewPortHandler: ViewPortHandler) {
super(viewPortHandler);
this.mAnimator = animator;
@ -79,112 +78,117 @@ export default abstract class DataRenderer extends Renderer {
this.mHighlightPaint.setColor(Color.Orange);
}
protected isDrawingValuesAllowed(chart:ChartInterface):boolean {
return chart.getData().getEntryCount() < chart.getMaxVisibleCount()
* this.mViewPortHandler.getScaleX();
protected isDrawingValuesAllowed(chart: ChartInterface): boolean {
return chart.getData().getEntryCount() < chart.getMaxVisibleCount() * this.mViewPortHandler.getScaleX();
}
/**
* Returns the Paint object this renderer uses for drawing the values
* (value-text).
*
* @return
*/
public getPaintValues():Paint {
/**
* Returns the Paint object this renderer uses for drawing the values
* (value-text).
*
* @return
*/
public getPaintValues(): Paint {
return this.mValuePaint;
}
/**
* Returns the Paint object this renderer uses for drawing highlight
* indicators.
*
* @return
*/
public getPaintHighlight():Paint {
/**
* Returns the Paint object this renderer uses for drawing highlight
* indicators.
*
* @return
*/
public getPaintHighlight(): Paint {
return this.mHighlightPaint;
}
/**
* Returns the Paint object used for rendering.
*
* @return
*/
public getPaintRender():Paint {
/**
* Returns the Paint object used for rendering.
*
* @return
*/
public getPaintRender(): Paint {
return this.mRenderPaint;
}
public getPathPaint():PathPaint {
public getPathPaint(): PathPaint {
return this.mPathPaint;
}
/**
* Applies the required styling (provided by the DataSet) to the value-paint
* object.
*
* @param set
*/
protected applyValueTextStyle(dateSet:IDataSet<EntryOhos>) {
/**
* Applies the required styling (provided by the DataSet) to the value-paint
* object.
*
* @param set
*/
protected applyValueTextStyle(dateSet: IDataSet<EntryOhos>) {
this.mValuePaint.setTypeface(dateSet.getValueTypeface());
this.mValuePaint.setTextSize(dateSet.getValueTextSize());
}
/**
* Initializes the buffers used for rendering with a new size. Since this
* method performs memory allocations, it should only be called if
* necessary.
*/
public abstract initBuffers();
/**
* Initializes the buffers used for rendering with a new size. Since this
* method performs memory allocations, it should only be called if
* necessary.
*/
public abstract initBuffers();
/**
* Draws the actual data in form of lines, bars, ... depending on Renderer subclass.
*
* @param c
*/
public abstract drawData(): Paint[];
* Draws the actual data in form of lines, bars, ... depending on Renderer subclass.
*
* @param c
*/
public abstract drawData(): Paint[];
/**
* Loops over all Entrys and draws their values.
*
* @param c
*/
public abstract drawValues(): Paint[];
/**
* Loops over all Entrys and draws their values.
*
* @param c
*/
public abstract drawValues(): Paint[];
/**
* Draws the value of the given entry by using the provided IValueFormatter.
*
* @param c canvas
* @param formatter formatter for custom value-formatting
* @param value the value to be drawn
* @param entry the entry the value belongs to
* @param dataSetIndex the index of the DataSet the drawn Entry belongs to
* @param x position
* @param y position
* @param color
*/
public drawValue(formatter:IValueFormatter, value:number, entry:EntryOhos, dataSetIndex:number, x:number, y:number, color:number): Paint[] {
/**
* Draws the value of the given entry by using the provided IValueFormatter.
*
* @param c canvas
* @param formatter formatter for custom value-formatting
* @param value the value to be drawn
* @param entry the entry the value belongs to
* @param dataSetIndex the index of the DataSet the drawn Entry belongs to
* @param x position
* @param y position
* @param color
*/
public drawValue(
formatter: IValueFormatter,
value: number,
entry: EntryOhos,
dataSetIndex: number,
x: number,
y: number,
color: number
): Paint[] {
this.mValuePaint.setColor(color);
let textPaint = new TextPaint();
textPaint.set(this.mValuePaint);
textPaint.setText(formatter.getFormattedValue(value, entry, dataSetIndex, this.mViewPortHandler));
textPaint.setX(x)
textPaint.setY(y)
return [textPaint]
textPaint.setX(x);
textPaint.setY(y);
return [textPaint];
}
/**
* Draws any kind of additional information (e.g. line-circles).
*
* @param c
*/
public abstract drawExtras(): Paint[];
/**
* Draws any kind of additional information (e.g. line-circles).
*
* @param c
*/
public abstract drawExtras(): Paint[];
/**
* Draws all highlight indicators for the values that are currently highlighted.
*
* @param c
* @param indices the highlighted values
*/
public abstract drawHighlighted(indices:Highlight[] ): Paint[];
/**
* Draws all highlight indicators for the values that are currently highlighted.
*
* @param c
* @param indices the highlighted values
*/
public abstract drawHighlighted(indices: Highlight[]): Paint[];
}

View File

@ -13,52 +13,57 @@
* limitations under the License.
*/
import {Style, Align, FontMetrics} from '../data/Paint'
import Legend from '../components/Legend'
import {LegendForm, LegendHorizontalAlignment, LegendVerticalAlignment, LegendOrientation, LegendDirection} from '../components/Legend'
import LegendEntry from '../components/LegendEntry'
import ChartData from '../data/ChartData'
import IBarDataSet from '../interfaces/datasets/IBarDataSet'
import IDataSet from '../interfaces/datasets/IDataSet'
import EntryOhos from '../data/EntryOhos'
import ColorTemplate from '../utils/ColorTemplate'
import FSize from '../utils/FSize'
import Utils from '../utils/Utils'
import ViewPortHandler from '../utils/ViewPortHandler'
import Renderer from './Renderer'
import {JArrayList} from '../utils/JArrayList'
import Paint,{LinePaint,TextPaint,PathPaint,CirclePaint,RectPaint} from '../data/Paint'
import { Style, Align, FontMetrics } from '../data/Paint';
import Legend from '../components/Legend';
import {
LegendForm,
LegendHorizontalAlignment,
LegendVerticalAlignment,
LegendOrientation,
LegendDirection,
} from '../components/Legend';
import LegendEntry from '../components/LegendEntry';
import ChartData from '../data/ChartData';
import IBarDataSet from '../interfaces/datasets/IBarDataSet';
import IDataSet from '../interfaces/datasets/IDataSet';
import EntryOhos from '../data/EntryOhos';
import ColorTemplate from '../utils/ColorTemplate';
import FSize from '../utils/FSize';
import Utils from '../utils/Utils';
import ViewPortHandler from '../utils/ViewPortHandler';
import Renderer from './Renderer';
import { JArrayList } from '../utils/JArrayList';
import Paint, { LinePaint, TextPaint, PathPaint, CirclePaint, RectPaint } from '../data/Paint';
class Point {
x1: number = 0
y1: number = 0
x2: number = 0
y2: number = 0
x1: number = 0;
y1: number = 0;
x2: number = 0;
y2: number = 0;
constructor(x1: number, y1: number, x2: number, y2: number) {
this.x1 = x1
this.y1 = y1
this.x2 = x2
this.y2 = y2
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
}
export default class LegendRenderer extends Renderer {
/**
* paint for the legend labels
*/
protected mLegendLabelPaint : Paint;
protected mLegendLabelPaint: Paint;
/**
* paint used for the legend forms
*/
protected mLegendFormPaint : Paint;
protected mLegendFormPaint: Paint;
/**
* the legend object this renderer renders
*/
protected mLegend : Legend;
protected mLegend: Legend;
constructor(viewPortHandler : ViewPortHandler, legend : Legend) {
constructor(viewPortHandler: ViewPortHandler, legend: Legend) {
super(viewPortHandler);
this.mLegend = legend;
@ -77,7 +82,7 @@ export default class LegendRenderer extends Renderer {
*
* @return
*/
public getLabelPaint() : Paint {
public getLabelPaint(): Paint {
return this.mLegendLabelPaint;
}
@ -86,100 +91,101 @@ export default class LegendRenderer extends Renderer {
*
* @return
*/
public getFormPaint() : Paint {
public getFormPaint(): Paint {
return this.mLegendFormPaint;
}
protected computedEntries : JArrayList<LegendEntry> = new JArrayList<LegendEntry>(/*16*/);
protected computedEntries: JArrayList<LegendEntry> = new JArrayList<LegendEntry>(/*16*/);
/**
* Prepares the legend and calculates all needed forms, labels and colors.
*
* @param data
*/
public computeLegend(data ?: ChartData<IDataSet<EntryOhos>>) : void {
public computeLegend(data?: ChartData<IDataSet<EntryOhos>>): void {
if (!this.mLegend.isLegendCustom() && data) {
this.computedEntries.clear();
// loop for building up the colors and labels used in the legend
for (var i : number = 0; i < data.getDataSetCount(); i++) {
var dataSet : IDataSet<EntryOhos> = data.getDataSetByIndex(i);
for (var i: number = 0; i < data.getDataSetCount(); i++) {
var dataSet: IDataSet<EntryOhos> = data.getDataSetByIndex(i);
if (dataSet == null) continue;
var clrs : JArrayList<Number> = dataSet.getColors();
var entryCount : number = dataSet.getEntryCount();
var clrs: JArrayList<Number> = dataSet.getColors();
var entryCount: number = dataSet.getEntryCount();
// if we have a barchart with stacked bars
if (dataSet.constructor.name == "IBarDataSet<EntryOhos>" && (<IBarDataSet>dataSet).isStacked()) {
if (dataSet.constructor.name == 'IBarDataSet<EntryOhos>' && (<IBarDataSet>dataSet).isStacked()) {
var bds: IBarDataSet = <IBarDataSet>dataSet;
var sLabels: string[] = bds.getStackLabels();
var bds : IBarDataSet = <IBarDataSet> dataSet;
var sLabels : string[] = bds.getStackLabels();
var minEntries: number = Math.min(clrs.size(), bds.getStackSize());
var minEntries : number = Math.min(clrs.size(), bds.getStackSize());
for (var j : number = 0; j < minEntries; j++) {
var label : string;
for (var j: number = 0; j < minEntries; j++) {
var label: string;
if (sLabels.length > 0) {
var labelIndex : number = j % minEntries;
var labelIndex: number = j % minEntries;
label = labelIndex < sLabels.length ? sLabels[labelIndex] : null;
} else {
label = null;
}
this.computedEntries.add(new LegendEntry(
label,
dataSet.getForm(),
dataSet.getFormSize(),
dataSet.getFormLineWidth(),
dataSet.getFormLineDashEffect(),
clrs.get(j).valueOf()
));
this.computedEntries.add(
new LegendEntry(
label,
dataSet.getForm(),
dataSet.getFormSize(),
dataSet.getFormLineWidth(),
dataSet.getFormLineDashEffect(),
clrs.get(j).valueOf()
)
);
}
if (bds.getLabel() != null) {
// add the legend description label
this.computedEntries.add(new LegendEntry(
dataSet.getLabel(),
this.computedEntries.add(
new LegendEntry(
dataSet.getLabel(),
LegendForm.NONE,
Number.NaN,
Number.NaN,
null,
null,
ColorTemplate.COLOR_NONE
));
)
);
}
} else {
// all others
} else { // all others
for (var j :number = 0; j < clrs.size() && j < entryCount; j++) {
var label : string;
for (var j: number = 0; j < clrs.size() && j < entryCount; j++) {
var label: string;
// if multiple colors are set for a DataSet, group them
if (j < clrs.size() - 1 && j < entryCount - 1) {
label = null;
} else { // add label to the last entry
} else {
// add label to the last entry
label = data.getDataSetByIndex(i).getLabel();
}
this.computedEntries.add(new LegendEntry(
label,
dataSet.getForm(),
dataSet.getFormSize(),
dataSet.getFormLineWidth(),
dataSet.getFormLineDashEffect(),
clrs.get(j).valueOf()
));
this.computedEntries.add(
new LegendEntry(
label,
dataSet.getForm(),
dataSet.getFormSize(),
dataSet.getFormLineWidth(),
dataSet.getFormLineDashEffect(),
clrs.get(j).valueOf()
)
);
}
}
}
if (this.mLegend.getExtraEntries() != null) {
var datas : LegendEntry[] = this.mLegend.getExtraEntries();
for (var i : number = 0; i < datas.length; i++) {
var datas: LegendEntry[] = this.mLegend.getExtraEntries();
for (var i: number = 0; i < datas.length; i++) {
this.computedEntries.add(datas[i]);
}
}
@ -187,10 +193,9 @@ export default class LegendRenderer extends Renderer {
this.mLegend.setEntries(this.computedEntries);
}
var tf : FontWeight/*Typeface*/ = this.mLegend.getTypeface();
var tf: FontWeight /*Typeface*/ = this.mLegend.getTypeface();
if (tf != null)
this.mLegendLabelPaint.setTypeface(tf);
if (tf != null) this.mLegendLabelPaint.setTypeface(tf);
this.mLegendLabelPaint.setTextSize(this.mLegend.getTextSize());
this.mLegendLabelPaint.setColor(this.mLegend.getTextColor());
@ -199,190 +204,241 @@ export default class LegendRenderer extends Renderer {
this.mLegend.calculateDimensions(this.mLegendLabelPaint, this.mViewPortHandler);
}
protected legendFontMetrics : FontMetrics = new FontMetrics();
protected legendFontMetrics: FontMetrics = new FontMetrics();
// public void renderLegend(Canvas c) {
public renderLegend() : Paint [] {
public renderLegend(): Paint[] {
let datas: Point[] = [];
if (!this.mLegend.isEnabled()) return;
let datas : Point[] = []
if (!this.mLegend.isEnabled())
return;
var tf: FontWeight /*Typeface*/ = this.mLegend.getTypeface();
var tf : FontWeight/*Typeface*/ = this.mLegend.getTypeface();
if (tf != null)
this.mLegendLabelPaint.setTypeface(tf);
if (tf != null) this.mLegendLabelPaint.setTypeface(tf);
this.mLegendLabelPaint.setTextSize(this.mLegend.getTextSize());
this.mLegendLabelPaint.setColor(this.mLegend.getTextColor());
var labelLineHeight : number = Utils.getLineHeight(this.mLegendLabelPaint);
var labelLineSpacing : number = Utils.getLineSpacing(this.mLegendLabelPaint)
+ this.mLegend.getYEntrySpace();
var formYOffset : number = labelLineHeight - Utils.calcTextHeight(this.mLegendLabelPaint, "ABC") / 2.0;
var labelLineHeight: number = Utils.getLineHeight(this.mLegendLabelPaint);
var labelLineSpacing: number = Utils.getLineSpacing(this.mLegendLabelPaint) + this.mLegend.getYEntrySpace();
var formYOffset: number = labelLineHeight - Utils.calcTextHeight(this.mLegendLabelPaint, 'ABC') / 2.0;
var entries : LegendEntry[] = this.mLegend.getEntries();
var entries: LegendEntry[] = this.mLegend.getEntries();
var formToTextSpace : number = this.mLegend.getFormToTextSpace();
var xEntrySpace : number = this.mLegend.getXEntrySpace();
var orientation : LegendOrientation = this.mLegend.getOrientation(); // "HORIZONTAL" ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var horizontalAlignment : LegendHorizontalAlignment = this.mLegend.getHorizontalAlignment(); // "LEFT" ˮƽ<CBAE><C6BD><EFBFBD>ʽ
var verticalAlignment : LegendVerticalAlignment = this.mLegend.getVerticalAlignment(); // "BOTTOM
var direction : LegendDirection = this.mLegend.getDirection(); // "LEFT_TO_RIGHT" ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
var defaultFormSize : number = this.mLegend.getFormSize();
var formToTextSpace: number = this.mLegend.getFormToTextSpace();
var xEntrySpace: number = this.mLegend.getXEntrySpace();
var orientation: LegendOrientation = this.mLegend.getOrientation(); // "HORIZONTAL" ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var horizontalAlignment: LegendHorizontalAlignment = this.mLegend.getHorizontalAlignment(); // "LEFT" ˮƽ<CBAE><C6BD><EFBFBD>ʽ
var verticalAlignment: LegendVerticalAlignment = this.mLegend.getVerticalAlignment(); // "BOTTOM
var direction: LegendDirection = this.mLegend.getDirection(); // "LEFT_TO_RIGHT" ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
var defaultFormSize: number = this.mLegend.getFormSize();
// space between the entries <20>ѵ<EFBFBD><D1B5><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>µĿռ<C4BF>
var stackSpace : number = this.mLegend.getStackSpace();
var stackSpace: number = this.mLegend.getStackSpace();
var yoffset : number = this.mLegend.getYOffset();
var xoffset : number = this.mLegend.getXOffset();
var originPosX : number = 0.0;
var paints : Paint[] = [];
var yoffset: number = this.mLegend.getYOffset();
var xoffset: number = this.mLegend.getXOffset();
var originPosX: number = 0.0;
var paints: Paint[] = [];
switch (horizontalAlignment) {
case LegendHorizontalAlignment.LEFT:
if (orientation == LegendOrientation.VERTICAL) {
originPosX = xoffset;
} else {
originPosX = this.mViewPortHandler.contentLeft() + xoffset;
}
console.log("1. originPosX("+JSON.stringify(originPosX)+")= xoffset("+xoffset+") + mViewPortHandler.contentLeft("+this.mViewPortHandler.contentLeft()+")");
if (direction == LegendDirection.RIGHT_TO_LEFT)
originPosX += this.mLegend.mNeededWidth;
console.log(
'1. originPosX(' +
JSON.stringify(originPosX) +
')= xoffset(' +
xoffset +
') + mViewPortHandler.contentLeft(' +
this.mViewPortHandler.contentLeft() +
')'
);
if (direction == LegendDirection.RIGHT_TO_LEFT) originPosX += this.mLegend.mNeededWidth;
break;
case LegendHorizontalAlignment.RIGHT:
if (orientation == LegendOrientation.VERTICAL) originPosX = this.mViewPortHandler.getChartWidth() - xoffset;
else originPosX = this.mViewPortHandler.contentRight() - xoffset;
if (orientation == LegendOrientation.VERTICAL)
originPosX = this.mViewPortHandler.getChartWidth() - xoffset;
else
originPosX = this.mViewPortHandler.contentRight() - xoffset;
if (direction == LegendDirection.LEFT_TO_RIGHT)
originPosX -= this.mLegend.mNeededWidth;
if (direction == LegendDirection.LEFT_TO_RIGHT) originPosX -= this.mLegend.mNeededWidth;
break;
case LegendHorizontalAlignment.CENTER:
if (orientation == LegendOrientation.VERTICAL) originPosX = this.mViewPortHandler.getChartWidth() / 2.0;
else originPosX = this.mViewPortHandler.contentLeft() + this.mViewPortHandler.contentWidth() / 2.0;
if (orientation == LegendOrientation.VERTICAL)
originPosX = this.mViewPortHandler.getChartWidth() / 2.0;
else
originPosX = this.mViewPortHandler.contentLeft()
+ this.mViewPortHandler.contentWidth() / 2.0;
originPosX += (direction == LegendDirection.LEFT_TO_RIGHT
? +xoffset
: -xoffset);
originPosX += direction == LegendDirection.LEFT_TO_RIGHT ? +xoffset : -xoffset;
// Horizontally layed out legends do the center offset on a line basis,
// So here we offset the vertical ones only.
if (orientation == LegendOrientation.VERTICAL) {
originPosX += (direction == LegendDirection.LEFT_TO_RIGHT
originPosX +=
direction == LegendDirection.LEFT_TO_RIGHT
? -this.mLegend.mNeededWidth / 2.0 + xoffset
: this.mLegend.mNeededWidth / 2.0 - xoffset);
: this.mLegend.mNeededWidth / 2.0 - xoffset;
}
break;
}
switch (orientation) { // "HORIZONTAL"
switch (
orientation // "HORIZONTAL"
) {
case LegendOrientation.HORIZONTAL: {
var calculatedLineSizes: JArrayList<FSize> = this.mLegend.getCalculatedLineSizes();
var calculatedLabelSizes: JArrayList<FSize> = this.mLegend.getCalculatedLabelSizes();
var calculatedLabelBreakPoints: JArrayList<Boolean> = this.mLegend.getCalculatedLabelBreakPoints();
var calculatedLineSizes : JArrayList<FSize> = this.mLegend.getCalculatedLineSizes();
var calculatedLabelSizes : JArrayList<FSize> = this.mLegend.getCalculatedLabelSizes();
var calculatedLabelBreakPoints : JArrayList<Boolean> = this.mLegend.getCalculatedLabelBreakPoints();
var posX: number = originPosX;
var posY: number = 0.0;
var posX : number = originPosX;
var posY : number = 0.0;
switch (verticalAlignment) { // "BOTTOM"
switch (
verticalAlignment // "BOTTOM"
) {
case LegendVerticalAlignment.TOP:
posY = yoffset;
console.log("2.0 posY("+JSON.stringify(posY)+")= yoffset("+yoffset+")");
console.log('2.0 posY(' + JSON.stringify(posY) + ')= yoffset(' + yoffset + ')');
break;
case LegendVerticalAlignment.BOTTOM:
posY = this.mViewPortHandler.getChartHeight() - yoffset - this.mLegend.mNeededHeight;
console.log("2.1 posY("+posY+")= mViewPortHandler.getChartHeight("+this.mViewPortHandler.getChartHeight()+")-mNeededHeight("+this.mLegend.mNeededHeight+")-yoffset("+yoffset+")");
console.log(
'2.1 posY(' +
posY +
')= mViewPortHandler.getChartHeight(' +
this.mViewPortHandler.getChartHeight() +
')-mNeededHeight(' +
this.mLegend.mNeededHeight +
')-yoffset(' +
yoffset +
')'
);
break;
case LegendVerticalAlignment.CENTER:
posY = (this.mViewPortHandler.getChartHeight() - this.mLegend.mNeededHeight) / 2.0 + yoffset;
console.log("2.1 posY("+posY+")= mViewPortHandler.getChartHeight("+this.mViewPortHandler.getChartHeight()+")-mNeededHeight/2("+this.mLegend.mNeededHeight/2+")+yoffset("+yoffset+")");
console.log(
'2.1 posY(' +
posY +
')= mViewPortHandler.getChartHeight(' +
this.mViewPortHandler.getChartHeight() +
')-mNeededHeight/2(' +
this.mLegend.mNeededHeight / 2 +
')+yoffset(' +
yoffset +
')'
);
break;
}
var lineIndex : number = 0;
for (var i : number = 0, count = entries.length; i < count; i++) {
let x1: number = 0
let y1: number = 0
let x2: number = 0
let y2: number = 0
var lineIndex: number = 0;
for (var i: number = 0, count = entries.length; i < count; i++) {
let x1: number = 0;
let y1: number = 0;
let x2: number = 0;
let y2: number = 0;
var e : LegendEntry = entries[i];
var drawingForm : boolean = e.form != LegendForm.NONE;
var formSize : number = Number.isNaN(e.formSize) ? defaultFormSize : Utils.convertDpToPixel(e.formSize);
var e: LegendEntry = entries[i];
var drawingForm: boolean = e.form != LegendForm.NONE;
var formSize: number = Number.isNaN(e.formSize) ? defaultFormSize : Utils.convertDpToPixel(e.formSize);
if (i < calculatedLabelBreakPoints.size() && calculatedLabelBreakPoints.get(i)) { // <20><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
if (i < calculatedLabelBreakPoints.size() && calculatedLabelBreakPoints.get(i)) {
// <20><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
posX = originPosX;
posY += labelLineHeight + labelLineSpacing;
console.log("3.0 i("+i+") posX="+posX+"; posY("+posY+")=labelLineHeight("+labelLineHeight+")+labelLineSpacing("+labelLineSpacing+")");
console.log(
'3.0 i(' +
i +
') posX=' +
posX +
'; posY(' +
posY +
')=labelLineHeight(' +
labelLineHeight +
')+labelLineSpacing(' +
labelLineSpacing +
')'
);
}
if (posX == originPosX &&
if (
posX == originPosX &&
horizontalAlignment == LegendHorizontalAlignment.CENTER && // "LEFT"
lineIndex < calculatedLineSizes.size()) {
posX += (direction == LegendDirection.RIGHT_TO_LEFT
lineIndex < calculatedLineSizes.size()
) {
posX +=
(direction == LegendDirection.RIGHT_TO_LEFT
? calculatedLineSizes.get(lineIndex).width
: -calculatedLineSizes.get(lineIndex).width) / 2.0;
lineIndex++;
}
var isStacked : boolean = e.label == null; // grouped forms have null labels
var isStacked: boolean = e.label == null; // grouped forms have null labels
if (drawingForm) {
if (direction == LegendDirection.RIGHT_TO_LEFT)
posX -= formSize;
if (direction == LegendDirection.RIGHT_TO_LEFT) posX -= formSize;
x1 = posX
y1 = posY
console.log("3.1 i("+i+") drawForm <==> posX="+posX+"; posY("+posY+")+formYOffset("+formYOffset+")");
x1 = posX;
y1 = posY;
console.log(
'3.1 i(' + i + ') drawForm <==> posX=' + posX + '; posY(' + posY + ')+formYOffset(' + formYOffset + ')'
);
paints.push(this.drawForm(posX, posY, e, this.mLegend));
if (direction == LegendDirection.LEFT_TO_RIGHT) { // "LEFT_TO_RIGHT"
console.log("3.2 i("+i+") posX("+posX+")+=Utils.convertDpToPixel(formSize)("+Utils.convertDpToPixel(formSize)+")");
if (direction == LegendDirection.LEFT_TO_RIGHT) {
// "LEFT_TO_RIGHT"
console.log(
'3.2 i(' +
i +
') posX(' +
posX +
')+=Utils.convertDpToPixel(formSize)(' +
Utils.convertDpToPixel(formSize) +
')'
);
posX += Utils.convertDpToPixel(formSize);
}
}
if (!isStacked) {
if (drawingForm) {
console.log("3.3 i("+i+") posX("+posX+")+=formToTextSpace("+formToTextSpace+")");
posX += direction == LegendDirection.RIGHT_TO_LEFT ? -formToTextSpace :
formToTextSpace;
console.log('3.3 i(' + i + ') posX(' + posX + ')+=formToTextSpace(' + formToTextSpace + ')');
posX += direction == LegendDirection.RIGHT_TO_LEFT ? -formToTextSpace : formToTextSpace;
}
if (direction == LegendDirection.RIGHT_TO_LEFT)
posX -= calculatedLabelSizes.get(i).width;
if (direction == LegendDirection.RIGHT_TO_LEFT) posX -= calculatedLabelSizes.get(i).width;
x2 = posX
y2 = posY
console.log("3.4 i("+i+") drawLabel <==> posX="+posX+"; posY("+posY+")+formYOffset("+formYOffset+")");
x2 = posX;
y2 = posY;
console.log(
'3.4 i(' + i + ') drawLabel <==> posX=' + posX + '; posY(' + posY + ')+formYOffset(' + formYOffset + ')'
);
paints.push(this.drawLabel(posX, posY, e.label));
if (direction == LegendDirection.LEFT_TO_RIGHT) {
console.log("3.5 i("+i+") posX("+posX+")+=calcTextWidth("+JSON.stringify(Utils.calcTextWidth(this.mLegendLabelPaint, e.label))+")");
posX += Utils.calcTextWidth(this.mLegendLabelPaint,e.label);
console.log(
'3.5 i(' +
i +
') posX(' +
posX +
')+=calcTextWidth(' +
JSON.stringify(Utils.calcTextWidth(this.mLegendLabelPaint, e.label)) +
')'
);
posX += Utils.calcTextWidth(this.mLegendLabelPaint, e.label);
}
console.log("3.6 i("+i+") posX("+posX+")+=xEntrySpace("+xEntrySpace+"); stackSpace("+stackSpace+")");
console.log(
'3.6 i(' + i + ') posX(' + posX + ')+=xEntrySpace(' + xEntrySpace + '); stackSpace(' + stackSpace + ')'
);
posX += direction == LegendDirection.RIGHT_TO_LEFT ? -xEntrySpace : xEntrySpace;
} else
posX += direction == LegendDirection.RIGHT_TO_LEFT ? -stackSpace : stackSpace;
} else posX += direction == LegendDirection.RIGHT_TO_LEFT ? -stackSpace : stackSpace;
datas.push(new Point(x1, y1, x2, y2))
datas.push(new Point(x1, y1, x2, y2));
}
break;
@ -390,59 +446,52 @@ export default class LegendRenderer extends Renderer {
case LegendOrientation.VERTICAL: {
// contains the stacked legend size in pixels
var stack : number = 0;
var wasStacked : boolean = false;
var posY : number = 0.1;
var stack: number = 0;
var wasStacked: boolean = false;
var posY: number = 0.1;
switch (verticalAlignment) {
case LegendVerticalAlignment.TOP:
posY = (horizontalAlignment == LegendHorizontalAlignment.CENTER
? 0.1
: this.mViewPortHandler.contentTop());
posY = horizontalAlignment == LegendHorizontalAlignment.CENTER ? 0.1 : this.mViewPortHandler.contentTop();
posY += yoffset;
break;
case LegendVerticalAlignment.BOTTOM:
posY = (horizontalAlignment == LegendHorizontalAlignment.CENTER
posY =
horizontalAlignment == LegendHorizontalAlignment.CENTER
? this.mViewPortHandler.getChartHeight()
: this.mViewPortHandler.contentBottom());
: this.mViewPortHandler.contentBottom();
posY -= this.mLegend.mNeededHeight + yoffset;
break;
case LegendVerticalAlignment.CENTER:
posY = this.mViewPortHandler.getChartHeight() / 2.0
- this.mLegend.mNeededHeight / 2.0
+ this.mLegend.getYOffset();
posY =
this.mViewPortHandler.getChartHeight() / 2.0 -
this.mLegend.mNeededHeight / 2.0 +
this.mLegend.getYOffset();
break;
}
for (var i : number = 0; i < entries.length; i++) {
for (var i: number = 0; i < entries.length; i++) {
var e: LegendEntry = entries[i];
var drawingForm: boolean = e.form != LegendForm.NONE;
var formSize: number = Number.isNaN(e.formSize) ? defaultFormSize : Utils.convertDpToPixel(e.formSize);
var e : LegendEntry = entries[i];
var drawingForm : boolean = e.form != LegendForm.NONE;
var formSize : number = Number.isNaN(e.formSize) ? defaultFormSize : Utils.convertDpToPixel(e.formSize);
var posX : number = originPosX;
var posX: number = originPosX;
if (drawingForm) {
if (direction == LegendDirection.LEFT_TO_RIGHT)
posX += stack;
else
posX -= formSize - stack;
if (direction == LegendDirection.LEFT_TO_RIGHT) posX += stack;
else posX -= formSize - stack;
this.mLegendFormPaint = this.drawForm(/*c,*/ posX, posY + formYOffset, e, this.mLegend);
if (direction == LegendDirection.LEFT_TO_RIGHT)
posX += formSize;
if (direction == LegendDirection.LEFT_TO_RIGHT) posX += formSize;
}
if (e.label != null) {
if (drawingForm && !wasStacked)
posX += direction == LegendDirection.LEFT_TO_RIGHT ? formToTextSpace
: -formToTextSpace;
else if (wasStacked)
posX = originPosX;
posX += direction == LegendDirection.LEFT_TO_RIGHT ? formToTextSpace : -formToTextSpace;
else if (wasStacked) posX = originPosX;
if (direction == LegendDirection.RIGHT_TO_LEFT)
posX -= Utils.calcTextWidth(this.mLegendLabelPaint[i], e.label);
@ -466,10 +515,9 @@ export default class LegendRenderer extends Renderer {
}
break;
}
}
console.log("6. LegendRenderer datas:"+JSON.stringify(datas));
console.log('6. LegendRenderer datas:' + JSON.stringify(datas));
return paints;
}
@ -483,25 +531,19 @@ export default class LegendRenderer extends Renderer {
* @param entry the entry to render
* @param legend the legend context
*/
protected drawForm(
x : number, y : number,
entry : LegendEntry,
legend : Legend) : Paint {
if (entry.formColor == ColorTemplate.COLOR_SKIP ||
protected drawForm(x: number, y: number, entry: LegendEntry, legend: Legend): Paint {
if (
entry.formColor == ColorTemplate.COLOR_SKIP ||
entry.formColor == ColorTemplate.COLOR_NONE ||
entry.formColor == 0)
entry.formColor == 0
)
return;
var form : LegendForm = entry.form;
if (form == LegendForm.DEFAULT)
form = legend.getForm();
var form: LegendForm = entry.form;
if (form == LegendForm.DEFAULT) form = legend.getForm();
var formSize : number = Utils.convertDpToPixel(
Number.isNaN(entry.formSize)
? legend.getFormSize()
: entry.formSize);
var half : number = formSize / 2;
var formSize: number = Utils.convertDpToPixel(Number.isNaN(entry.formSize) ? legend.getFormSize() : entry.formSize);
var half: number = formSize / 2;
switch (form) {
case LegendForm.NONE:
@ -514,43 +556,42 @@ export default class LegendRenderer extends Renderer {
case LegendForm.DEFAULT:
case LegendForm.CIRCLE:
var circlePaint : CirclePaint = new CirclePaint()//= this.mLegendFormPaint as CirclePaint;
var circlePaint: CirclePaint = new CirclePaint(); //= this.mLegendFormPaint as CirclePaint;
circlePaint.setColor(entry.formColor);
circlePaint.setStyle(Style.FILL)
circlePaint.setX(x + half)
circlePaint.setY(y)
circlePaint.setWidth(half)
circlePaint.setHeight(half)
return circlePaint
circlePaint.setStyle(Style.FILL);
circlePaint.setX(x + half);
circlePaint.setY(y);
circlePaint.setWidth(half);
circlePaint.setHeight(half);
return circlePaint;
break;
case LegendForm.SQUARE:
var rectPaint : RectPaint = new RectPaint();//= this.mLegendFormPaint as RectPaint;
rectPaint.setStroke(entry.formColor)
rectPaint.setStyle(Style.FILL)
rectPaint.setStartPoint([x, y])
rectPaint.setWidth(formSize)
rectPaint.setHeight(half)
return rectPaint
var rectPaint: RectPaint = new RectPaint(); //= this.mLegendFormPaint as RectPaint;
rectPaint.setStroke(entry.formColor);
rectPaint.setStyle(Style.FILL);
rectPaint.setStartPoint([x, y]);
rectPaint.setWidth(formSize);
rectPaint.setHeight(half);
return rectPaint;
break;
case LegendForm.LINE:
{
var linePaint : LinePaint //= this.mLegendFormPaint as LinePaint;
var formLineWidth : number = Utils.convertDpToPixel(
Number.isNaN(entry.formLineWidth)
? legend.getFormLineWidth()
: entry.formLineWidth);
/*var formLineDashEffect : DashPathEffect = entry.formLineDashEffect == null
? legend.getFormLineDashEffect()
: entry.formLineDashEffect;*/
linePaint.setStyle(Style.STROKE)
linePaint.setStrokeWidth(formLineWidth)
{
var linePaint: LinePaint; //= this.mLegendFormPaint as LinePaint;
var formLineWidth: number = Utils.convertDpToPixel(
Number.isNaN(entry.formLineWidth) ? legend.getFormLineWidth() : entry.formLineWidth
);
/*var formLineDashEffect : DashPathEffect = entry.formLineDashEffect == null
? legend.getFormLineDashEffect()
: entry.formLineDashEffect;*/
linePaint.setStyle(Style.STROKE);
linePaint.setStrokeWidth(formLineWidth);
linePaint.setStartPoint([x, y])
linePaint.setEndPoint([x + formSize, y])
return linePaint
}
linePaint.setStartPoint([x, y]);
linePaint.setEndPoint([x + formSize, y]);
return linePaint;
}
break;
}
}
@ -564,12 +605,11 @@ export default class LegendRenderer extends Renderer {
* @param label the label to draw
*/
// protected void drawLabel(Canvas c, float x, float y, String label) {
protected drawLabel(/*c : Canvas,*/ x : number, y : number, label : string) : Paint {
var textPaint : TextPaint = new TextPaint(this.mLegendLabelPaint as TextPaint) //= this.mLegendLabelPaint as TextPaint;
textPaint.setText(label)
textPaint.setX(x)
textPaint.setY(y)
return textPaint
protected drawLabel(/*c : Canvas,*/ x: number, y: number, label: string): Paint {
var textPaint: TextPaint = new TextPaint(this.mLegendLabelPaint as TextPaint); //= this.mLegendLabelPaint as TextPaint;
textPaint.setText(label);
textPaint.setX(x);
textPaint.setY(y);
return textPaint;
}
}

View File

@ -13,24 +13,25 @@
* limitations under the License.
*/
import YAxis,{AxisDependency} from '../components/YAxis';
import YAxis, { AxisDependency } from '../components/YAxis';
import EntryOhos from '../data/EntryOhos';
import MyRect from '../data/Rect';
import {LineDataSet,Mode} from '../data/LineDataSet';
import { LineDataSet, Mode } from '../data/LineDataSet';
import MPPointD from '../utils/MPPointD';
import { PathViewModel } from '../components/PathView';
import {XAxis} from '../components/XAxis';
import LineDataProvider from '../interfaces/dataprovider/LineDataProvider'
import LineData from '../data/LineData'
import Paint, { PathPaint, TextPaint, CirclePaint, PathFillPaint, LinePaint, ImagePaint} from '../data/Paint'
import {Rounding} from '../data/DataSet'
import Utils from '../utils/Utils'
import {FillStyle} from '../data/LineDataSet'
import LineScatterCandleRadarRenderer from '../renderer/LineScatterCandleRadarRenderer'
import { XAxis } from '../components/XAxis';
import LineDataProvider from '../interfaces/dataprovider/LineDataProvider';
import LineData from '../data/LineData';
import Paint, { PathPaint, TextPaint, CirclePaint, PathFillPaint, LinePaint, ImagePaint } from '../data/Paint';
import { Rounding } from '../data/DataSet';
import Utils from '../utils/Utils';
import { FillStyle } from '../data/LineDataSet';
import LineScatterCandleRadarRenderer from '../renderer/LineScatterCandleRadarRenderer';
export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
protected mChart: LineDataProvider;
private min; max: number;
private min;
max: number;
private range: number;
private phaseY: number = 1;
private phaseX: number = 1;
@ -45,13 +46,12 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
private mLineBuffer: number[] = new Array(4);
private clickPaint: Paint[] = [];
private xStartPoint:number[] = [];
private xEndPoint:number[] = [];
private yStartPoint:number[] = [];
private yEndPoint:number[] = [];
private xStartPoint: number[] = [];
private xEndPoint: number[] = [];
private yStartPoint: number[] = [];
private yEndPoint: number[] = [];
constructor(pathViewModel: PathViewModel,yleftAxis: YAxis,yRightAxis: YAxis,isInverted: boolean) {
constructor(pathViewModel: PathViewModel, yleftAxis: YAxis, yRightAxis: YAxis, isInverted: boolean) {
super(null, null);
this.pathViewModel = pathViewModel;
this.lineData = pathViewModel.getLineData();
@ -60,14 +60,11 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
this.isInverted = isInverted;
}
public drawExtras():Paint[]{
public drawExtras(): Paint[] {
return [];
}
public drawHighlighted():Paint[]{
public drawHighlighted(): Paint[] {
// 1、拿到点击的物理坐标转换成图形坐标
// 2、拿点击转换后的坐标和数据中所有的点作比较取最近的点
// 3、以最近的点为中心画十字架
@ -76,7 +73,7 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
let x = this.pathViewModel.eventX;
let y = this.pathViewModel.eventY;
if(x > 0 && x < this.pathViewModel.rect.right && y > 0 && y < this.pathViewModel.rect.bottom){
if (x > 0 && x < this.pathViewModel.rect.right && y > 0 && y < this.pathViewModel.rect.bottom) {
let ccTemp: number = Number.MAX_VALUE;
let positionX: number;
let positionY: number;
@ -87,64 +84,69 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
let yAxis: YAxis;
let yScale: number;
let size = this.lineData.getDataSets().length();
for (let i = 0;i < size; i++) {
for (let i = 0; i < size; i++) {
let entryArray: EntryOhos[] = (this.lineData.getDataSetByIndex(i) as LineDataSet).getEntries().toArray();
for(let j = 0; j < entryArray.length; j++){
for (let j = 0; j < entryArray.length; j++) {
isLeftAxis = this.pathViewModel.lineData.getDataSetByIndex(i).getAxisDependency() == AxisDependency.LEFT;
yAxis = isLeftAxis ? this.pathViewModel.yleftAxis : this.pathViewModel.yRightAxis;
yScale = isLeftAxis ? this.pathViewModel.yLeftScale : this.pathViewModel.yRightScale;
entryX = entryArray[j].getX() * this.pathViewModel.xScale * this.pathViewModel.scaleX + this.pathViewModel.moveX - this.pathViewModel.currentXSpace;
entryX =
entryArray[j].getX() * this.pathViewModel.xScale * this.pathViewModel.scaleX +
this.pathViewModel.moveX -
this.pathViewModel.currentXSpace;
maxY = yAxis.getAxisMaximum();
if(!this.pathViewModel.isInverted){
if (!this.pathViewModel.isInverted) {
entryY = (maxY - entryArray[j].getY()) * yScale;
} else {
entryY = (entryArray[j].getY()) * yScale;
entryY = entryArray[j].getY() * yScale;
}
entryY = entryY * this.pathViewModel.scaleY + this.pathViewModel.moveY - this.pathViewModel.currentYSpace
entryY = entryY * this.pathViewModel.scaleY + this.pathViewModel.moveY - this.pathViewModel.currentYSpace;
let a = Math.abs(x - entryX);
let b = Math.abs(y - entryY);
let cc = Math.sqrt(a * a + b * b);
if(ccTemp > cc){
if (ccTemp > cc) {
ccTemp = cc;
positionX = entryX;
positionY = entryY;
}
}
}
let textPaint: TextPaint = new TextPaint();
let value: string = Math.floor(maxY - positionY / yScale).toString();
textPaint.setText(value);
textPaint.setColor(Color.White);
textPaint.setX(positionX - Utils.calcTextWidth(textPaint,value) / 2);
textPaint.setY(positionY - Utils.calcTextHeight(textPaint,value) - (Utils.calcTextHeight(textPaint,value) + 20) / 2);
textPaint.setX(positionX - Utils.calcTextWidth(textPaint, value) / 2);
textPaint.setY(
positionY - Utils.calcTextHeight(textPaint, value) - (Utils.calcTextHeight(textPaint, value) + 20) / 2
);
let imagePaint: ImagePaint = new ImagePaint();
imagePaint.setWidth(Utils.calcTextWidth(textPaint,value) + 20);
imagePaint.setHeight(Utils.calcTextHeight(textPaint,value) + 20);
imagePaint.setX(positionX - (Utils.calcTextWidth(textPaint,value) + 20) / 2);
imagePaint.setY(positionY - Utils.calcTextHeight(textPaint,value) - 20);
imagePaint.setWidth(Utils.calcTextWidth(textPaint, value) + 20);
imagePaint.setHeight(Utils.calcTextHeight(textPaint, value) + 20);
imagePaint.setX(positionX - (Utils.calcTextWidth(textPaint, value) + 20) / 2);
imagePaint.setY(positionY - Utils.calcTextHeight(textPaint, value) - 20);
let yLinePaint: LinePaint = new LinePaint();
yLinePaint.setStartPoint([positionX,0]);
yLinePaint.setEndPoint([positionX,this.pathViewModel.rect.bottom - this.pathViewModel.minOffset]);
yLinePaint.setStartPoint([positionX, 0]);
yLinePaint.setEndPoint([positionX, this.pathViewModel.rect.bottom - this.pathViewModel.minOffset]);
yLinePaint.setColor(Color.Red);
yLinePaint.setStrokeWidth(0.5);
let xLinePaint: LinePaint = new LinePaint();
xLinePaint.setStartPoint([0,positionY]);
if(!yAxis || yAxis == null || yAxis == undefined){
xLinePaint.setStartPoint([0, positionY]);
if (!yAxis || yAxis == null || yAxis == undefined) {
yAxis = this.pathViewModel?.yleftAxis || this.yleftAxis;
}
xLinePaint.setEndPoint([this.pathViewModel.rect.right - this.pathViewModel.minOffset - Utils.calcTextWidth(textPaint,yAxis.getLongestLabel()),positionY]);
xLinePaint.setEndPoint([
this.pathViewModel.rect.right -
this.pathViewModel.minOffset -
Utils.calcTextWidth(textPaint, yAxis.getLongestLabel()),
positionY,
]);
xLinePaint.setColor(Color.Red);
xLinePaint.setStrokeWidth(0.5);
@ -156,62 +158,88 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
return this.clickPaint;
}
public initBuffers() {}
public initBuffers(){
}
public drawData():Paint[]{
public drawData(): Paint[] {
let pathPaintArr: Paint[] = [];
let firstPointX,lastPointX,minPointY, maxPointY: number;
let firstPointX, lastPointX, minPointY, maxPointY: number;
let xScale: number = this.pathViewModel.xScale;
let yScale: number = 1;
let lineDataSet: LineDataSet;
for(let i = 0; i < this.lineData.getDataSetCount(); i++) {
for (let i = 0; i < this.lineData.getDataSetCount(); i++) {
lineDataSet = this.lineData.getDataSetByIndex(i) as LineDataSet;
if(lineDataSet.getEntries().size() <= 0){
if (lineDataSet.getEntries().size() <= 0) {
continue;
}
this.animateXIndex = this.animateXIndex <= (lineDataSet.getEntries().length() - 1) ? this.animateXIndex : (lineDataSet.getEntries().length() - 1);
this.animateXIndex =
this.animateXIndex <= lineDataSet.getEntries().length() - 1
? this.animateXIndex
: lineDataSet.getEntries().length() - 1;
firstPointX = Utils.convertDpToPixel(this.getXPosition(lineDataSet.getEntries().at(0).getX() * xScale * this.pathViewModel.scaleX));
lastPointX = Utils.convertDpToPixel(this.getXPosition(lineDataSet.getEntries().at(this.animateXIndex).getX() * xScale));
if(lineDataSet.getAxisDependency() == AxisDependency.LEFT){
firstPointX = Utils.convertDpToPixel(
this.getXPosition(lineDataSet.getEntries().at(0).getX() * xScale * this.pathViewModel.scaleX)
);
lastPointX = Utils.convertDpToPixel(
this.getXPosition(lineDataSet.getEntries().at(this.animateXIndex).getX() * xScale)
);
if (lineDataSet.getAxisDependency() == AxisDependency.LEFT) {
yScale = this.pathViewModel.yLeftScale;
minPointY = Utils.convertDpToPixel(this.getYPosition((this.yleftAxis.getAxisMaximum() - this.yleftAxis.getAxisMinimum() * this.animateYValue) * yScale));
minPointY = Utils.convertDpToPixel(
this.getYPosition(
(this.yleftAxis.getAxisMaximum() - this.yleftAxis.getAxisMinimum() * this.animateYValue) * yScale
)
);
maxPointY = this.getYPosition(0); // 屏幕上Y值的0点在最上方而图例的最大是在最上方所以取0
} else {
yScale = this.pathViewModel.yRightScale;
minPointY = Utils.convertDpToPixel(this.getYPosition((this.yRightAxis.getAxisMaximum() - this.yRightAxis.getAxisMinimum() * this.animateYValue) * yScale));
minPointY = Utils.convertDpToPixel(
this.getYPosition(
(this.yRightAxis.getAxisMaximum() - this.yRightAxis.getAxisMinimum() * this.animateYValue) * yScale
)
);
maxPointY = this.getYPosition(0);
}
let pathPaint: Paint[] = this.computePathDataSet(lineDataSet,xScale,yScale,firstPointX,lastPointX,minPointY, maxPointY);
let pathPaint: Paint[] = this.computePathDataSet(
lineDataSet,
xScale,
yScale,
firstPointX,
lastPointX,
minPointY,
maxPointY
);
pathPaintArr = pathPaintArr.concat(pathPaint);
}
return pathPaintArr;
}
protected computePathDataSet(dataSet: LineDataSet, xScale: number, yScale: number,firstPointX: number,lastPointX: number,minPointY: number,maxPointY: number):Paint[] {
protected computePathDataSet(
dataSet: LineDataSet,
xScale: number,
yScale: number,
firstPointX: number,
lastPointX: number,
minPointY: number,
maxPointY: number
): Paint[] {
if (this.lineData.getDataSetCount() < 1) return null;
let chartMode: Mode = dataSet.getMode();
switch (chartMode) {
case Mode.LINEAR:
case Mode.STEPPED:
return this.computeLinear(dataSet, xScale, yScale, firstPointX,lastPointX,minPointY, maxPointY);
return this.computeLinear(dataSet, xScale, yScale, firstPointX, lastPointX, minPointY, maxPointY);
break;
case Mode.CUBIC_BEZIER:
return this.computeCubicBezier(dataSet, xScale, yScale, firstPointX,lastPointX,minPointY, maxPointY);
return this.computeCubicBezier(dataSet, xScale, yScale, firstPointX, lastPointX, minPointY, maxPointY);
break;
case Mode.HORIZONTAL_BEZIER:
return this.computeHorizontalBezier(dataSet, xScale, yScale, firstPointX,lastPointX,minPointY, maxPointY);
return this.computeHorizontalBezier(dataSet, xScale, yScale, firstPointX, lastPointX, minPointY, maxPointY);
break;
default:
@ -219,11 +247,18 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
}
}
protected computeCubicBezier(dataSet: LineDataSet, xScale: number, yScale: number,firstPointX: number,lastPointX: number,minY: number,maxY: number):Paint[] {
protected computeCubicBezier(
dataSet: LineDataSet,
xScale: number,
yScale: number,
firstPointX: number,
lastPointX: number,
minY: number,
maxY: number
): Paint[] {
let intensity = dataSet.getCubicIntensity();
let mXAxis = new XAxis()
let mXAxis = new XAxis();
let posForGetLowestVisibleX = MPPointD.getInstance(0, 0);
let posForGetHighestVisibleX = MPPointD.getInstance(0, 0);
@ -239,7 +274,6 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
this.range = dataSet.getEntryCount() - 1;
if (this.range >= 1) {
let prevDx = 0;
let prevDy = 0;
let curDx = 0;
@ -259,27 +293,28 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
var commandsData: string = '';
var commandsDataFill: string = '';
if(dataSet.getFillStyle() == FillStyle.MIN){
commandsDataFill = 'M' + firstPointX + ' ' + minY;
if (dataSet.getFillStyle() == FillStyle.MIN) {
commandsDataFill = 'M' + firstPointX + ' ' + minY;
} else {
commandsDataFill = 'M' + firstPointX + ' ' + minY;
commandsDataFill = 'M' + firstPointX + ' ' + minY;
}
let startAddY: number;
let yAxis: YAxis = dataSet.getAxisDependency() == AxisDependency.LEFT ? this.yleftAxis : this.yRightAxis;
if (!this.isInverted) {
startAddY = Utils.convertDpToPixel(this.getYPosition((yAxis.getAxisMaximum() - cur.getY() * this.animateYValue) * yScale));
startAddY = Utils.convertDpToPixel(
this.getYPosition((yAxis.getAxisMaximum() - cur.getY() * this.animateYValue) * yScale)
);
} else {
startAddY = Utils.convertDpToPixel(this.getYPosition((cur.getY() * this.animateYValue) * yScale));
startAddY = Utils.convertDpToPixel(this.getYPosition(cur.getY() * this.animateYValue * yScale));
}
commandsDataFill += " L"+Utils.convertDpToPixel(this.getXPosition(cur.getX() * xScale)) + " " + startAddY
commandsDataFill += ' L' + Utils.convertDpToPixel(this.getXPosition(cur.getX() * xScale)) + ' ' + startAddY;
commandsData = "M" + Utils.convertDpToPixel(this.getXPosition(cur.getX() * xScale)) + " " + startAddY;
commandsData = 'M' + Utils.convertDpToPixel(this.getXPosition(cur.getX() * xScale)) + ' ' + startAddY;
for (let j = this.min + 1; j <= this.range + this.min; j++) {
if(j > this.animateXIndex){
if (j > this.animateXIndex) {
break;
}
prevPrev = prev;
@ -290,64 +325,81 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
next = dataSet.getEntryForIndex(nextIndex);
prevDx = (cur.getX() - prevPrev.getX()) * intensity;
prevDy = (yAxis.getAxisMaximum() - cur.getY() * this.animateYValue - (yAxis.getAxisMaximum() - prevPrev.getY() * this.animateYValue)) * intensity;
prevDy =
(yAxis.getAxisMaximum() -
cur.getY() * this.animateYValue -
(yAxis.getAxisMaximum() - prevPrev.getY() * this.animateYValue)) *
intensity;
curDx = (next.getX() - prev.getX()) * intensity;
curDy = 0;
let realY1: number = this.isInverted ? (prev.getY() * this.animateYValue + prevDy) : (yAxis.getAxisMaximum() - prev.getY() * this.animateYValue + prevDy);
let realY1: number = this.isInverted
? prev.getY() * this.animateYValue + prevDy
: yAxis.getAxisMaximum() - prev.getY() * this.animateYValue + prevDy;
let x1 = Utils.convertDpToPixel(this.getXPosition((prev.getX() + prevDx) * xScale));
let y1 = Utils.convertDpToPixel(this.getYPosition(realY1 * yScale));
let realY2: number = this.isInverted ? cur.getY() * this.animateYValue : yAxis.getAxisMaximum() - cur.getY() * this.animateYValue;
let realY2: number = this.isInverted
? cur.getY() * this.animateYValue
: yAxis.getAxisMaximum() - cur.getY() * this.animateYValue;
let x2 = Utils.convertDpToPixel(this.getXPosition((cur.getX() - curDx) * xScale));
let y2 = Utils.convertDpToPixel(this.getYPosition((realY2 - curDy) * yScale));
let realY3: number = this.isInverted ? cur.getY() * this.animateYValue : yAxis.getAxisMaximum() - cur.getY() * this.animateYValue;
let realY3: number = this.isInverted
? cur.getY() * this.animateYValue
: yAxis.getAxisMaximum() - cur.getY() * this.animateYValue;
let x3 = Utils.convertDpToPixel(this.getXPosition(cur.getX() * xScale));
let y3 = Utils.convertDpToPixel(this.getYPosition(realY3 * yScale));
commandsData += " C" + x1 + " " + y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3;
commandsDataFill += " C" + x1 + " " + y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3;
commandsData += ' C' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2 + ' ' + x3 + ' ' + y3;
commandsDataFill += ' C' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2 + ' ' + x3 + ' ' + y3;
}
if(dataSet.getFillStyle() == FillStyle.MIN){
commandsDataFill += " L" + lastPointX + " " + minY;
if (dataSet.getFillStyle() == FillStyle.MIN) {
commandsDataFill += ' L' + lastPointX + ' ' + minY;
} else {
commandsDataFill += " L" + lastPointX + " " + maxY;
commandsDataFill += ' L' + lastPointX + ' ' + maxY;
}
}
return this.creatPathPaintArr(dataSet,commandsData,commandsDataFill);;
return this.creatPathPaintArr(dataSet, commandsData, commandsDataFill);
}
private getXPosition(x: number): number{
return x * this.pathViewModel.scaleX + this.pathViewModel.moveX - this.pathViewModel.currentXSpace
private getXPosition(x: number): number {
return x * this.pathViewModel.scaleX + this.pathViewModel.moveX - this.pathViewModel.currentXSpace;
}
private getYPosition(y: number): number{
private getYPosition(y: number): number {
return y * this.pathViewModel.scaleY + this.pathViewModel.moveY - this.pathViewModel.currentYSpace;
}
private computeLinear(dataSet: LineDataSet,xScale: number, yScale: number,firstPointX: number,lastPointX: number,minY: number,maxY: number): Paint[]{
let x,y: number;
private computeLinear(
dataSet: LineDataSet,
xScale: number,
yScale: number,
firstPointX: number,
lastPointX: number,
minY: number,
maxY: number
): Paint[] {
let x, y: number;
var commandsData: string = '';
var commandsFillData: string = '';
if(dataSet.getFillStyle() == FillStyle.MIN){
commandsFillData = 'M' + firstPointX + ' ' + minY;
if (dataSet.getFillStyle() == FillStyle.MIN) {
commandsFillData = 'M' + firstPointX + ' ' + minY;
} else {
commandsFillData = 'M' + firstPointX + ' ' + maxY;
commandsFillData = 'M' + firstPointX + ' ' + maxY;
}
let entryArray: Array<EntryOhos> = dataSet.getEntries().toArray();
let entryOhosY: number;
for(let i = 0; i < entryArray.length;i++){
if(i > this.animateXIndex){
for (let i = 0; i < entryArray.length; i++) {
if (i > this.animateXIndex) {
break;
}
if(!this.isInverted) {
if(dataSet.getAxisDependency() == AxisDependency.LEFT){
if (!this.isInverted) {
if (dataSet.getAxisDependency() == AxisDependency.LEFT) {
entryOhosY = this.yleftAxis.getAxisMaximum() - entryArray[i].getY() * this.animateYValue;
} else {
entryOhosY = this.yRightAxis.getAxisMaximum() - entryArray[i].getY() * this.animateYValue;
@ -358,25 +410,32 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
x = Utils.convertDpToPixel(this.getXPosition(entryArray[i].getX() * xScale));
y = Utils.convertDpToPixel(this.getYPosition(entryOhosY * yScale));
if(i == 0){
commandsData = "M" + x + " " + y;
if (i == 0) {
commandsData = 'M' + x + ' ' + y;
} else {
commandsData += " L" + x + " " + y;
commandsData += ' L' + x + ' ' + y;
}
commandsFillData += " L" + x + " " + y;
commandsFillData += ' L' + x + ' ' + y;
}
if(dataSet.getFillStyle() == FillStyle.MIN){
commandsFillData += " L" + lastPointX + " " + minY;
if (dataSet.getFillStyle() == FillStyle.MIN) {
commandsFillData += ' L' + lastPointX + ' ' + minY;
} else {
commandsFillData += " L" + lastPointX + " " + maxY;
commandsFillData += ' L' + lastPointX + ' ' + maxY;
}
return this.creatPathPaintArr(dataSet,commandsData,commandsFillData);
return this.creatPathPaintArr(dataSet, commandsData, commandsFillData);
}
private computeHorizontalBezier(dataSet: LineDataSet,xScale: number, yScale: number,firstPointX: number,lastPointX: number,minY: number,maxY: number): Paint[]{
let mXAxis = new XAxis()
private computeHorizontalBezier(
dataSet: LineDataSet,
xScale: number,
yScale: number,
firstPointX: number,
lastPointX: number,
minY: number,
maxY: number
): Paint[] {
let mXAxis = new XAxis();
let posForGetLowestVisibleX = MPPointD.getInstance(0, 0);
let posForGetHighestVisibleX = MPPointD.getInstance(0, 0);
@ -391,78 +450,83 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
this.range = dataSet.getEntryCount() - 1;
if (this.range >= 1) {
let prev: EntryOhos = dataSet.getEntryForIndex(this.min);
let cur: EntryOhos = prev;
var commandsData: string = '';
var commandsDataFill: string = '';
if(dataSet.getFillStyle() == FillStyle.MIN){
commandsDataFill = 'M' + firstPointX + ' ' + minY;
if (dataSet.getFillStyle() == FillStyle.MIN) {
commandsDataFill = 'M' + firstPointX + ' ' + minY;
} else {
commandsDataFill = 'M' + firstPointX + ' ' + maxY;
commandsDataFill = 'M' + firstPointX + ' ' + maxY;
}
let startAddY: number;
let yAxis: YAxis = dataSet.getAxisDependency() == AxisDependency.LEFT ? this.yleftAxis : this.yRightAxis;
if (!this.isInverted) {
startAddY = Utils.convertDpToPixel(this.getYPosition((yAxis.getAxisMaximum() - cur.getY() * this.animateYValue) * yScale));
startAddY = Utils.convertDpToPixel(
this.getYPosition((yAxis.getAxisMaximum() - cur.getY() * this.animateYValue) * yScale)
);
} else {
startAddY = Utils.convertDpToPixel(this.getYPosition((cur.getY() * this.animateYValue) * yScale));
startAddY = Utils.convertDpToPixel(this.getYPosition(cur.getY() * this.animateYValue * yScale));
}
commandsDataFill += " L"+Utils.convertDpToPixel(this.getXPosition(cur.getX() * xScale)) + " " + startAddY
commandsDataFill += ' L' + Utils.convertDpToPixel(this.getXPosition(cur.getX() * xScale)) + ' ' + startAddY;
commandsData = "M" + Utils.convertDpToPixel(this.getXPosition(cur.getX()) * xScale) + " " + startAddY;
commandsData = 'M' + Utils.convertDpToPixel(this.getXPosition(cur.getX()) * xScale) + ' ' + startAddY;
for (let j = this.min + 1; j <= this.range + this.min; j++) {
if(j > this.animateXIndex){
if (j > this.animateXIndex) {
break;
}
prev = cur;
cur = dataSet.getEntryForIndex(j);
let realY1: number = this.isInverted ? (prev.getY() * this.animateYValue) : (yAxis.getAxisMaximum() - prev.getY() * this.animateYValue);
let x1 = Utils.convertDpToPixel(this.getXPosition(((prev.getX()) + (cur.getX() - prev.getX()) / 2) * xScale));
let realY1: number = this.isInverted
? prev.getY() * this.animateYValue
: yAxis.getAxisMaximum() - prev.getY() * this.animateYValue;
let x1 = Utils.convertDpToPixel(this.getXPosition((prev.getX() + (cur.getX() - prev.getX()) / 2) * xScale));
let y1 = Utils.convertDpToPixel(this.getYPosition(realY1 * yScale));
let realY2: number = this.isInverted ? (cur.getY() * this.animateYValue) : (yAxis.getAxisMaximum() - cur.getY() * this.animateYValue);
let x2 = Utils.convertDpToPixel(this.getXPosition(((prev.getX()) + (cur.getX() - prev.getX()) / 2) * xScale));
let realY2: number = this.isInverted
? cur.getY() * this.animateYValue
: yAxis.getAxisMaximum() - cur.getY() * this.animateYValue;
let x2 = Utils.convertDpToPixel(this.getXPosition((prev.getX() + (cur.getX() - prev.getX()) / 2) * xScale));
let y2 = Utils.convertDpToPixel(this.getYPosition(realY2 * yScale));
let realY3: number = this.isInverted ? (cur.getY() * this.animateYValue) : (yAxis.getAxisMaximum() - cur.getY() * this.animateYValue);
let realY3: number = this.isInverted
? cur.getY() * this.animateYValue
: yAxis.getAxisMaximum() - cur.getY() * this.animateYValue;
let x3 = Utils.convertDpToPixel(this.getXPosition(cur.getX() * xScale));
let y3 = Utils.convertDpToPixel(this.getYPosition(realY3 * yScale));
commandsData += " C" + x1 + " " + y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3;
commandsDataFill += " C" + x1 + " " + y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3;
commandsData += ' C' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2 + ' ' + x3 + ' ' + y3;
commandsDataFill += ' C' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2 + ' ' + x3 + ' ' + y3;
}
if(dataSet.getFillStyle() == FillStyle.MIN){
commandsDataFill += " L" + lastPointX + " " + minY;
if (dataSet.getFillStyle() == FillStyle.MIN) {
commandsDataFill += ' L' + lastPointX + ' ' + minY;
} else {
commandsDataFill += " L" + lastPointX + " " + maxY;
commandsDataFill += ' L' + lastPointX + ' ' + maxY;
}
}
return this.creatPathPaintArr(dataSet,commandsData,commandsDataFill);
return this.creatPathPaintArr(dataSet, commandsData, commandsDataFill);
}
public drawCircle(): Paint[]{
public drawCircle(): Paint[] {
let circlePaints: Paint[] = new Array();
let xScale: number = this.pathViewModel.xScale;
let yScale: number = 1;
for (let index = 0; index < this.lineData.getDataSetCount(); index++) {
let lineDataSet: LineDataSet = this.lineData.getDataSetByIndex(index) as LineDataSet;
if(!lineDataSet.isDrawCirclesEnabled()){
if (!lineDataSet.isDrawCirclesEnabled()) {
continue;
}
if(lineDataSet.getAxisDependency() == AxisDependency.LEFT){
if (lineDataSet.getAxisDependency() == AxisDependency.LEFT) {
yScale = this.pathViewModel.yLeftScale;
} else {
yScale = this.pathViewModel.yRightScale;
@ -470,13 +534,13 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
let entryOhosY: number;
for (let i = 0; i < lineDataSet.getEntries().length(); i++) {
if(i > this.animateXIndex){
if (i > this.animateXIndex) {
break;
}
let circlePaint: CirclePaint = new CirclePaint();
if(!this.isInverted) {
if(lineDataSet.getAxisDependency() == AxisDependency.LEFT){
if (!this.isInverted) {
if (lineDataSet.getAxisDependency() == AxisDependency.LEFT) {
entryOhosY = this.yleftAxis.getAxisMaximum() - lineDataSet.getEntries().at(i).getY() * this.animateYValue;
} else {
entryOhosY = this.yRightAxis.getAxisMaximum() - lineDataSet.getEntries().at(i).getY() * this.animateYValue;
@ -486,12 +550,12 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
}
let xx: number = lineDataSet.getEntries().at(i).getX() * xScale;
let yy: number = entryOhosY * yScale;
circlePaint.setDrawCircles(lineDataSet.isDrawCirclesEnabled())
circlePaint.setCirclesColor(lineDataSet.getCircleColor())
circlePaint.setCircleRadius(lineDataSet.getCircleRadius())
circlePaint.setDrawCircleHole(lineDataSet.isDrawCircleHoleEnabled())
circlePaint.setCircleHoleRadius(lineDataSet.getCircleHoleRadius())
circlePaint.setCircleHoleColor(lineDataSet.getCircleHoleColor())
circlePaint.setDrawCircles(lineDataSet.isDrawCirclesEnabled());
circlePaint.setCirclesColor(lineDataSet.getCircleColor());
circlePaint.setCircleRadius(lineDataSet.getCircleRadius());
circlePaint.setDrawCircleHole(lineDataSet.isDrawCircleHoleEnabled());
circlePaint.setCircleHoleRadius(lineDataSet.getCircleHoleRadius());
circlePaint.setCircleHoleColor(lineDataSet.getCircleHoleColor());
circlePaint.setX(xx * this.pathViewModel.scaleX + this.pathViewModel.moveX - this.pathViewModel.currentXSpace);
circlePaint.setY(yy * this.pathViewModel.scaleY + this.pathViewModel.moveY - this.pathViewModel.currentYSpace);
@ -501,8 +565,8 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
return circlePaints;
}
public drawValues():Paint[]{
let textPaints:Paint[] = new Array();
public drawValues(): Paint[] {
let textPaints: Paint[] = new Array();
let xScale: number = this.pathViewModel.xScale;
let yScale: number = 1;
@ -510,13 +574,13 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
for (let i = 0; i < this.lineData.getDataSetCount(); i++) {
let lineDataSet: LineDataSet = this.pathViewModel.getLineData().getDataSetByIndex(i) as LineDataSet;
if(!lineDataSet.isDrawValuesEnabled()){
if (!lineDataSet.isDrawValuesEnabled()) {
return [];
}
entryArray = lineDataSet.getEntries().toArray();
if(lineDataSet.getAxisDependency() == AxisDependency.LEFT){
if (lineDataSet.getAxisDependency() == AxisDependency.LEFT) {
yScale = this.pathViewModel.yLeftScale;
} else {
yScale = this.pathViewModel.yRightScale;
@ -525,15 +589,14 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
let entryOhosY: number;
let xx: number;
let yy: number;
let value: string
let value: string;
for (let i = 0; i < entryArray.length; i++) {
if(i > this.animateXIndex){
if (i > this.animateXIndex) {
break;
}
let textPaint:TextPaint = new TextPaint();
if(!this.isInverted) {
if(lineDataSet.getAxisDependency() == AxisDependency.LEFT){
let textPaint: TextPaint = new TextPaint();
if (!this.isInverted) {
if (lineDataSet.getAxisDependency() == AxisDependency.LEFT) {
entryOhosY = this.yleftAxis.getAxisMaximum() - entryArray[i].getY() * this.animateYValue;
} else {
entryOhosY = this.yRightAxis.getAxisMaximum() - entryArray[i].getY() * this.animateYValue;
@ -542,8 +605,8 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
entryOhosY = entryArray[i].getY() * this.animateYValue;
}
value = Math.floor(entryArray[i].getY()).toString();
xx = entryArray[i].getX() * xScale * this.pathViewModel.scaleX - Utils.calcTextWidth(textPaint,value) / 2;
yy = entryOhosY * yScale * this.pathViewModel.scaleY - Utils.calcTextHeight(textPaint,value) - 2;
xx = entryArray[i].getX() * xScale * this.pathViewModel.scaleX - Utils.calcTextWidth(textPaint, value) / 2;
yy = entryOhosY * yScale * this.pathViewModel.scaleY - Utils.calcTextHeight(textPaint, value) - 2;
textPaint.setText(value);
textPaint.setX(xx + this.pathViewModel.moveX - this.pathViewModel.currentXSpace);
textPaint.setY(yy + this.pathViewModel.moveY - this.pathViewModel.currentYSpace);
@ -553,21 +616,21 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
return textPaints;
}
private creatPathPaintArr(dataSet: LineDataSet, commandsData: string,commandsDataFill ? : string): Paint[]{
let pathPaints:Paint[] = new Array();
private creatPathPaintArr(dataSet: LineDataSet, commandsData: string, commandsDataFill?: string): Paint[] {
let pathPaints: Paint[] = new Array();
let pathPaint: PathPaint = new PathPaint();
pathPaint.setCommands(commandsData);
pathPaint.setAxisDependency(dataSet.getAxisDependency());
pathPaint.setStrokeWidth(dataSet.getLineWidth());
pathPaint.setStroke(dataSet.getColor())
pathPaint.setDashPathEffect(dataSet.getDashPathEffect())
pathPaint.setStroke(dataSet.getColor());
pathPaint.setDashPathEffect(dataSet.getDashPathEffect());
if(dataSet.isDrawFilledEnabled()){
if (dataSet.isDrawFilledEnabled()) {
let pathFillPaint: PathFillPaint = new PathFillPaint();
pathFillPaint.setCommandsFill(commandsDataFill);
pathFillPaint.setDrawFilled(dataSet.isDrawFilledEnabled());
pathFillPaint.setGradientFillColor(dataSet.getGradientFillColor())
pathFillPaint.setGradientFillColor(dataSet.getGradientFillColor());
pathPaints.push(pathFillPaint);
}
@ -576,11 +639,11 @@ export default class LineChartRenderer extends LineScatterCandleRadarRenderer {
return pathPaints;
}
public animateX(animateIndex: number){
public animateX(animateIndex: number) {
this.animateXIndex = animateIndex;
}
public animateY(animateYValue: number){
public animateY(animateYValue: number) {
this.animateYValue = animateYValue;
}
}

Some files were not shown because too many files have changed in this diff Show More