logo
down
shadow

Highcharts: create multiple series grouped my month and year using JSON data


Highcharts: create multiple series grouped my month and year using JSON data

By : hpajaro
Date : December 02 2020, 10:46 PM
should help you out You can achieve it simply by creating a Date object using different parameters.
Instead of the string date parameter new Date('2019-07-07') use year and month as separate parameters like that: new Date(2019, 7).
code :
var json = [{
  month: 6,
  year: 2019,
  starts: 21278998,
  completes: 9309458
}, {
  month: 7,
  year: 2019,
  starts: 38850115,
  completes: 17790105
}];

var series1 = {
    name: 'starts',
    data: []
  },
  series2 = {
    name: 'completes',
    data: []
  };

json.forEach(elem => {
  series1.data.push({
    x: +new Date(elem.year, elem.month),
    y: elem.starts
  });

  series2.data.push({
    x: +new Date(elem.year, elem.month),
    y: elem.completes
  });
});

Highcharts.chart('container', {
  chart: {
    type: 'spline'
  },
  xAxis: {
    type: 'datetime'
  },
  series: [
    series1,
    series2
  ]
});


Share : facebook icon twitter icon
C# - Parse Year/Month from multiple files, run program and create new file in subfolders (year/month)

C# - Parse Year/Month from multiple files, run program and create new file in subfolders (year/month)


By : Yasmine Annisa
Date : March 29 2020, 07:55 AM
I hope this helps you . I currently have a program where I am taking existing log files from a directory, running through each one and calculating statistics, then creating a new file from that.
code :
  String filename = "2012-4-24.log";
  String file = Path.GetFileNameWithoutExtension(filename);
  String[] parts = file.Split('-');
  if (parts.Length == 3)
  {
    String year = parts[0];
    String month = parts[1];
    String day = parts[2];

    Console.WriteLine(string.Format("year:{0} - month:{1} - day:{2}", year, month, day));
  }
Highcharts with JSON data and multiple series

Highcharts with JSON data and multiple series


By : Deimantas ThroneRush
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You should look at this: http://api.highcharts.com/highcharts#series.data
If you specify each point as an object, you can add any property you want to each point and access it in your tooltip formatter through this.point.
code :
var seriesArr = [];
$.each(jdata, function(key, data) {
  var series = {name : key, data : []};

  $.each(data.y, function(index, value) {
    series.data.push({y: value });
  });

  $.each(data.n, function(index, value) {
    series.data[index].n = value;
  });
  seriesArr.push(series);
});
seriesArr : [{
    name : 'Total',
    data : [
      {y:9.39, n:9.62},
      ...
    ]
  },
...
]
tooltip: {
  formatter: function () {
    return 'Y value is : ' + this.point.y + '<br>' + 'N value is : ' + this.point.n;
  }
},
Retrieving JSON data for Highcharts with multiple series?

Retrieving JSON data for Highcharts with multiple series?


By : CamillaCarrillo
Date : March 29 2020, 07:55 AM
it fixes the issue I've been looking through tons of examples but I can't seem to get my code to pull out the data. The chart is blank. , As per Pal's comment - changed it to this:
code :
val1.push([value[0], value[1]]);
val2.push([value[0], value[2]]);
Highcharts: create multiple series using JSON data

Highcharts: create multiple series using JSON data


By : user3042529
Date : November 28 2020, 12:01 PM
will help you You can achieve it by splitting the JSON data into two separate series to look like that:
code :
[{
  "name": "starts",
  "data": [{
    "x": 1562457600000, // date in milliseconds
    "y": 42
  }, {
    "x": 1562544000000,
    "y": 2
  }, {
    "x": 1562630400000,
    "y": 28
  }]
}, {
  "name": "completes",
  "data": [{
    "x": 1562457600000,
    "y": 142
  }, {
    "x": 1562544000000,
    "y": 90
  }, {
    "x": 1562630400000,
    "y": 175
  }]
}]
Create rows for missing months in data grouped by year and month (multi index)

Create rows for missing months in data grouped by year and month (multi index)


By : user3386163
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further So Actually I found a solution to my problem. It involves the following steps: 1) instead of using .groupby(year, month) and get a multi index, I use .set_index(['year', 'month']).sum(level=[0,1]).reset_index() so that my group index does not involve datetime variables.
2) I create a 'date' column from the "year" and "month" columns, I used to group my date, using: pd.to_datetime(walney_month[['year', 'month']].assign(day=1)) ##Note: I need to assign a day (here, each monthly values are associated with the first day of the month).
code :

walney_day = walney_wff.set_index(['year', 'month', 'day']).sum(level [0,1,2]).reset_index()

walney_day['dry'] = np.where((walney_day['precp']==0), 1, 0).copy()

walney_month = walney_day.set_index(['year', 'month']).sum(level=[0,1]).reset_index()

walney_month['date'] = pd.to_datetime(walney_month[['year', 'month']].assign(day=1))

walney_month = walney_month.set_index('date')

all_months = pd.date_range(walney_month.index.min(), walney_month.index.max(), freq='MS')

walney_month = walney_month.reindex(all_months)
Related Posts Related Posts :
  • redux how to use state
  • All data in the db is lost when closing a express based node js server
  • How to convert javascript code for Angular
  • XPath select on child nodes
  • Idle event on mouse move - how to stop script permanently on mouse move
  • Why do I get logic is not defined in this code
  • When I enter a number in the input, the first function starts
  • ES6 imports and node_modules hell
  • How to get css selector of clicked-on element?
  • How to auto input MySQL data (input column 1 data to auto input column 2 data with same column) in php?
  • Appending to Datalist Via Javascript
  • Customizing Material-UI Components with Styled-Components
  • Populate elements with class name using Javascript
  • How to execute promises in batches (first resolving 10, then next 10 and so on)
  • Maximo JS automation script: "importPackage" is not defined
  • How to surround selected text inside textarea with <em> on key combination CTRL+i?
  • Your configured registry does not support audit requests ~ On npm audit
  • What's the Angular equivalent of Vue <slot/>?
  • Iconify icon not updating when "data-icon" set with setAttribute()
  • Javascript newbie stuck with XMLHttpRequest return data
  • How to add obj to to state in my example Redux React
  • Loading "grunt-karma.js" tasks...ERROR >> SyntaxError: Unexpected identifier
  • Why do I get log is not defined
  • get the multiple index of the same string
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Instantiate subclass without constructing
  • Outputing a created object in javascript to a server side JSON file
  • Transition the numeric labels in a bar chart
  • createBottomTabNavigator: hide just one tab from the tabBar
  • iife vs simple statement behavior with document.title
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • Nodejs javascript added to button not responding
  • Trying to define a promise.all
  • Python GEE to extract featurecollection timeseries from Landsat imageries
  • How to write negative binary number?
  • Unable to set property of individual object
  • Why Named Function Expression itself cannot assign Name to another Value?
  • How to reset scroll position on single page pagination
  • How to scroll to bottom of page, when a new message is sent - Socket.io
  • How to reconstruct audio blob from a base64 encoded String?
  • How to calculate numbers within an array of objects
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org