protected bool Equals(Greeks other) { return(Gamma.AlmostEqual(other.Gamma, 4) && Delta.AlmostEqual(other.Delta, 4) && Theta.AlmostEqual(other.Theta, 4) && Vega.AlmostEqual(other.Vega, 4) && Rho.AlmostEqual(other.Rho, 4) && RhoFx.AlmostEqual(other.RhoFx, 4) && Sigma.AlmostEqual(other.Sigma, 4)); }
private static void NewMethod1() { var names = "a b c d e f g h i".Split(" "); var values = new[] { 28, 55, 43, 91, 81, 53, 19, 87, 52 }; var source = names.Zip(values, (f, s) => new { name = f, value = s }); Vega.SetData(source) .SetMark(Vega.Marks.Bar) .SetEncoding(x: "name:N", y: "value:Q") .ToFile("res.html"); }
private static void NewMethod2() { var url = @"https://vega.github.io/vega-datasets/data/movies.json"; Vega.SetData(url) .SetMark(Vega.Marks.Bar) .SetEncoding(en => { en.X = Vega.PcField("IMDB_Rating:Q").SetBin(true); en.Y = Vega.PcField().SetAggregate("count"); }) .ToFile("res.html"); }
public override int GetHashCode() { unchecked { int hashCode = Gamma.GetHashCode(); hashCode = (hashCode * 397) ^ Delta.GetHashCode(); hashCode = (hashCode * 397) ^ Theta.GetHashCode(); hashCode = (hashCode * 397) ^ Vega.GetHashCode(); hashCode = (hashCode * 397) ^ Rho.GetHashCode(); hashCode = (hashCode * 397) ^ RhoFx.GetHashCode(); hashCode = (hashCode * 397) ^ Sigma.GetHashCode(); return(hashCode); } }
/// <summary> /// https://vega.github.io/vega-lite/docs/sort.html#sort-by-encoding /// </summary> private static void NewMethod8() { var url = @"https://vega.github.io/vega-datasets/data/population.json"; var cm = Vega.SetData(url) .SetMark(Vega.Marks.Bar) .SetEncoding(en => { en.Y = Vega.PcField().SetName("age:O").SetSort("-x"); en.X = Vega.PcField().SetName("people:Q") .SetAggregate("sum"); }) .SetFilter(d => d.Number("year") == 2000); cm.ToFile("res.html"); }
private static void test2() { var names = "a b c d e f g h i".Split(" "); var values = new[] { 28, 55, 43, 91, 81, 53, 19, 87, 52 }; var source = names.Zip(values, (f, s) => new { name = f, value = s }); var cond = Vega.ColorCondition(d => d.Number("value") > 60, Color.Red); Vega.SetData(source) .SetMark(Vega.Marks.Bar) .SetEncoding( Vega.Y("value:Q"), Vega.X("name:N"), Vega.Color(condition: cond, color: Color.Blue) ) .ToFile("res.html"); }
public static SamplesResult NewMethod1() { var names = "a b c d e f g h i".Split(' '); var values = new[] { 28, 55, 43, 91, 81, 53, 19, 87, 52 }; var source = names.Zip(values, (f, s) => new { name = f, value = s }); var res = Vega.SetData(source) .SetMark(Vega.Marks.Bar) .SetEncoding(x: "name:N", y: "value:Q") .ToHtml(); return(new SamplesResult { Desc = "普通柱状图", Html = res }); }
public static SamplesResult NewMethod2() { var url = @"https://vega.github.io/vega-datasets/data/movies.json"; var res = Vega.SetData(url) .SetMark(Vega.Marks.Bar) .SetEncoding(en => { en.X = Vega.PcField("IMDB_Rating:Q").SetBin(true); en.Y = Vega.PcField().SetAggregate("count"); }) .ToHtml(); return(new SamplesResult { Desc = "柱状图,y轴直接指定聚合 count,按x轴统计个数", Html = res }); }
/// <summary> /// https://vega.github.io/vega-lite/docs/sort.html#sort-by-encoding /// </summary> public static SamplesResult NewMethod8() { var url = @"https://vega.github.io/vega-datasets/data/population.json"; var cm = Vega.SetData(url) .SetMark(Vega.Marks.Bar) .SetEncoding(en => { en.Y = Vega.PcField().SetName("age:O").SetSort("-x"); en.X = Vega.PcField().SetName("people:Q") .SetAggregate("sum"); }) .SetFilter(d => d.Number("year") == 2000); return(new SamplesResult { Desc = "Y轴按x轴值倒序排序", Html = cm.ToHtml() }); }
private static void NewMethod3() { var url = @"https://vega.github.io/vega-datasets/data/stocks.csv"; var cm = Vega.SetData(url) .SetEncoding(en => { en.X = Vega.PcField("date:T"); en.Y = Vega.PcField("price:Q"); en.Color = Vega.McField("symbol:N"); }) .SetFilter(d => d.String("symbol") == "GOOG") //.SetFilter("datum.symbol == 'GOOG'") ; var line = cm.SetMark(Vega.Marks.Line); var point = cm.SetMark(Vega.Marks.Point); (line + point).ToFile("res.html"); }
public static SamplesResult NewMethod3() { var url = @"https://vega.github.io/vega-datasets/data/stocks.csv"; var cm = Vega.SetData(url) .SetEncoding(en => { en.X = Vega.PcField("date:T"); en.Y = Vega.PcField("price:Q"); en.Color = Vega.McField("symbol:N"); }) .SetFilter(d => d.String("symbol") == "GOOG") //.SetFilter("datum.symbol == 'GOOG'") ; var line = cm.SetMark(Vega.Marks.Line); var point = cm.SetMark(Vega.Marks.Point); return(new SamplesResult { Desc = "点图 + 线图 叠加", Html = (line + point).ToHtml() }); }
private static void NewMethod4() { var url = @"https://vega.github.io/vega-datasets/data/stocks.csv"; var cond = Vega.Condition() .AddTest(d => d.Number("price") > 400) .AddValue(Color.Red); var cm = Vega.SetData(url) .SetEncoding(en => { en.X = Vega.PcField().SetName("date:T"); en.Y = Vega.PcField().SetName("price:Q"); en.Color = cond.ToColor(Color.Blue); }) .SetFilter(d => d.String("symbol") == "GOOG") ; var line = cm.SetMark(Vega.Marks.Line); var point = cm.SetMark(Vega.Marks.Point); (line + point).ToFile("res.html"); }