gyetvan-andras / chart.js-objc-wrapper Goto Github PK
View Code? Open in Web Editor NEWAn Objective-C wrapper around Chart.js.
License: MIT License
An Objective-C wrapper around Chart.js.
License: MIT License
Hi,
Love the library, just starting to use it and absolutely love it. I am struggling though with trying to figure out how to declare and pass options like a legend to my line graph. Can you give an example of how that can be done?
I should have posted this earlier but this is the code I have so far but its throwing a javascript exception error.
- (void)addLine {
NSArray* labels = @[@"A",@"B",@"C",@"D"];
NSMutableArray* datasets = [NSMutableArray array];
for(NSInteger i = 1; i < 4; i++) {
CWPointDataSet* ds = [[CWPointDataSet alloc] initWithData:@[@([self random:100]),@([self random:100]),@([self random:100]),@([self random:100])]];
ds.label = [NSString stringWithFormat:@"Label %ld",i];
CWColor* c1 = [[CWColors sharedColors] pickColor];
CWColor* c2 = [c1 colorWithAlphaComponent:0.5f];
ds.fillColor = c2;
ds.strokeColor = c1;
[datasets addObject:ds];
}
CWLineChartOptions* opt = [[CWLineChartOptions alloc] init];
int varGrid = 1;
opt.legendTemplate = @"<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].strokeColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>";
opt.scaleGridLineWidth = [NSNumber numberWithInt:varGrid];
CWLineChartData* lcd = [[CWLineChartData alloc] initWithLabels:labels andDataSet:datasets];
self.lineChart = [[CWLineChart alloc] initWithWebView:self.webview name:@"LineChart1" width:300 height:200 data:lcd options:opt];
[self.lineChart addChart];
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.