Okay
  Public Ticket #949450
Multi line chart
Closed

Comments

  •  1
    Terry started the conversation

    I have a simple table in a mysql database.

    It contains 3 fields: TIME/DATE, COUNTRIES, DATA.

    Is it possible a line chart with multiple lines?

    In essence, I need to create a timeline line chart that can compare DATA variations for multiple COUNTRIES over TIME/DATE.

    If this is possible can you please explain how I can do it?


    I have created a single line chart using the following table (sql query)

    SELECT countrydata.DATE,
           countrydata.DATA

    FROM countrydata

    WHERE 1=1 
       
    AND countrydata.country = 'Afghanistan'

    Unfortunately, I have no idea how I can create a multiline using this type of query.


  • [deleted] replied

    Hi Terry,
    Thank you for your purchase.

    When you are creating charts first column that you add should be String, Date or DateTime column type and second should be Integer or Float column type for Pie charts or Donut chart. For other charts that are supporting more then two columns first should be String, Date or DateTime column type and other columns should be Integer or Float. In you case first column that you can be TIME/DATE or COUNTRIES and second one can be DATA if it is Integer or Float column type.

    You can take a look how  to create chart in our documentation and what column types you should include:

    http://wpdatatables.com/documentation/wpdatacharts/creating-charts-wordpress-wpdatachart-wizard/

    http://wpdatatables.com/documentation/wpdatacharts/highcharts/

    http://wpdatatables.com/documentation/wpdatacharts/google-charts/

  •  1
    Terry replied

    Thanks for your reply, Milos but I am still very confused.

    Below is an example of the format of my table. I have also attached 2 images. (1. table in sql. 2. example chart design that I need)

    2016-10-01 Afghanistan 5.7351234875
    2016-10-01 Albania 0.2486325211
    2016-10-01 Algeria 1.524946129
    2016-10-02 Afghanistan 5.2837486638
    2016-10-02 Albania 0.0393928377
    2016-10-02 Algeria 1.8398746644
    2016-10-03 Afghanistan 5.5958776394
    2016-10-03 Albania 0.998899331
    2016-10-03 Algeria 1.847476637

    As you can see from the screen capture of the table in sql, the table 218,751 records/rows because it has daily data for each country (200 countries) from the past 3+ years). It has these fields

    DATE - This field has date (200 daily records for each date representing all countries)

    COUNTRY - This field has the country name associated with the daily date and data entry

    DATA - This field has the data entry for each country on each day


    I need to create a multi line chart and my issue seems to be pulling the data to create a table that can then be visualized in a line chart. 

    You will notice that the data is rather long (example. 5.37668828). I can list it as an integer as long as the number is reflected properly and not entered as 5 (as opposed to 5.37668828).

    The date can be a string but I dont understand how I then include the country column.

    Lastly, once I have the data there is no way to visualize multiple lines.

    For a single line table and chart I was able to create the following query.

    SELECT fragileindicators.DATE,
           
         fragileindicators.FRAGILE

    FROM fragileindicators

    WHERE 1=1 
       
         AND fragileindicators.country = 'Afghanistan'


    Unfortunately, I cant use this for a multi line chart.

    Can you please send me an actual example of how to create a table and chart for multiline charts?


    Thanks



  • [deleted] replied

    Hi Terry,

    I will give you example of table in attachment how it should be structured to create multiple line chart. Each of these countries should be separate column with own values so you would be able to create chart like this. In your case one column that you add to chart (First column from the example) should be Date column type (You have to set Date column type in Optional Column Setup) and other columns (Countries) should be Float column type if you want to show them with decimal places (You have to set Float column type also in Optional Column Setup in table settings).

    Date column will be used as chart categories (Dates on X axis on your screenshots), and Countries column will be used as Series.

  •  1
    Terry replied

    all fixed. Thanks!

  • [deleted] replied

    Hi Terry,

    You are welcome. We'd greatly appreciate it if you could take a minute and leave a review on CodeCanyon on this link. Thanks!