Sorry, it is me again

This time [ScottPlot](https://scottplot.net/) is used.

Although [ScottPlot](https://scottplot.net/) can plot on GUI, even in 
interactive way, but I know nothing about .NET GUI programming. So the simplest 
code from [ScottPlot](https://scottplot.net/) which tries to save plotting into 
file is used.
    
    
    double[] xs = { 1, 2, 3, 4, 5 };
    double[] ys = { 1, 4, 9, 16, 25 };
    var plt = new ScottPlot.Plot(400, 300);
    plt.AddScatter(xs, ys);
    plt.SaveFig("quickstart.png");
    
    
    Run

first try on the array, but failed with `Error: unhandled exception: variant is 
not a object (0x80004002) [CLRError]`
    
    
    import sugar, strutils
    import winim/clr
    
    var mscor = load("mscorlib")
    
    var Array = mscor.GetType("System.Array")
    dump Array
    
    var Double = mscor.GetType("System.Double")
    dump Double
    
    var Int32 = mscor.GetType("System.Int32")
    dump Int32
    
    var xs = @Array.CreateInstance(Double, 5)
    echo xs
    
    for i in 1 .. 5:
        xs.SetValue(i[Double], (i-1)[Int32])
        echo i[Double]
    
    for i in 0 ..< 5:
        echo xs.GetValue(i)
    
    
    
    Run

second but wierd try on the array 
    
    
    import sugar
    import winim/clr
    
    var code = """
    using System;
    
    public class Test {
        public double[] dataX = new double[] { 1, 2, 3, 4, 5 };
        public double[] dataY = new double[] { 1, 4, 9, 16, 25 };
    }
    """
    var res = compile(code)
    var o = res.CompiledAssembly.new("Test")
    
    var xs = o.dataX
    var ys = o.dataY
    
    echo xs
    echo ys
    
    
    
    Run

says 
    
    
    VT_ARRAY(1D)|VT_R8
    VT_ARRAY(1D)|VT_R8
    
    
    
    Run

then the plotting part is added but failed to run with `Error: unhandled 
exception: unable to invoke specified member: CreateInstance (0x80131604) 
[CLRError]`
    
    
    import sugar
    import winim/clr
    
    var code = """
    using System;
    
    public class Test {
        public double[] dataX = new double[] { 1, 2, 3, 4, 5 };
        public double[] dataY = new double[] { 1, 4, 9, 16, 25 };
    }
    """
    var res = compile(code)
    var o = res.CompiledAssembly.new("Test")
    
    var xs = o.dataX
    var ys = o.dataY
    
    var ScottPlot = load("ScottPlot.dll")
    var Plot = ScottPlot.GetType("ScottPlot.Plot")
    dump Plot
    
    # Error: unhandled exception: unable to invoke specified member: 
CreateInstance (0x80131604) [CLRError]
    var plt = @Plot.new(400, 300);
    
    plt.AddScatter(xs, ys);
    plt.SaveFig("console.png");
    
    
    
    Run

any tips? Thanks

Reply via email to