0

I'm trying to graph various small values in a line chart, but it's not working. It just makes a big line.

setSeries function

private void setSeries(){
    XYChart.Series series = new XYChart.Series();
    start = 0.01;
    for (int i = 0; i < sounds.size(); i++) {
        series.getData().add(new XYChart.Data<>(Math.sin(2.0*Math.PI*getFrequencyNote(sounds.get(i).Vol,notes.indexOf(sounds.get(i).Note))*start) + "", start));
        System.out.println(Math.sin(2.0*Math.PI*getFrequencyNote(sounds.get(i).Vol,notes.indexOf(sounds.get(i).Note))*start));
        start += 0.01;
    }
    SoundGraph.getData().add(series);
}

getFrequency function

private double value = Math.pow(2,1.0/12.0);
private double getFrequencyNote(double oct, double note){
    return 440*Math.pow( value , (oct-4)*12 + (note - 10) );
}

The LineChart SoundGraph in not used before. "sounds" is a list of a class I made which contains a double for vol, and Note is a string, but I only need the index of an other list to use the getFrequency function.

I'm using Java SE 10, Javafx. These are the results: Image of the graphic

Values

-0.8020843062860846,
 0.9580268553320735,
 0.9973557960766156,
-0.8446351001370388,
-0.9512778105761924,
 0.1449623768717014,
-0.2301723191097895,
-0.9997705757517672,
-0.9894395527823209,
 0.4887761842135673,
 0.81474751877591,
-0.9849431403051101,
 0.4495554901763745,
-0.3477891889816327,
 0.1555506540644018,
 0.7280882151244978,
 0.11499335080804679,
 0.4227021204675916,
 0.9978519665255616,
 0.9501664522040059,
-0.8731531393300894,
 0.9983904297633855,
-0.9909331059657619,
 0.6125702128979333,
-0.9570691237579619,
 0.8950210873763147,
 0.0017581396656234664,
 0.6521553395245636,
-0.39306730640652926,
 0.9992498113928694,
-0.11310002999268495,
-0.08557982614432237,
 0.6444322301559682,
 0.14807529636552533,
 0.6309415311077592,
 0.8671951169285017,
-0.6238825080225738,
-0.7256733664647849,
 0.10651890266625182,
-0.9942696556523624,
-0.44641179085560256,
 0.8512299966259365,
-0.7292922654748821,
-0.6190887279747803,
-0.7469772343384066,
-0.2662759469316001,
 0.6796190835594168,
 0.6403901381336917,
-0.9984885989706641,
 0.9364223936822729,
-0.25576596448581923,
-0.48827388585839016,
-0.2818940265631654,
-0.0035162738966224957,
-0.9987958639647898,
 0.9994748271680698,
-0.3872420445435474,
 0.853566897318016,
 0.9980774069098237,
 0.5848859750411508,
-0.9588838044715969,
 0.607557284685807
Michael
  • 41,989
  • 11
  • 82
  • 128
Mario Tp
  • 53
  • 4
  • Welcome to SO. " It just makes a big line" - what is the expected output ? – c0der Jun 06 '18 at 05:01
  • 2
    For quick and efficient help, please post [mcve]. Your mcve can be as simple as [this](https://ide.geeksforgeeks.org/SYXZ2dpQ1Z). I find mcve a very useful technique. Not only it makes helping much easier, it is a powerful debugging tool. It many case, while preparing one, you are likely to find the problem. – c0der Jun 06 '18 at 05:39

0 Answers0