Welcome Guest Search | Active Topics |

line chart with a very long buttom axis
bloomingdals
#1 Posted : Wednesday, May 8, 2013 9:07:25 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/3/2013(UTC)
Posts: 9

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hello every one,
i'm trying to generate a line chart with axis zooming. the code works fine for me but i wan't to modify it as follow: Actually, bottom axis represent dates that i get from an SQL column. the problem that the number of these dates can be very big, so it's not convenient to let them be all visible on the chart.

how can force the chart to let (for exemple) only the last 5 values be visible (the reste could be read if we use the axis zooming)??

thank you!
Dragan
#2 Posted : Thursday, May 9, 2013 12:32:39 PM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

You can try converting your date labels from SQL to true date values (new Date() in JavaScript). In this case jqChart will display the labels on the axis correctly.
Best Regards,
Dragan Matek
jqChart Inc.
bloomingdals
#3 Posted : Tuesday, May 14, 2013 5:17:34 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/3/2013(UTC)
Posts: 9

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi again,
beleive me t've tried every thing i could to get this chart work but it doesn't. I'm running out of time and i' can't get forward with my project because of my unability to yse correctly the plugin.
the problem that i have almost 1000 point to represent in my line chart (so 1000 date to put on the axis dateTime). but with already 10 dates the chart starts to look weird.

here there is my hole php file please please if you have some time give it a try may be it would work with you.

thank you a lot.
Code:

<?php
// Connexion to the data base
$db = mysql_connect('localhost', 'root', 'Orange2424')  or die('Erreur de connexion '.mysql_error());
mysql_select_db('OrangeTunisie',$db)  or die('Erreur de sélection '.mysql_error());

$query = mysql_query("SELECT * from Prefix_Count_History");

$name_chart = "Prefix_Count_History";
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>
    Line Chart on a DateTime Axis Example - HTML5 jQuery Chart Plugin by jqChart
</title>
    <link rel="stylesheet" type="text/css" href="../css/jquery.jqChart.css" />
    <link rel="stylesheet" type="text/css" href="../css/jquery.jqRangeSlider.css" />
    <link rel="stylesheet" type="text/css" href="../themes/smoothness/jquery-ui-1.8.21.css" />
    <script src="../js/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="../js/jquery.jqChart.min.js" type="text/javascript"></script>
    <script src="../js/jquery.jqRangeSlider.min.js" type="text/javascript"></script>
    <!--[if IE]><script lang="javascript" type="text/javascript" src="../js/excanvas.js"></script><![endif]-->
   
    <script lang="javascript" type="text/javascript">
        $(document).ready(function () {
            var background = {
                type: 'linearGradient',
                x0: 0,
                y0: 0,
                x1: 0,
                y1: 1,
                colorStops: [{ offset: 0, color: '#d2e6c9' },
                             { offset: 1, color: 'white '}]
            };
            $('#jqChart').jqChart({
                title: { text: 'IPv4 / IPv6 prefixes' },
                border: { strokeStyle: '#6ba851' },
                background: background,
                tooltips: { type: 'shared' },
                animation: { duration: 1 },
                shadows: {
                    enabled : true,
                    shadowColor: 'gray',
                    shadowBlur: 10,
                    shadowOffsetX: 10,
                    shadowOffsetY: 10
                },
                selectionRect: {
                    fillStyle: 'rgba(125,125,125,0.2)',
                    strokeStyle: 'gray',
                    lineWidth: 1
                },
                mouseInteractionMode: 'zooming', // zooming, panning

                axes: [{
                         
                         type: 'linear',
                         location: 'left',
                         zoomEnabled: true,
                         title: { text: 'Number of prefixes', fillStyle : 'green' },
                         <?php
                         $visibility=mysql_query("SELECT min(IPv4), max(IPv4) from Prefix_Count_History");
                        while ($donnee = mysql_fetch_array($visibility))
                          {
                             $min = intval($donnee[0]);
                             $max = intval($donnee[1]); 
                             $result1.= "visibleMinimum: ".$min.",";   
                             $result2.= "visibleMaximum: ".$max."";   
                          }
                           echo $result1;
                           echo $result2;
                         ?>
                           
                       },

                        {   
                            type: 'dateTime',
                            location: 'bottom',
                            zoomEnabled: true,
                            title: { text: 'Date', fillStyle : 'green' }
                        }
],

                series: [
                            {
                                type: 'line',
                                title: 'IPv4',
                                data: [ <?php
                                        while ($donnees = mysql_fetch_array($query))
                                          {
                                            $date = addslashes($donnees['Date']);
                                            $time = addslashes($donnees['Time']);
                                            $D = date_create(''.$date.'');
                                            $stamp= date_format($D, 'Y-m-d');
                                            $ipv4=intval($donnees['IPv4']);
                                            $data .= "['".$stamp."', ".$ipv4."],";
                         
                                          }
                                         echo $data;
                                      ?>]
                            },

                            {
                                type: 'spline',
                                title: 'IPv6',
                                data: [<?php
                                        mysql_data_seek($query, 0);
                                        while ($donnees = mysql_fetch_array($query))
                                          {
                                            $date = addslashes($donnees['Date']);
                                            $time = addslashes($donnees['Time']);
                                            $D = date_create(''.$date.'');
                                            $stamp= date_format($D, 'Y-m-d');
                                            $ipv6=intval($donnees['IPv6']);
                                            $data2 .= "['".$stamp."', ".$ipv6."],";
                                          }
                                         echo $data2;
                                      ?>]
                            }
                        ]
            });
        });
    </script>

</head>
<body>
    <div>
        <div id="jqChart" style="width: 1100px; height: 300px;">
        </div>

    </div>

</body>
</html>


                         
                             

Dragan
#4 Posted : Wednesday, May 15, 2013 5:08:28 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

Is it possible to give me a running sample with html and JavaScript only? Or at least a screenshot of your chart? It's quite hard for us to give you directions without running or seeing the chart.
Best Regards,
Dragan Matek
jqChart Inc.
bloomingdals
#5 Posted : Friday, May 17, 2013 10:12:28 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/3/2013(UTC)
Posts: 9

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Thank you for your time. I will send you a screenshot by mail to support.com
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.113 seconds.