首页 / 浏览问题 / 移动GIS / 问题详情
ChartView使用问题
21EXP 2021年09月17日
-(void)showPieChart:(Layer *)layer{

    PieChart *piechart = [[PieChart alloc] initWithFrame:(CGRectMake(SCREEN_WIDTH-120, SCREEN_HEIGHT-150, 120, 150))];

    [piechart setTitle:@"土地规划占比"];

    [piechart setBackgroundColor:[UIColor blueColor]];

    [piechart setRadious:10.0f];

    [piechart setAlpha:0.6];

    

    UIColor *co0 = [UIColor colorWithRed:205.0f/255.0f green:107.0f/255.0f blue:121.0f/255.0f alpha:1.0f];

    UIColor *co1 = [UIColor colorWithRed:247.0f/255.0f green:254.0f/255.0f blue:143.0f/255.0f alpha:1.0f];

    UIColor *co2 = [UIColor colorWithRed:251.0f/255.0f green:255.0f/255.0f blue:96.0f/255.0f alpha:1.0f];

    UIColor *co3 = [UIColor colorWithRed:231.0f/255.0f green:145.0f/255.0f blue:143.0f/255.0f alpha:1.0f];

    UIColor *co4 = [UIColor colorWithRed:202.0f/255.0f green:162.0f/255.0f blue:126.0f/255.0f alpha:1.0f];

    UIColor *co5 = [UIColor colorWithRed:143.0f/255.0f green:222.0f/255.0f blue:251.0f/255.0f alpha:1.0f];

    UIColor *co6 = [UIColor colorWithRed:60.0f/255.0f green:109.0f/255.0f blue:39.0f/255.0f alpha:1.0f];

    

    NSNumber *num1 = [NSNumber numberWithFloat:0.0716f];

    NSNumber *num2 = [NSNumber numberWithFloat:0.0858f];

    NSNumber *num3 = [NSNumber numberWithFloat:0.1572f];

    NSNumber *num4 = [NSNumber numberWithFloat:0.1662f];

    NSNumber *num5 = [NSNumber numberWithFloat:0.1666f];

    NSNumber *num6 = [NSNumber numberWithFloat:0.1762f];

    NSNumber *num7 = [NSNumber numberWithFloat:0.1764f];

    NSArray *va0 = [NSArray arrayWithObject:num1];

    NSArray *va1 = [NSArray arrayWithObject:num2];

    NSArray *va2 = [NSArray arrayWithObject:num3];

    NSArray *va3 = [NSArray arrayWithObject:num4];

    NSArray *va4 = [NSArray arrayWithObject:num5];

    NSArray *va5 = [NSArray arrayWithObject:num6];

    NSArray *va6 = [NSArray arrayWithObject:num7];

    

    ChartPieData *piedata1 = [[ChartPieData alloc] initWithItemName:@"城镇建设用地" value:va0 color:co0 ID:234];

    ChartPieData *piedata2 = [[ChartPieData alloc] initWithItemName:@"一般农用地" value:va1 color:co1 ID:2];

    ChartPieData *piedata3 = [[ChartPieData alloc] initWithItemName:@"基本农田保护区" value:va2 color:co2 ID:3];

    ChartPieData *piedata4 = [[ChartPieData alloc] initWithItemName:@"村镇建设用地" value:va3 color:co3 ID:4];

    ChartPieData *piedata5 = [[ChartPieData alloc] initWithItemName:@"独立工矿用地区" value:va4 color:co4 ID:5];

    ChartPieData *piedata6 = [[ChartPieData alloc] initWithItemName:@"其它用地区" value:va5 color:co5 ID:6];

    ChartPieData *piedata7 = [[ChartPieData alloc] initWithItemName:@"生态环境安全控制区" value:va6 color:co6 ID:7];

    

    NSArray *dataset = [NSArray arrayWithObjects:piedata1, piedata2, piedata3, piedata4, piedata5, piedata6, piedata7, nil];

    [piechart addChartDatas:dataset];

    [layer addChart:piechart];

    

    [piechart startPlay];

    

}

以上为我写的显示饼状图的方法,参数为layer,不报错,但是也没有显示出来饼状图。

怎么解决问题???

1个回答

看代码没什么问题,layer参数是如何传的?在地图上打开了吗?
1,737EXP 2021年09月17日
这个方法是在添加图层的同时调用的,参数layer为添加数据集的方法返回值。如果看不出来问题的话麻烦你写个可以用的方法给我,或者把我这个方法测试一下找一下问题。

另外问一下rest服务的查询有哪些方法?除了SQLQuery之外可以像WEB端那样根据源数据,也就是data服务区查询吗?如果用SQLQuery查询某个rest服务,怎么根据指定字段的值去生产CHaretView?

问题比较多,希望多指点一下,不胜感激!
...