图表js直线(v1 vs v2)

时间:2016-04-21 07:15:44

标签: chart.js

尝试在Chart.js(http://www.chartjs.org

中绘制一条直线

charts.js straight lines - i cant find a solution

上述链接不起作用,我怀疑由于v1和v2之间存在差异。

- (void)getPathGoogleAPI_CallWithSource : (CLLocationCoordinate2D)sourceCoordinate andDestination: (CLLocationCoordinate2D)destinationCoordinate
{

    NSString *getDriverLocationURl;    
    NSDictionary *postParams = @{k_API_GoogleOrigin      : [NSString stringWithFormat:@"%f,%f", sourceCoordinate.latitude, sourceCoordinate.longitude],
                                 k_API_GoogleDestination : [NSString stringWithFormat:@"%f,%f",                                                          destinationCoordinate.latitude, destinationCoordinate.longitude],
                                };

    getDriverLocationURl = [NSString stringWithFormat:@"%@", GOOGLE_DIRECTION_URL];

    [serviceManager apiCallUsingDataTaskHTTPMethod:GET url:getDriverLocationURl andParameters:postParams forTask:kTaskDrawRoute currentView:self.view accessToken:NO completionHandler:^(id response, NSError *error, TaskType task, BOOL success)
    {
        if (!error && response)
        {
            if ([[response valueForKey:RESPONSE_STATUS] isEqualToString:RESPONSE_OK])
            {
                NSArray *routArr            = [response valueForKey:k_API_GoogleRoutes];

                GMSPath *path = [GMSPath pathFromEncodedPath:routArr[0][@"overview_polyline"][@"points"]];
                polyline = [GMSPolyline polylineWithPath:path];
                polyline.strokeColor = [UIColor blueColor];
                polyline.strokeWidth = 4.f;
                polyline.map = self.mapView;
            }
            else
            {
                DLog(@"Google Direction : %@", [response valueForKey:RESPONSE_ERROR_MESSAGE]);
            }
        }
        else
        {
            DLog(@"Google Direction : Sorry something went wrong");
        }
    }];
}

基于文档: http://nnnick.github.io/Chart.js/docs-v2/

上述方法为bezierCurve行显示预期的EXCEPT。 我需要点之间的直线,不能让它工作。 任何指向或引用不同的JS库都是值得赞赏的。

注意v1方法失败(.Line()) -

function newWin() {
var win = window.open("www.google.com") //should open new tab in chrome
}

1 个答案:

答案 0 :(得分:0)

我一直在找同样的事情。文档说它是lineTension:0,但它实际上是tension:0,这对我有用。

http://www.chartjs.org/docs/#line-chart