Skip to content

Instantly share code, notes, and snippets.

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
package com.xxmassdeveloper.mpchartexample;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.WindowManager;
//: Playground 2: Same as 1 with added container view and "random" changes of its size/position between zoom/pan. Everything works
import UIKit
import PlaygroundSupport
let domainPoint = CGPoint(x: 5, y: 5)
// The following variables are simplified ranges - all start with 0
let xDomain: CGFloat = 10
let yDomain: CGFloat = 10
//: Playground 1: Simple setup, everything works.
import UIKit
import PlaygroundSupport
let domainPoint = CGPoint(x: 5, y: 5)
// The following variables are simplified ranges - all start with 0
let xDomain: CGFloat = 10
let yDomain: CGFloat = 10
//
// AreasExample.swift
// SwiftCharts
//
// Created by ischuetz on 04/05/15.
// Copyright (c) 2015 ivanschuetz. All rights reserved.
//
import UIKit
import SwiftCharts
@ivnsch
ivnsch / autolayout.swift
Last active August 20, 2018 00:09
Chart with autolayout
// NOTE: you may have to set the module in the storyboard to "SwiftCharts", otherwise the view may not be recognized correctly, which leads to axis, labels and guidelines not showing
class HelloWorld: UIViewController {
private var chart: Chart? // arc
@IBOutlet weak var chartView: ChartBaseView!
private var didLayout: Bool = false
//
// ScatterExample.swift
// Examples
//
// Created by ischuetz on 16/05/15.
// Copyright (c) 2015 ivanschuetz. All rights reserved.
//
import UIKit
import CoreGraphics
@ivnsch
ivnsch / gist:b969cdb35c80fc721368
Last active August 29, 2015 14:16
Ranges mapping playground
// Playground containing the process I did today of looking for a generic way to get an object associated with a range, using Swift
// for example, given a mapping of range 0..<2 to a string "first range" and 2..<4 to a string "second range", we want to get the string for the value 3.4
// I started thinking about this because in my work I had to map rating ranges to certain background colors. So for example if a user gives a 5.9 rating (very good!) this would be in the range 4.5 - 6.0 which has to be displayed with a dark green background, etc. Sadly I had to do this using objc. I wondered how I would do it with Swift.
// The most simple way:
let n = 3.4
let found1:String? = {if n < 2 {
return "first"
} else if n < 4 {
return "second"