Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of UUChart

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

I. brief introduction

UUChart is a third party for drawing charts, especially for drawing line charts. When I do another hospital-related project, I need to monitor the blood pressure within a week, and I need to draw a line chart to show the trend of high pressure and low pressure.

2. Download address:

Https://github.com/ZhipingYang/UUChartView

III. Use

The first step is to extract the downloaded file with a UUChar folder inside, and then drag the entire folder into the project. We will find that there are UUBar.h, UUChart.h and other files, these are the specific implementation of UUChart.

Second, we need to introduce in the referenced .h file

# import "UUChart.h"

Then implement the agent

@ interface BloodPressureViewController: BaseViewController

Then we need to instantiate a UUChart. What I instantiated myself is: UUChart * bloodPressureCharView

Instantiate three arrays:

NSMutableArray * xValues; / / this is Abscissa content NSMutableArray * yValues1; / / this is vertical coordinate content (high voltage) NSMutableArray * yValues2; / / this is vertical coordinate content (low voltage)

The third step is to realize the agent method.

# pragma mark-UUCharView Delegate// this method returns the Abscissa of the instantiated line chart-(NSArray *) UUChart_xLableArray: (UUChart *) chart {return xValues;} / / the method returns the vertical coordinate of the instantiated line chart (if one is a line chart, I need to show high voltage and low voltage here, so I return two)-(NSArray *) UUChart_yValueArray: (UUChart *) chart {return @ [yValues1,yValues2] } / / the range of ordinates is returned here. -(CGRange) UUChartChooseRangeInLineChart: (UUChart *) chart {return CGRangeMake (200Co.0);} / / this is used to set whether the maximum and minimum values are displayed. -(BOOL) UUChart: (UUChart *) chart ShowMaxMinAtIndex: (NSInteger) index {return YES;} / / Color array-(NSArray *) UUChart_ColorArray: (UUChart *) chart {return @ [UUGreen,UURed,UUBrown];}-(BOOL) UUChart: (UUChart *) chart ShowHorizonLineAtIndex: (NSInteger) index {return YES;}

Step 4, we can put the data we need to set into three arrays.

Beside the point, I need a function to display the ordinates of all the points in the line chart, so I can modify the UUChart slightly. The modification method is as follows:

Locate UULineChar.m and find the following code:

-(void) addPoint: (CGPoint) point index: (NSInteger) index isShow: (BOOL) isHollow value: (CGFloat) value {UIView * view = [[UIView alloc] initWithFrame:CGRectMake (5,5,8,8)]; view.center = point; view.layer.masksToBounds = YES; view.layer.cornerRadius = 4; view.layer.borderWidth = 2; view.layer.borderColor = [[_ colors objectAtIndex:index] CGColor]? [[_ colors objectAtIndex:index] CGColor]: UUGreen.CGColor If (isHollow) {view.backgroundColor = [UIColor whiteColor];} else {view.backgroundColor = [_ colors objectAtIndex:index]? [_ colors objectAtIndex:index]: UUGreen; UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake (point.x-UUTagLabelwidth/2.0, point.y-UULabelHeight*2, UUTagLabelwidth, UULabelHeight)]; label.font = [UIFont systemFontOfSize:10]; label.textAlignment = NSTextAlignmentCenter; label.textColor = view.backgroundColor Label.text = [NSString stringWithFormat:@ "% d", (int) value]; [self addSubview:label];} [self addSubview:view];}

We just need to get rid of the if else judgment. That is,

-(void) addPoint: (CGPoint) point index: (NSInteger) index isShow: (BOOL) isHollow value: (CGFloat) value {UIView * view = [[UIView alloc] initWithFrame:CGRectMake (5,5,8,8)]; view.center = point; view.layer.masksToBounds = YES; view.layer.cornerRadius = 4; view.layer.borderWidth = 2; view.layer.borderColor = [[_ colors objectAtIndex:index] CGColor]? [[_ colors objectAtIndex:index] CGColor]: UUGreen.CGColor / / if (isHollow) {/ / view.backgroundColor = [UIColor whiteColor]; / /} else {view.backgroundColor = [_ colors objectAtIndex:index]? [_ colors objectAtIndex:index]: UUGreen; UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake (point.x-UUTagLabelwidth/2.0, point.y-UULabelHeight*2, UUTagLabelwidth, UULabelHeight)]; label.font = [UIFont systemFontOfSize:10]; label.textAlignment = NSTextAlignmentCenter Label.textColor = view.backgroundColor; label.text = [NSString stringWithFormat:@ "% d", (int) value]; [self addSubview:label]; / /} [self addSubview:view];}

In this way, the vertical coordinates of all points can be displayed. The effect is shown in the figure

Additional request processing source code is attached. I hope you can use it.

View Code

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report