简体   繁体   中英

Update flot chart with slider

Hi I have two scripts and want to make one of them. I get the value of the slider into the chart but if I use the slider the chart don't make changes. I tried different plot.draw(); but I don't find an working solution.

What I must do? Can you help me please?

$(function () {

    /*--------------------------------------------------
    Plugin: Slider
    --------------------------------------------------*/

    /* Increment Slider */
    $( "#incrementSlider" ).slider({
        range: "min",
        value:1500,
        min: 0,
        max: 10000,
        step: 100,
        slide: function( event, ui ) {
            $( "#incrementAmount" ).text ("TXT: " +  ui.value + "€");

        }
    });

    $( "#incrementAmount" ).text ( "TXT: " + $( "#incrementSlider" ).slider( "value" ) + "€" );


    var ds = [];
    var data = [];

    ds.push ([[1,$( "#incrementSlider" ).slider( "value" )]]);
    ds.push ([[1,$( "#incrementSlider" ).slider( "value" ) - $( "#incrementSlider" ).slider( "value" ) / 100 * 19,5]]);
    ds.push ([[1,$( "#incrementSlider" ).slider( "value" ) / 100 * 19,5]]);

    data.push ({
        data: ds[0], 
        label: 'Graph1', 
        bars: {
        barWidth: 0.15, 
            order: 1
        }
    });
    data.push   ({
        data: ds[1], 
        label: 'Graph2', 
        bars: {
        barWidth: 0.15, 
            order: 2
        }
    });
    data.push ({
        data: ds[2], 
        label: 'Graph3', 
        bars: {
        barWidth: 0.15, 
            order: 3
        }
    });

    Charts.vertical ('#vertical-chart', data);


});

plot.draw()不会重置数据或缩放轴,重新绘制整个图形会更容易(在性能方面,您不会注意到差异)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM