I have two object that I want to merge in a new object, the first object is for default options for a google chart:
optionsA = {
    height: 500,
    focusTarget: 'category',
    hAxis: {
      showTextEvery: 0,
      slantedText: true,
      slantedTextAngle: 45,
      format: 'date',
    },
}
With my second object I want to add some properties to hAxis and override present options with the new values but I want to keep the options by default in optionsA.
This is my second object:
optionsA = {
    isStacked: true,
    hAxis: {
      gridlines: {
        count: 10
      },
      format: 'percent',
    },
}
These objects are more complex but I reduce the properties to simplify the question
When I try to merge with object.assign the result is that object B add new root properties to the new object, but properties in hAxis is complete overrided with the options in optionsB.
let newObj = Object.assign({}, optionsA, optionsB);
This is the object that I want expected:
{
    height: 500,
    focusTarget: 'category',    
    isStacked: true,
    hAxis: {
      gridlines: {
         count: 10
      },
      format: 'percent',
      showTextEvery: 0,
      slantedText: true,
      slantedTextAngle: 45,
    },
}
but instead of this I am getting this:
{
    height: 500,
    focusTarget: 'category',    
    isStacked: true,
    hAxis: {
       gridlines: {
         count: 10
       },
       format: 'percent',
    },
}
Properties in hAxis are completely override with the new properties, what's wrong with my aproach?
 
     
    