首页 / 浏览问题 / 移动GIS / 问题详情
iOS端二维开发中ChartView如何使用?
21EXP 2021年09月14日

使用版本:10.0.1 

ChartView如何使用?是否能根据一个图层中的数据达到如下图所示效果

1个回答

可以达到这个效果,具体使用可以参考联机帮助手册上的ChartView接口说明http://support.supermap.com.cn/DataWarehouse/WebDocHelp/iMobileForIos/SuperMapiMobileForiOSHelp.htm

1,752EXP 2021年09月15日

要是看得明白就不会提问了crying

-(void)showPieChart:(Layer *)layer{

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

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

    [pie setAlpha:0.6];

    

    UIColor *co0 = [UIColor colorWithRed:205/255 green:107/255 blue:121/255 alpha:1.0];

    UIColor *co1 = [UIColor colorWithRed:247/255 green:254/255 blue:143/255 alpha:1.0];

    UIColor *co2 = [UIColor colorWithRed:251/255 green:255/255 blue:96/255 alpha:1.0];

    UIColor *co3 = [UIColor colorWithRed:231/255 green:145/255 blue:143/255 alpha:1.0];

    UIColor *co4 = [UIColor colorWithRed:202/255 green:162/255 blue:126/255 alpha:1.0];

    UIColor *co5 = [UIColor colorWithRed:143/255 green:222/255 blue:251/255 alpha:1.0];

    UIColor *co6 = [UIColor colorWithRed:60/255 green:109/255 blue:39/255 alpha:1.0];

    

    NSArray *va0 = [NSArray arrayWithObject:@0.0716];

    NSArray *va1 = [NSArray arrayWithObject:@0.0858];

    NSArray *va2 = [NSArray arrayWithObject:@0.1572];

    NSArray *va3 = [NSArray arrayWithObject:@0.1662];

    NSArray *va4 = [NSArray arrayWithObject:@0.1666];

    NSArray *va5 = [NSArray arrayWithObject:@0.1762];

    NSArray *va6 = [NSArray arrayWithObject:@0.1764];

    

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

    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];

    [pie addChartDatas:dataset];

    [layer addChart:pie];

    [pie startPlay];

}

研究好久就写出这个方法 但是不对。。也不知道哪里有问题,能不能写一段示例代码参考一下

...